CS 107 (Spring '09)
[Schedule]
[Programs]
[Notes
& Reference] [Examples][Syllabus]
[Lab & TA] [Tests]
[Grades]
Prof. Reed, CS 107, Fall '08
Due Tuesday 12/2 at 1:00 PM
Again implement Yote, implementing the same functionality as in the previous program. This time you will not have a graphical interface, but rather will use a text-based interface, with the program written in C++. Running the program will look like:
Author: Dale Reed Program: #5, Yote TA: Englebert Humberdink, T 4-5 Nov 19, 2008 Welcome to the ancient African game of Yote. On each turn, each player may either deploy a piece from their reserve to any empty space on the board, or move a piece already on the board. Moves must be made vertically or horizontally, but not diagonally. Pieces move either by sliding to an adjacent empty cell or by jumping over and capturing an adjacent opponent's piece, landing in an empty square immediately beyond. When a piece captures another piece, the player may then select any other opponent piece on the board (but not in their opponent's reserve) and capture it as well. The player who captures all of her opponent's pieces wins. If either player is unable to move, then the game ends and the player with the most pieces on the board wins. If both players are reduced to three or less pieces, then the game is a draw. The first character on the input line tells what kind of move it will be.
Possible inputs for each move are: x to exit program. A message tells who has the most pieces. p n1 p signifies placing a piece at postion n1, where n1 is a number 1..20 m n1 n2 m signifies moving a piece from board position n1 to n2 X goes first, then O. For reference, the square numbers are given at right below. Let's begin... ------------------- | . | . | . | . | . | 1 2 3 4 5 |-------------------| | . | . | . | . | . | 6 7 8 9 10 |-------------------| | . | . | . | . | . | 11 12 13 14 15 |-------------------| | . | . | . | . | . | 16 17 18 19 20 ------------------- 1. Enter move for X: p 7 ------------------- | . | . | . | . | . | 1 2 3 4 5 |-------------------| | . | X | . | . | . | 6 7 8 9 10 |-------------------| | . | . | . | . | . | 11 12 13 14 15 |-------------------| | . | . | . | . | . | 16 17 18 19 20 ------------------- 2. Enter move for O: p 2 ------------------- | . | O | . | . | . | 1 2 3 4 5 |-------------------| | . | X | . | . | . | 6 7 8 9 10 |-------------------| | . | . | . | . | . | 11 12 13 14 15 |-------------------| | . | . | . | . | . | 16 17 18 19 20 ------------------- 3. Enter move for X: p 12
turnin -c cs107 -p program5 YoteText.cpp
where the file containing your solution is called YoteText.cpp. [CS Dept] [UIC] [Prof. Reed]