I wrote an TicTacToe AI game. I published it here.
https://tronyeu0802.github.io/TicTacToe-elm/
Currently, when you make a move, the game will calculate an AI move then
the browser will display both your move and the AI move at the same time. I
did this by create and perform a task that always succeeds with the AIMove
message.
update msg model =
case msg of
Toggle indexToToggle ->
( { model
| board = move indexToToggle model.turn model.board
}
, Task.perform (\_ -> Debug.crash "This failure cannot
happen.") identity (Task.succeed AIMove)
--Cmd.Extra.message AIMove
)
AIMove ->
( fst (miniMax model 0)
, Cmd.none
)
How can I display the player's move, then the AI's move after that?
I'm thinking that this could be done by subscribing to the number of
available moves left. If this is even then do an AI move else do nothing.
I'm very new to ELM so I hope you can teach better ways to achieve this. :D
Thank you
--
You received this message because you are subscribed to the Google Groups "Elm
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.