Cleaning up the loops
authorNeil Smith <neil.git@njae.me.uk>
Thu, 24 Dec 2020 11:54:14 +0000 (11:54 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Thu, 24 Dec 2020 11:54:14 +0000 (11:54 +0000)
advent15/src/advent15loop.hs

index 7d2d258c87150bf19ee47e1aacb3b17f1535cc50..f023cf9e330717d0a39c066d82f5c952165f0412 100644 (file)
@@ -25,6 +25,11 @@ runGame seed roundsNeeded =
        gameLoop roundsNeeded round word history
        readSTRef word
 
+gameLoop targetRound round word history =
+    do gameStep round word history 
+         `untilM_` ((== targetRound) <$> readSTRef round)
+       return ()
+
 -- gameLoop targetRound round word history =
 --     do ( gameStep round word history 
 --          `untilM_` (do r <- readSTRef round
@@ -44,11 +49,16 @@ runGame seed roundsNeeded =
 --                (gameStep round word history ) 
 --        return ()
 
-gameLoop targetRound round word history =
-    do whileM_ (do r <- readSTRef round
-                   return $ r /= targetRound )
-               $ gameStep round word history
-       return ()
+-- gameLoop targetRound round word history =
+--     do whileM_ (do r <- readSTRef round
+--                    return $ r /= targetRound )
+--                $ gameStep round word history
+--        return ()
+
+-- gameLoop targetRound round word history =
+--     do whileM_ ((/= targetRound) <$> readSTRef round)
+--                $ gameStep round word history
+--        return ()
 
 seedGame seed historySize = 
   do round <- newSTRef $ length seed