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, where I’ve put * next to the ones that are (in my opinion) more difficult.  But even better is to come up with something I haven’t thought of here!

Connect4

Mastermind

Othello

Checkers

Chess*

Concentration (use unicode emoji for the “cards”, maybe)

2048*

Battleship*

Sokoban*

Part 0: Play Games

Play some games. There are some appropriate online games here.

https://docs.google.com/document/d/1n89bbdy1q7NwBdPMwOHKOVX7IO1fSIqhBHkEQfR2iM8/edit?usp=sharing

Part 1: Presentation

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.  Show a single moment in the game, and what the values are in your model that correspond to that moment.

Algorithms

Consider your algorithms for init(), move(), and won().  If you have two players, OR a player and a computer player, you might have 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 Connect4.     Don’t create your algorithms by writing code!  Create them in pseudocode, or with a diagram, or something.   

Make a slideshow presentation about the game you’ve chosen. Show both your model and your algorithm. Make a short video of you giving your presentation. Use screencastify or something similar.

Part 2: Code

Code your game.  Since we don’t have check50, have someone other than yourself playtest it to make sure there are no edge cases (moving a piece off the board, etc) that break your game.  Code your game one function at a time.   

Use lots of comments! A great way to write an algorithm is to start with comments that describe what you’re going to do, and then write code that does each step.

You may use Fifteen as a guide for creating your main function, but don’t just copy stuff! And especially don’t copy and paste. Your squares project should be your own work.

Part 3: Video

If you’re taking the AP Exam, you’ll need to submit a one minute (max) video to the college board “that demonstrates the running of your program.” Whether you’re taking the exam or not, you’ll create this video and turn it in to me.