Skip to content

Instantly share code, notes, and snippets.

@dschinkel
Last active September 11, 2018 18:37
Show Gist options
  • Save dschinkel/73b06251a85316d709533d00a4834558 to your computer and use it in GitHub Desktop.
Save dschinkel/73b06251a85316d709533d00a4834558 to your computer and use it in GitHub Desktop.
miniMax Algorithm in Elm - Tests - next move wins for row 2
nextBestMove gameNode =
let
cells =
fromList gameNode
nextGameState1 =
set 2 'X' cells
nextGameState2 =
set 5 'X' cells
in
if (get 0 nextGameState1 == get 1 nextGameState1) && (get 1 nextGameState1 == get 2 nextGameState1) then
2
else if (get 3 nextGameState2 == get 4 nextGameState2) && (get 4 nextGameState2 == get 5 nextGameState2) then
5
else
0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment