Main

Assignment 3

Due: Wednesday of week 4

In our last C assignment, you will practice dynamic memory management, and additionally, you will use structs, typedefs, and enums to implement a text-based version of the Othello (Reversi) board game.

A description of the steps of the game is available here. Some more examples are available here. You only need to implement the standard rules (not optional expert play.)

You can see an example session in this video. Example executables are on ix-dev, ~norris/public/cis330/assignment3.

The details of the design and implementation are intentionally not spelled out in great detail. You have significant freedom to organize the code in a way you find reasonable, and you are free to ask if certain decisions are good or not as you refine your design.

You have a choice between human vs. human and human vs. computer. You will indicate which one you chose by the name of your executable. For human vs. computer, name your executable othello. For human vs. human, name it reversi. You are only required to implement one of those, but if you decide to implement both, you can earn up to 10 extra points.

Create and use a directory named assignment3 in your git repo containing all source files and the Makefile.

The following are the only requirements (with the requisite point values):

1. (5) In the very beginning of the game, prompt for the board size, e.g., to create a 12x12 board:

./othello
Please enter the size of the board: 12
..... the game input/output ....

2. (10) You have to use a struct, e.g., to represent the contents of the board

3. (5) You have to use an enum, e.g., for the possible colors of the disks

4. (5) You have to use a typedef, e.g., with your struct or enum (all these should be in your header file)

5. (20) Memory allocation, initialization, computing the next move, etc. should be in separate functions. Your main() should contain very few implementation details apart from calling functions.

6. (10) You must have a header file and separate implementation in at least one *.c file.

7. (15) Create a Makefile that builds an executable named othello if you are implementing human vs computer and reversi if you are implementing human vs human (please try to spell these exactly as asked, it makes testing much less onerous). The command make othello should produce the othello executable or equivalently, make reversi should produce the reversi executable.

8. (20) Everything compiles (10) and runs correctly (10)

(10) Style: well-structured code, comments, no or few global variables.

Do not assume valid input and do your best to manage incorrect input without crashing or producing incorrect behavior.

What to commit to the repo, in the assignment3 directory.

  • All *.h and *.c files
  • Makefile
  • A text file output.log showing a sample game session you ran on ix-dev.

Note: I can google C solutions, just like you, so resist the temptation (recall that we use Moss for more sizable codes). It's better to lose most of the points in this assignment and learn something than to have a perfectly working code that you didn't write and risk failing the course.

Green Marinee theme adapted by David Gilbert, powered by PmWiki