Description
In this project you will be implementing the logic to complete a “game of fifteen” board game which has been generalized to an NxN board. You may need to look up the game and learn about it (https://en.wikipedia.org/wiki/15_puzzle).
You will be provided with a skeleton program, which has the framework of the game implemented already, in a file fifteen.c.
Before starting implementation, you should follow through the next sections of this document.
Compile and Run
As the next step, ensure that you can compile and run the file as it is. You will need to provide an integer, representing the dimension of the board, as a command line argument.
Test the functionality of the program (the user may type tile ‘0’ to exit the program).
Read over the code and comments in the file and then answer the questions in the next section.
Questions
For this assignment you must also answer a few questions. The answers to these questions should be placed in your README.
- Besides 4×4, what other dimensions does the framework allow?
- What data structure is used for representation of the game board?
- What function is called to greet the player?
- What functions do you need to implement?
Important Information
- The game must begin with the board’s tiles in reverse order, from largest to smallest going from left to right, top to bottom, with the empty space in the board’s bottom-right corner. A 3×3 example starting configuration is depicted below:
8 7 6
5 4 3
- 1 _
- Important: If the board contains an odd number of tiles (i.e. the height and width of the board are even), then the positions of tiles numbered 1 and 2 must be swapped, as in the 4×4 example below:
15 14 13 12
11 10 9 8
7 6 5 4
- 1 2 _
- In order to move a tile, there must be an adjacent blank space.
- Your program should not crash when provided with bogus tile numbers. You should check these inputs.
Hints
- Take “baby steps” – implement small pieces of functionality one at a time and test each new increment.
- A suggested ordering of procedures to implement: init, draw, move, won.
- Some design choices are left to you where not otherwise specified. Presumably the board should look something like:
15 14 13 12
11 10 9 8
7 6 5 4
3 1 2 _
- Remember that the positions of tiles 1 and 2 must be swapped for even dimensioned game boards.
- You may automate input to this game using input redirection. You will be provided with test files which contain sequences of valid moves to verify the operation of your program.





