1. To verify that all students have the basic knowledge required to continue in cs1704, and
2. To introduce software development testing principles.
For this project, I will require:
1. A 3-dimentional array to represent the the mutliplayer checkerboard
2. A struct to represent a piece
3. enums to represent red vs. black and pawn vs. king
4. At least 1 switch statement,
5. At least 1 for loop,
6. At least 1 while loop,
7. At least 1 stringstream (example posted here),
8. You may not use classes, and
9. You may not use dynamic data.
In addition to the above requirements that you should already be familiar with, the following requirement will be taught the first week of class:10. You must use at least 3 testing switches, named 1 2 and 3
You will be implementing a console, command line based multiplayer checkers game. As stated in the requirements above, multiple checkerboards will be represented in memory as a 3D array of structs. Think of each checkerboard as a layer. Each layer is a checkerboard. Each struct will contain two members, the piece and the player. The player can be either red or black and the piece can be either king or pawn. You will use two enum's, one for the the players and one for the pieces.
When a player tries to make a move you will make sure the piece is following the following rules. (Some versions of checkers have other rules, for example, that if a jump exists you must jump. Do not enforce these other rules or your program will be incorrect.) If you are totally unfamiliar with checkers, see http://www.darkfish.com/checkers/Checkers.html for some basic hints.
- A piece can not move off the board.
- A pawn becomes a king if it lands on a space on the opponent's first row.
- A pawn can move one position diagonally forward to the right or left if another piece is not there.
- A pawn can move two positions diagonally forward to the right or left if an opponent's piece is in the "jumped" position and the new position is empty.
- A king can move one position diagonally forward or backwards to the right or left if another piece is not there.
- A king can move two positions diagonally forward or backwards to the right or left if an opponent's piece is in the "jumped" position and the new position is empty.
- A player cannot make two valid moves in a row (including double jumps as in most versions of checkers).
You will have to change the values of the members of the structs when a pawn becomes a king.
In addition, you will read commands from a file named checkers_in.dat. Each line represents a command. There may be blank lines in the file. In such cases, simple skip the line.
load<ws><levels>
- A load command will always be the first command in the file, however, it may occur more than once.
- Where levels is an integer representing the number of simultaneous checkerboards you will keep track of (each level of the array).
- There will never be more than 50 levels (you may make your checkerboard a static global array)
- You set up the board as shown below. Note that the left and right dimension here is x and the red vs black dimension (up on your computer screen) is y.
move<ws><level><ws><color><ws><x1><ws><y1><ws><x2><ws><y2><ws>
- Where ws is whitespace (tabs and/or spaces) and the last <ws> is optional
- Where level is an integer representing which checkerboard is referenced
- Where color is either red or black ( Note: don't forget to reverse the rules when checking the red checker's moves since the red player is facing the other directions!)
- x1 and y1 represent the current position of a piece and x2 and y2 represent where to move the piece to. The board is 1 based, however an array is 0 based!
- Note: if a player makes a valid move on a layer, the next time a player makes a move on that level, it must be the other player. The first player to make a move after setup is the "red" player.
print<ws><level>
- The output filename is checkers_out.dat....output in append mode
- Where ws is whitespace (tabs and/or spaces) and the last <ws> is optional
- Where level is an integer representing which checkerboard is referenced
- The output of the level will simply be an 8X8 printing of a level where bl stands for blank space, rp stands for red pawn, bp stands for black pawn, rk stands for red king, and bk stands for black king. Start at y=8, x=1 and print each row down to row 1. For example, the default setup should give the following output: The number of spaces between each board position is irrelevant.
bl rp bl rp bl rp bl rp
rp bl rp bl rp bl rp bl
bl rp bl rp bl rp bl rp
bl bl bl bl bl bl bl bl
bl bl bl bl bl bl bl bl
bp bl bp bl bp bl bp bl
bl bp bl bp bl bp bl bp
bp bl bp bl bp bl bp bl
- Output a single blank line after the board
quit
- Simply appends to the output file (checkers_out.dat) the following statistics that represent the sum from all levels: total valid moves, total invalid moves, total pawns at quit time, total kings at quit time. Sample output (where horizontal whitespace doesn't matter and the integers represent your program's.
Total Valid Moves:
256
Total Invalid Moves:
35
Total Pawns at Quit:
8
Total Kings at Quit:
88
- Design your project using Structure Charts and submit before 11:59pm of Wednesday, January 28th, 2004. (We will learn about Structure Charts in class.)
- You do NOT need to model the filestreams or stringstream, however you may.
- Use a Word Document (or Visio) to create the charts.
- Print out a hard copy to turn in on Friday, January 30th, 2004 during class.
As with all programming projects in this course, please see http://courses.cs.vt.edu/~cs1704/spring2004/standards.htm for a list of requirements that apply to all projects. YOU WILL BE GRADED on these. In addition, include the following pledge at the bottom of your .cpp file:
On my honor:
- I have not discussed the C++ language code in my program with anyone other than my instructor or the teaching assistants assigned to this course.
- I have not used C++ language code obtained from another student, or any other unauthorized source, either modified or unmodified.
- If any C++ language code or documentation used in my program was obtained from another source, such as a textbook or course notes, that has been clearly noted with a proper citation in the comments of my program.
- I have not designed this program in such a way as to defeat or interfere with the normal operation of the Curator System.
<Your Name>
Name your file <yourpid>.cpp and submit before 11:59pm of Monday, February 2, 2004. To receive credit, your assignment must be submitted before the time and date listed above. The curator can only accept a limited number of submissions per minute, so curator lag is not an excuse for submitting late. It is your responsibility to successfully submit your assignment via the curator, so plan to submit early. A maximum of 3 submissions is allowed per student, so DO NOT USE THE CURATOR FOR TESTING! Only the final submission will be graded, not your highest grade.
Submit to: http://www.cs.vt.edu/curator/