CS 102 (Fall '09)
[Schedule]
[Programs]
[Notes
& Reference] [Examples][Syllabus]
[Lab & TA] [Tests]
[Grades]
Prof. Reed, CS 102, Spring '09
Due Tuesday 11/17 at 2:00 p.m.
Write a program in C to play the game of Kaos (similar to the Mindware game of Chaos). For a video introduction of how the game is played, see the following video:
Our situation programming in C is a bit different, as we will be using a text interface and will not be designing a graphical interface. See what our interface will look like:
As illustrated above, our user interface is text-based, with an additional trace shown below. See this trace for an even longer example of the program running. As mentioned in the video, you can run the program yourself from your CS account, by typing in:
~i102/Kaos
which will start an executable copy of my program.
Note that since we can't graphically represent truly stacking pieces, we are showing them in a list.
Author: Dale Reed Date: 11/3/2009 Class: CS 102, program #4 Welcome to the game of Kaos! Each player starts with 12 pieces and take turns placing the pieces on a 3x3 board. Pieces can be stacked on top of each other. Once a 4th piece is placed on a stack, the pieces are redistributed in a clockwise direction to the immediately (but not diagonal) squares, starting with the square furthest from the player. Pieces that go "off" the board are returned to their respective original owner, to be replayed. The winner is the player that gets rid of her pieces first. --------------------------------------------- Pieces for X: 12 _ _ _ _ _ _ _ _ _ 1 2 3 _ _ _ _ _ _ _ _ _ _ _ _ 4 5 6 _ _ _ _ _ _ _ _ _ _ _ _ 7 8 9 _ _ _ Pieces for O: 12 1. Enter the square for 'X' to move: 5 --------------------------------------------- Pieces for X: 11 _ _ _ _ _ _ _ _ _ 1 2 3 _ _ _ _ _ _ _ _ _ _ _ _ 4 5 6 _ X _ _ _ _ _ _ _ _ _ _ 7 8 9 _ _ _ Pieces for O: 12 2. Enter the square for 'O' to move: 5 --------------------------------------------- Pieces for X: 11 _ _ _ _ _ _ _ _ _ 1 2 3 _ _ _ _ _ _ _ _ _ _ O _ 4 5 6 _ X _ _ _ _ _ _ _ _ _ _ 7 8 9 _ _ _ Pieces for O: 11 3. Enter the square for 'X' to move: 5 --------------------------------------------- Pieces for X: 10 _ _ _ _ _ _ _ _ _ 1 2 3 _ _ _ _ _ _ _ X _ _ O _ 4 5 6 _ X _ _ _ _ _ _ _ _ _ _ 7 8 9 _ _ _ Pieces for O: 11 4. Enter the square for 'O' to move: 5 Full stack at position 5 --------------------------------------------- Pieces for X: 10 _ _ _ _ _ _ _ _ _ 1 2 3 _ _ _ _ O _ _ X _ _ O _ 4 5 6 _ X _ _ _ _ _ _ _ _ _ _ 7 8 9 _ _ _ Pieces for O: 10 Redistributing pieces for 'O' at position 5 --------------------------------------------- Pieces for X: 10 _ _ _ _ _ _ _ _ _ 1 2 3 _ O _ _ _ _ _ _ _ _ _ _ 4 5 6 X _ X _ _ _ _ _ _ _ _ _ 7 8 9 _ O _ Pieces for O: 10 5. Enter the square for 'X' to move: 4 --------------------------------------------- Pieces for X: 9 _ _ _ _ _ _ _ _ _ 1 2 3 _ O _ _ _ _ _ _ _ X _ _ 4 5 6 X _ X _ _ _ _ _ _ _ _ _ 7 8 9 _ O _ Pieces for O: 10 6. Enter the square for 'O' to move:
turnin -c cs102 -p prog4 Kaos.cpp
where the file containing your solution is called Kaos.cpp.
[CS Dept] [UIC] [Prof. Reed]