[Haskell-beginners] Making a Tic-Tac-Toe Game

Theodore Lief Gannon tanuki at gmail.com
Wed Feb 22 07:18:55 UTC 2017


I know you said you didn't want code, but I think this will be helpful.
Here is an example of what the very top of your logic might reasonably look
like.

main :: IO ()
main = do
  someInitialization
  config <- someConfigurator
  result <- gameLoop $ makeInitialState config
  print result

gameLoop :: GameState -> IO GameResult
gameLoop gameState =
  let maybeEndState = discoverEndState gameState
  in case maybeEndState of
    Just endState -> return endState
    Nothing -> do
      playerMove <- fetchInput gameState
      gameLoop $ makeNextState playerMove


On Tue, Feb 21, 2017 at 8:35 AM, Sudhanshu Jaiswal <sudhanshuj007 at gmail.com>
wrote:

> Also called as Noughts and crosses or Xs and Os.
>
> Hello everyone,
>
> How do I start making a *Two Player* Tic Tac Toe game in Haskell?
>
> The program basically has to show the 3*3 grid as coordinates and let each
> player choose his coordinates in his turn by entering the coordinates of
> the required cell. I also want to be able to check if a player has won and
> display it once the winning move has been made or the same for a Draw.
>
> What have I done? - I have read Learn You a Haskell till Modules and know
> basic I/O.
>
> I don't want the code instead, I am interested in learning stuff and
> trying problems which would lead me to get the intuition and ability to
> make the game by myself.
>
> I would be thankful if you folks could direct me to related problems which
> I could do or some advice as to how I should go about implementing such a
> program.
> --
> Sudhanshu
>
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20170221/7205ce91/attachment.html>


More information about the Beginners mailing list