Skip to content

Instantly share code, notes, and snippets.

@dmwit
Created April 17, 2020 00:29
Show Gist options
  • Save dmwit/8e97cb361e41689d33feff49dde58341 to your computer and use it in GitHub Desktop.
Save dmwit/8e97cb361e41689d33feff49dde58341 to your computer and use it in GitHub Desktop.
--- test.hs.old 2020-04-16 20:27:41.179931585 -0400
+++ test.hs.new 2020-04-16 20:29:04.908156993 -0400
@@ -88,17 +88,17 @@
play (play_movement board Player (read col::Int)) Machine strat
--WIP
-machine_turn :: Board -> Strategy -> Board
+machine_turn :: Board -> Strategy -> IO Board
machine_turn board Random = machine_random_ia board
---WIP
-machine_random_ia :: Board -> Board
+machine_random_ia :: Board -> IO Board
machine_random_ia (Grid w h l) = do
- play_movement (Grid w h l) Machine rint
+ rint <- randInt 0 (w-1) -- TODO: shouldn't this be randInt 0 (length options-1) ?
+ pure $ play_movement (Grid w h l) Machine (options !! rint)
where
notfull = \x -> ((used_board_cells (Grid w h l) x) < h)
options = filter notfull [0..(w-1)]
- opt = options !! (randInt 0 (w-1))
--WIP
play :: Board -> Owner -> Strategy -> IO()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment