LGA-12: Haskell Tic Tac Toe

For this assigment, you will be reading someone else’s code. The code is well written Haskell code, but I imagine it will be non-trivial to follow, as you are probably a Haskell beginner.

First, download this Tic-Tac-Toe implementation.

Then, collaboratively, as a learning group, answer these questions:

  1. (10 points) How the game is displayed? Trace showBoard (use moves [(One, TL), (Two, TR)]), explain uses of Just/Nothing, explain how/when showBoard gets called, etc.
  2. (2 points) Explain how we start with a new game
  3. (10 points) Explain how the program accepts/validates a player’s move. How does it show the list of valid moves? Be sure to review getPosition as well as validMoves.
  4. (18 points) Explain how move alters the game state.
  5. (6 points) Explain the case statement in playGame.
  6. (2 points) Code does not appear to stop when the game is a draw. What would you need to modify? (you don’t have to write code, just think at a high level where the problem is).

Hint

If you get stuck figuring something out, it may help to load the file, set up some bindings (e.g., let bd = [(One, TL), (Two, TR)]), then run individual functions to see how they perform. I did this with several of the functions.

Your group should produce a single set of typed answers. I recommend you meet outside of class to complete this assignment.

To turn in the assignment, submit on Gradescope.

Notice that there are points assigned to each of the questions, that is because this will count towards the programming portion of your grade as well as the LGA. Since this counts towards your programming grade, you have until Tuesday, March 13th at 11:59 PM to complete the assignment. When I check the LGA on March 1st, I’ll simply give you the check if you made some effort to look over this ahead of time (and can answer questions then as well). Your group can spend slip days too if you would like, each 24-hours will cost 1 slip day from each group member.

I expect there to be questions on this assignment, send them to the mailing list!