Squares

You just finished Fifteen, a one player puzzle game.  You used a framework where you created functions like init(), move(), draw() and won().  For each of these functions, you had to come up with an algorithm to get the job done.  In this assignment you’ll make another similar game of your own choice.  

Lots of games are turn based, and played on a grid of squares.  Here are a few, broken into three levels of difficulty (my opinion).  But even better is to come up with something I haven’t thought of here!

Easiest:

Tic Tac Toe (two player)

Middle:

Tic Tac Toe (one player against non-stupid computer player)

Connect4

Challenging:

Othello

Checkers

Chess

Concentration (maybe use playing cards?  There are unicode values for ♣, ♠, ♦, ♥)  Think about the move functions here.  Maybe make move1() and move2() separate.  

Part 1:  Model

Your game keeps track of its state as a set of variables.  In Fifteen, there was a two dimensional array of integers called board, along with two other integers to keep separate track of the position of the empty spot.  These last two were redundant but useful.   Describe the model for your game and turn it in along with the algorithms in part 2.  

Part 2:  Algorithms

 

Create your algorithms for init(), move(), and won().  If you have two players, OR a player and a computer player, make two separate move functions, one for each player.   In some cases one function might be trivial, but others might be difficult.  init() is trivial for Tic Tac Toe and Connect4.  Won() is trivial for checkers.   Don’t create your algorithms by writing code!  Create them in pseudocode, or with a diagram, or something.   Some of you will be standing up in front of the class to describe your algorithm.  

Part 3:  Code!

Code your game.  Since we don’t have check50, have someone other than yourself playtest it to make sure there are no broken edge cases (moving a piece off the board, etc) that break your game.  Code your game one function at a time.  You’ll also need to fix the part of main that draws your game to the log.  

Part 4:  Video

Make a two minute video.  The video should show you playing the game.  It should include an explanation of one of the algorithms in your game, and show how you turned that algorithm into code.