Functional Requirements

For this assignment, you will be writing a program that can be used to play checkers (aka English Draughts). Checkers is a simple game played on a 8x8 checkered board (32 dark squares and 32 light squares). There are two colors of pieces, red and black, each being played by one human player. Each player starts with 12 pieces. The black piece player goes first. Rules of moving, jumping (capturing), and board layout can be found at this link (ignore instructions specific to the site). The objective of the game is to capture all of the opposing pieces. Do not worry about ties or draws.

Starting the Assignment

The starter repository (linked in canvas contains a new Windows Forms Application in which Form1.cs has been renamed UserInterface.cs. The pictures used for the checker pieces are in the included pics folder. An obfuscated executable is included a zip folder.

User Interface

The base interface is very simple. It should be impossible to maximize or otherwise resize this window (set the Form's MaximizeBox property to false and its FormBorderStyle property to Fixed3D to accomplish this). It includes a menu strip that has File->New Game as menu items. If a user clicks the "New Game" option, the existing board will be cleared and replaced with a fresh game. Under the menu strip, a FlowLayoutPanel should be added. The program will place all of the board squares, with the pieces, into this panel. The user will be able to interact with the board by clicking on a piece then the board square they wish to move it to. A piece is highlighted once it is selected. The user can then click on another square to move the piece or capture an enemy piece. If the square the user clicked to move to is not a valid move, a MessageBox appears indicating that it is an invalid move. At the bottom, add a StatusStrip that has the RightToLeft property set to Yes. It should also contain one label. This will indicate whose turn it is (ex: "Red's Turn"). Once all of the pieces of either side have been captured, the game is over and a MessageBox appears indicating the winner. The rest of the interface is generated by your program.

checker UI

Software Architecture

hw2-uml

The UserInterface class is primarily used for drawing/updating the UI for when the game is created and when a piece is interacted with. All of the actual logic for checkers is contained inside the Game class. Each square on the checker board will be represented using BoardSquare's. This class is also indicates whether or not a square contains an actual piece. The enum SquareColor is used to indicate this information.

Representing the Game Board

For this assignment, you will be representing the checkers board using a dictionary of linked lists. For the dictionary, the Key will be the row of the board. The Value will be the first cell of a linked list containing each BoardSquare. This cell should be the left most square (i.e. column) in that row. This structure can be seen when the board is numbered like the image below. Each row has an entry in the dictionary, where the key of each row is a number 1-8. Each value in the dictionary is a linked list of squares, also labeled 1-8, for a given row. The text in each of the below squares are the row-column for each board square. These are given in this image to help with debugging. To add this, when drawing the board, simply set the Text property.

hw2-numberedSquares

Coding Requirements

Specific requirements for the above classes are given in what follows. Feel free to add more private methods if you feel it improves the code. Note that some methods below are public for testing purposes.

The LinkedListCell< T > Class

This class is given.

BoardSquare.cs

The class contains the following properties:

The class also contains a public constructor that takes in two integers as parameters. These represent the row and the column of the BoardSquare class. The Row and Column variables defined above should be set to these parameters.

In addition to the BoardSquare class, the BoardSquare.cs file should contain an enum defined as:

We have used enumerators like this before, like with DialogResult when using open/save dialog boxes for files. Red, Black, and None can be accessed like so: SquareColor.Black. These are used to indicate the color of a piece. SquareColor.None is used if there is no piece on a square.

The Game Class

The Game Class holds most of the logic for checkers. This class contains the following fields:

This class contains the following properties:

This class contains the following methods:

The UserInterface Class

The UserInterface class is responsible for drawing and updating the checker board. This class contains the following fields:

This class contains the following methods:

This class contains the following event handlers:

Testing Your Program

Be sure to test win conditions for both sides, and each kind of move/jump. To assist in testing your program, it can be helpful to add text to your board squares to indicate the row and column. Unit tests are also provided to test PART of the features. These unit tests are not exhaustive, meaning they do not test every feature/requirement. The CheckAnyJump, Jump, and MoveSelectedPiece are not unit tested at all since they highly depend on the state of the board through interactions with the GUI. The unit tests are provided to assist testing helper methods of the more complex methods (like Jump and MoveSelectedPiece).

Performance

Each move made in the game should be instant and have relatively no delay. There will be a cascade effect when creating a new game.

Submitting Your Assignment

Be sure to commit all your changes, then push your commits to your GitHub repository. Then submit the entire URL of the commit that you want graded.

The repositories for the homework assignments for this class are set up to use GitHub's autograding feature to track push times. No actual testing/grading is done, but after each push, the GitHub page for the repository will show a green check mark on the line indicating the latest commit. Clicking that check mark will display a popup indicating that all checks have passed, regardless of whether your program works. You may also get an email indicating that all checks have passed. The only purpose for using the autograding feature in this way is to give us a backup indication of your push times in case you submitted your assignment incorrectly.

Important: We will only grade the source code that is included in the commit that you submit. Therefore, be sure that the commit on GitHub contains all .cs files, and that it is the version you want graded. This is especially important if you had any trouble committing or pushing your code.