Problem Solving and Programming in C++

word image 3

Project Description:

Note: Video with Description and Demo is available on Blackboard

Chickapig is a two-player board game played on a 2D board, where each player has to maneuver his pieces across a fence on the opposite side. To do so, a die is rolled to determine how many moves will be played in that turn. Once a player has moved all of his pieces across the opposite fence, the player wins. You will be implementing a variant of this game.

Pieces

There are two types of pieces, chickapigs and haybales. Chickapigs can move perpendicularly and horizontally until an obstacle stops their movement. The player’s own pieces, the pieces of the opponent, and the board boundaries all count as obstacles.

Haybales can also move perpendicularly and horizontally, but they can do so only one square at a time, while the chickapigs will move across all empty squares until meeting an obstacle. Thus, chickapigs move akin to rooks in chess, and haybales move akin to kings, with the exception that there is no piece capturing in this game. The movement capabilities of both types of pieces are illustrated in Figure 1.

A piece movement, regardless of how many squares were traversed, counts as a single move. The number of moves a player can perform in a turn is indicated by a six-sided die. Within the turn, the player can move a piece numerous times, or can move several pieces, as long as the total number of moves matches the value of the die roll.

word image 4

Figure 1

Scoring

word image 5

To score, a player must move his chickapigs at either of the two central squares in front of the poles. There are many ways to score; Figure 2 illustrates two such ways if a roll of at least “four” has been rolled. The first way (white arrow) the player can simply move his piece between the two poles with a single move. Alternatively (blue arrows) the player can utilize his haybales as obstacles in order to score with his other chickapig. First the haybale is moved, then the chickapigs can score with four moves as indicated in the figure.

Figure 2

Initial Board Setup

Each player has six chickapigs and four haybales arranged as illustrated in Figure 3. ‘O’ and ‘X’ are the chickapigs of player 1 and player 2 respectively. Similarly, ‘@’ and ‘#’ are the haybales of player 1 and player 2 respectively. Note that the { } is the position of the cursor. It will be used to specify which piece to play, instead of relying on inserting the row and column number of the piece, which is much slower and severely hinders the ease of playing.

word image 7

Figure 3

Using the console to Play

Each Player will be moving the cursor across the board in order to reach the piece that is to be moved. The cursor must move with the following keys.

  1. a = left
  2. d = right
  3. s = down
  4. w = up

Once the cursor has reached the desired piece, the player can insert ‘q’ to indicate that this piece must move. The program will then prompt for the direction in which to move. The player will then insert either (a, d, s, or w) to indicate the direction.

Implementation Details

You must implement three ADTs, one for a player, one for the board, and one for the referee.

In the player ADT, add an integer member variable to record the player’s score.

You must overload the following operators:

void operator++(); // This operator overloading adds 1 to the score of the player

bool operator<(int n) ; // This operator overloading returns true if the player’s score is less than n

You should use these 2 operators in the referee or board ADTs.

At each turn the program should show the die roll and the player’s whose turn it is to play. The pieces that can potentially be moved must be displayed. You are free to display such information in any manner you think is best, but a suggestion is provided through Figure 4.

word image 8 In case of incorrect command (choosing another player’s piece or a piece that cannot move in the indicated direction), the program should keep prompting the user until a valid one is entered. When a player wins, the game should stop and a message indicating which player is victorious must be printed to the screen.

Figure 4

Grading:

  • Compilation 15
  • Correct Output
    • Correct piece movement 10
    • Correct scoring 10
    • Correct game termination 5
    • Correct turn taking 5
  • Appropriate ADTs
    • Three ADTs 15
    • Use of private data members, accessor and mutators 15
    • ADT Cohesion 10
    • Operator overloading 5
  • Style: Comments, Indentation, Simplicity of Main 10

Total 100

Tip: When designing the structure of your ADTs, it is useful to think in terms of designing a player’s A.I., in order to see how the ADTs should interact. Your Referee should act as an interface between player and board, and not allow the player to cheat (player setting his own score, making illegal moves, etc.)

You can think in the same manner when trying to decide which functions in an ADT should be private and which public. If you were to write a player’s A.I., what kind of functions from another ADT (i.e. Referee) may be useful? These functions will probably need to be public.

Problem Solving and Programming in C++

word image 3

Project Description:

Note: Video with Description and Demo is available on Blackboard

Chickapig is a two-player board game played on a 2D board, where each player has to maneuver his pieces across a fence on the opposite side. To do so, a die is rolled to determine how many moves will be played in that turn. Once a player has moved all of his pieces across the opposite fence, the player wins. You will be implementing a variant of this game.

Pieces

There are two types of pieces, chickapigs and haybales. Chickapigs can move perpendicularly and horizontally until an obstacle stops their movement. The player’s own pieces, the pieces of the opponent, and the board boundaries all count as obstacles.

Haybales can also move perpendicularly and horizontally, but they can do so only one square at a time, while the chickapigs will move across all empty squares until meeting an obstacle. Thus, chickapigs move akin to rooks in chess, and haybales move akin to kings, with the exception that there is no piece capturing in this game. The movement capabilities of both types of pieces are illustrated in Figure 1.

A piece movement, regardless of how many squares were traversed, counts as a single move. The number of moves a player can perform in a turn is indicated by a six-sided die. Within the turn, the player can move a piece numerous times, or can move several pieces, as long as the total number of moves matches the value of the die roll.

word image 4

Figure 1

Scoring

word image 5

To score, a player must move his chickapigs at either of the two central squares in front of the poles. There are many ways to score; Figure 2 illustrates two such ways if a roll of at least “four” has been rolled. The first way (white arrow) the player can simply move his piece between the two poles with a single move. Alternatively (blue arrows) the player can utilize his haybales as obstacles in order to score with his other chickapig. First the haybale is moved, then the chickapigs can score with four moves as indicated in the figure.

Figure 2

Initial Board Setup

Each player has six chickapigs and four haybales arranged as illustrated in Figure 3. ‘O’ and ‘X’ are the chickapigs of player 1 and player 2 respectively. Similarly, ‘@’ and ‘#’ are the haybales of player 1 and player 2 respectively. Note that the { } is the position of the cursor. It will be used to specify which piece to play, instead of relying on inserting the row and column number of the piece, which is much slower and severely hinders the ease of playing.

word image 7

Figure 3

Using the console to Play – Problem Solving and Programming in C++

Each Player will be moving the cursor across the board in order to reach the piece that is to be moved. The cursor must move with the following keys.

  1. a = left
  2. d = right
  3. s = down
  4. w = up

Once the cursor has reached the desired piece, the player can insert ‘q’ to indicate that this piece must move. The program will then prompt for the direction in which to move. The player will then insert either (a, d, s, or w) to indicate the direction.

Implementation Details

You must implement three ADTs, one for a player, one for the board, and one for the referee.

In the player ADT, add an integer member variable to record the player’s score.

You must overload the following operators:

void operator++(); // This operator overloading adds 1 to the score of the player

bool operator<(int n) ; // This operator overloading returns true if the player’s score is less than n

You should use these 2 operators in the referee or board ADTs.

At each turn the program should show the die roll and the player’s whose turn it is to play. The pieces that can potentially be moved must be displayed. You are free to display such information in any manner you think is best, but a suggestion is provided through Figure 4.

word image 8 In case of incorrect command (choosing another player’s piece or a piece that cannot move in the indicated direction), the program should keep prompting the user until a valid one is entered. When a player wins, the game should stop and a message indicating which player is victorious must be printed to the screen.

Figure 4

Grading:

  • Compilation 15
  • Correct Output
    • Correct piece movement 10
    • Correct scoring 10
    • Correct game termination 5
    • Correct turn taking 5
  • Appropriate ADTs
    • Three ADTs 15
    • Use of private data members, accessor and mutators 15
    • ADT Cohesion 10
    • Operator overloading 5
  • Style: Comments, Indentation, Simplicity of Main 10

Total 100

Tip: When designing the structure of your ADTs, it is useful to think in terms of designing a player’s A.I., in order to see how the ADTs should interact. Your Referee should act as an interface between player and board, and not allow the player to cheat (player setting his own score, making illegal moves, etc.)

You can think in the same manner when trying to decide which functions in an ADT should be private and which public. If you were to write a player’s A.I., what kind of functions from another ADT (i.e. Referee) may be useful? These functions will probably need to be public.

Problem Solving and Programming in C++

Problem Solving and Programming in C++

Project Description: Problem Solving and Programming in C++

Note: Video with Description and Demo is available on Blackboard

Chickapig is a two-player board game played on a 2D board, where each player has to maneuver his pieces across a fence on the opposite side. To do so, a die is rolled to determine how many moves will be played in that turn. Once a player has moved all of his pieces across the opposite fence, the player wins. You will be implementing a variant of this game.

Pieces

There are two types of pieces, chickapigs and haybales. Chickapigs can move perpendicularly and horizontally until an obstacle stops their movement. The player’s own pieces, the pieces of the opponent, and the board boundaries all count as obstacles.

Haybales can also move perpendicularly and horizontally, but they can do so only one square at a time, while the chickapigs will move across all empty squares until meeting an obstacle. Thus, chickapigs move akin to rooks in chess, and haybales move akin to kings, with the exception that there is no piece capturing in this game. The movement capabilities of both types of pieces are illustrated in Figure 1.

A piece movement, regardless of how many squares were traversed, counts as a single move. The number of moves a player can perform in a turn is indicated by a six-sided die. Within the turn, the player can move a piece numerous times, or can move several pieces, as long as the total number of moves matches the value of the die roll.

word image 4

Figure 1

Scoring

word image 5

To score, a player must move his chickapigs at either of the two central squares in front of the poles. There are many ways to score; Figure 2 illustrates two such ways if a roll of at least “four” has been rolled. The first way (white arrow) the player can simply move his piece between the two poles with a single move. Alternatively (blue arrows) the player can utilize his haybales as obstacles in order to score with his other chickapig. First the haybale is moved, then the chickapigs can score with four moves as indicated in the figure.

Figure 2

Initial Board Setup – Problem Solving and Programming in C++

Each player has six chickapigs and four haybales arranged as illustrated in Figure 3. ‘O’ and ‘X’ are the chickapigs of player 1 and player 2 respectively. Similarly, ‘@’ and ‘#’ are the haybales of player 1 and player 2 respectively. Note that the { } is the position of the cursor. It will be used to specify which piece to play, instead of relying on inserting the row and column number of the piece, which is much slower and severely hinders the ease of playing.

word image 7

Figure 3

Using the console to Play – Problem Solving and Programming in C++

Each Player will be moving the cursor across the board in order to reach the piece that is to be moved. The cursor must move with the following keys.

  1. a = left
  2. d = right
  3. s = down
  4. w = up

Once the cursor has reached the desired piece, the player can insert ‘q’ to indicate that this piece must move. The program will then prompt for the direction in which to move. The player will then insert either (a, d, s, or w) to indicate the direction.

Implementation Details – Problem Solving and Programming in C++

You must implement three ADTs, one for a player, one for the board, and one for the referee.

In the player ADT, add an integer member variable to record the player’s score.

You must overload the following operators:

void operator++(); // This operator overloading adds 1 to the score of the player

bool operator<(int n) ; // This operator overloading returns true if the player’s score is less than n

You should use these 2 operators in the referee or board ADTs.

At each turn the program should show the die roll and the player’s whose turn it is to play. The pieces that can potentially be moved must be displayed. You are free to display such information in any manner you think is best, but a suggestion is provided through Figure 4.

word image 8

In case of incorrect command (choosing another player’s piece or a piece that cannot move in the indicated direction), the program should keep prompting the user until a valid one is entered. When a player wins, the game should stop and a message indicating which player is victorious must be printed to the screen.

Figure 4

Grading – Problem Solving and Programming in C++:

  • Compilation 15
  • Correct Output
    • Correct piece movement 10
    • Correct scoring 10
    • Correct game termination 5
    • Correct turn taking 5
  • Appropriate ADTs
    • Three ADTs 15
    • Use of private data members, accessor and mutators 15
    • ADT Cohesion 10
    • Operator overloading 5
  • Style: Comments, Indentation, Simplicity of Main 10

Total 100

Tip: When designing the structure of your ADTs, it is useful to think in terms of designing a player’s A.I., in order to see how the ADTs should interact. Your Referee should act as an interface between player and board, and not allow the player to cheat (player setting his own score, making illegal moves, etc.)

You can think in the same manner when trying to decide which functions in an ADT should be private and which public. If you were to write a player’s A.I., what kind of functions from another ADT (i.e. Referee) may be useful? These functions will probably need to be public.

Subscribe For Latest Updates
Let us notify you each time there is a new assignment, book recommendation, assignment resource, or free essay and updates