(disclaimer: I am also quite new to Elm) 
I always try to avoid creating my own Cmd: there is usually a better, less 
bug-prone way to achieve this (e.g. with resursive update calls).

That said: I can see the logic in having a Msg originating from a "real" 
player, and another Msg from your AI player.

What you could do, is make a subscription to Time, that is only active if 
it is the AI's turn to move.
That way, you get a) a delay before the AI makes a move + b) you do not 
need to create your own command
Whenever it is the user's turn, or as soon as the game is over, the 
subscription is turned off.

Something like this:

subscriptions : Model -> Sub Msg
subscriptions model =
  if (gameIsNotFinished model && model.turn == AIToMove) then
    Time.every second AIMove
  else
    Sub.none

You would of course have to define your own functions to check if the game 
is still playing (no winner and no draw) and if it is the AI's turn to play.

-- 
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 elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to