Homework 5, Candyland
Short Description:
Write a program which will simulate the game of Candyland.
This assignment is worth 100 points.
Goals
When you finish this homework, you should:
- Have reviewed and strengthened your design skills.
- Have reviewed and strengthened your skills with procedures and functions.
- Have used multiple arrays within a program.
Formal Description
The game of Candyland is a game
for children who can not read. The game consists of a game board (pictured below), a deck of cards and a set of gingerbread man markers. Players take turns (in order of age) drawing a card from the deck, and moving their gingerbread man marker to the appropriate square on the board.
For a the official set of rules, look here (or a local copy here). These rules apply unless changed in the discussion below.
Traditional Board Spaces:
The standard game board is made up of 136 spaces, each with a color. Normal spaces have a standard color (Red, Purple, Yellow, Blue, Orange, Green) but no name. Some spaces are special and my have a different color. There are four types of special spaces.
- Book Keeping
- Start (0), where the game begins.
- Candy Castle (135), where the game ends.
- These spaces do not have a color on the board.
- These spaces have a name.
- Penalty
- Gooey Gumdrops (48), stay until a yellow card is drawn by player.
- Lost in Lollipop Woods (86), stay until a blue card is drawn by player.
- Molasses Swamp (121), stay until red card is drawn by player.
- These spaces are colored according to the standard coloring pattern below. The color of the space determines the card needed to escape from the trap.
- These spaces have a name.
- Shortcuts
- Rainbow Trail (5), go to square 59
- Gumdrop Pass (34), go to square 47
- These spaces are colored according to the standard coloring pattern below.
- These spaces have a name (or, rather, the path out of these spaces has a name.)
- Characters
- Plumpy (9)
- Mr Mint (18)
- Jolly (43)
- Grandma Nut (75)
- Princess Lolly (96)
- Queen Frostine (104)
- These spaces are all Pink.
- These spaces all have a name.
To color the board,
- The character spaces are filled with the color pink.
- The Start and Candy Castle spaces are uncolored.
- The remaining spaces are colored in order (Red, Purple, Yellow, Blue, Orange, Green) starting with Red. Skip any Pink spaces.
Cards
The deck of cards indicate player movement. Cards are either normal movement cards or character cards. There is one character card for each character on the board. When a player draws a character card, the player moves to the corresponding character space on the board. In the normal game there are 6 player cards.
Normal movement cards contain either one or two colored squares, always the same color. For example a card may contain one or two blue squares. Only the standard colors (Red, Purple, Yellow, Blue, Orange, Green) are used, there are no Pink cards. In the traditional deck, there are 8 copies of each single color and two copies of each double card, for a total of 6×8+6×2 = 60.
There will be a total of 66 cards. *This differs from the rules*
A player consists of a name and an age.
For the purposes of this assignment, you will support generic board configurations with:
- up to 200 spaces,
- up 10 different characters
- up to 20 players.
Your program should begin by prompting the user for an input file which contains the game configuration. This file is in the following format:
- An integer (n) representing the total number of spaces on the board, including Start and the Candy Castle.
- An integer (c) indicating the number of characters
- c sets of character information consisting of:
- An integer (ci), 0 < ci < n, the location of the character.
- The character name, a string terminated by a new line.
- An integer (p) indicating the number of penalty spaces
- p sets of penalty information consisting of:
- An integer (pi), 0 < pi < n, the location of the penalty.
- The penalty name, a string terminated by a new line.
- An integer (s), the number of shortcuts.
- s sets of shortcut information consisting of:
- An integer si, 0 < si < n, the location of the entrance to the shortcut.
- An integer ti, 0 < ti < n, the location of the exit from the shortcut.
- The shortcut name, a string terminated by a new line.
- An integer k, the number of players in the game.
- k sets of player information consisting of:
- An integer ai, the age of player i.
- The player name, a string terminated by a new line.
- A character V or S that the program is to run is verbose (V) or silent (S) mode.
- An integer, trials, indicating the number of games to play.
No square will appear twice in the above list. For the traditional game, the configuration file would be:
136
6
9 Plumpy
18 Mr. Mint
43 Jolly
75 Grandma Nut
96 Princess Lolly
104 Queen Frostine
3
48 Gooey Gumdrops
86 Lost in Lollipop Woods
121 Molasses Swamp
2
5 59 Rainbow Trail
34 47 Gumdrop Pass
4
10 Bob
3 Brett
14 Steve
21 Pat
V
100
For this configuration, you should play a four player game 100 times, in verbose mode. A game in verbose mode will print sufficient information to allow the user to verify that the game is being played correctly. This should include details about a player's turn, including card drawn, start and end position. For silent mode, the results of each game should be printed. Examples of each are below:
Verbose Mode:
Round 1:
Brett draws a green card.
Brett moves from space 0 to space 6.
Turn over
Bob draws an orange card.
Bob moves from space 0 to space 5
Space 5 is the Rainbow Trail, a shortcut.
Bob moves from space 5 to space 59
Turn over
Steve draws Mr. Mint
Steve moves from space 0 to space 18
Turn over
Pat draws a red card.
Pat moves from space 0 to space 1
Turn over
End of round one. The player order is:
Bob space 59
Steve 18
Brett 6
Pat 1
Round 2:
Silent Mode
Game 1 Bob wins in 32 turns
Game 2 Pat wins in 145 turns
In any case, you should print statistics which include
- Number of games played
- The longest game
- The shortest game
- The average number of turns per game.
Required Files
You should submit the following in a tar file:
- All source code required to build all programs.
- A makefile which will build all programs as well as clean the directory
- A README describing
- Author identification information
- The project
- Problems encountered
- Any portions of the code which are not working.
- Any unique features of the code.
- Any other information you wish to share.
You should not submit
- Object files or executable.
- Core files.
- Source code files which are not related to the project.
Submission
Please create a tar file containing the files described above. Email this file to danbennett360@gmail.com by class time of the due date.