Question: Develop a C++ program for the game Pegz. (KEEP IT SIMPLE) Pegz is played on a game board. The spaces on the game board are

Develop a C++ program for the game Pegz. (KEEP IT SIMPLE)

Pegz is played on a game board. The spaces on the game board are either occupied by a marker (a peg) or are empty. A peg can capture an adjacent peg by jumping over it into an empty space. The peg that was jumped over (captured) is removed from the game board, leaving an empty space. Pegs can only move by jumping another peg. Jumps must be straight lines, and may be in any direction (up, down, left, right for box shaped boards, and diagonally for triangular shaped boards.) Pegs may not jump out of the board space. In a two-player game, the players take turns jumping and capturing the pegs that remain on the board. A players turn consists of capturing as many pegs as possible with the same peg. If more than one peg can be jumped with the same peg (i.e.: multiple jumps), then the player may continue to jump (in any direction) and capture pegs until there are no more possible jumps for that peg. It then becomes the next players turn. The game is over when there are no more possible jumps for any remaining pegs on the board.

For a single-player game, the players score is the number of REMAINING pegs; a perfect score is 1 (one remaining peg).

For a two-player game, each players score is the total number of pegs that they captured (i.e.: jumped over and removed from the board.)

The program must do the following:

- Provide the option for a single-player game or two players to play against each other. (The program does NOT have to be capable of playing the game itself i.e.: a human vs. computer match.)

- For single-player game, detect the end of the game and report the score.

- For two-player game, detect the end of the game, report the score for each player, and report which player won.

- NOT allow invalid moves: o Jump into a location that is occupied, o Jump into any invalid location (i.e.: off the board), o Jumps that are not straight lines, o Move without jumping an adjacent peg,

User Interface:

- Provide an updated graphic of the game board after each move.

- The program must keep track of whose turn it is, prompt the player(s) as to whose turn it is, and keep track of how many pegs each player has captured.

- The graphical display of the board may be just ASCII text, and the up-dated board display may just "scroll" down the screen (i.e.: you do not have to clear the screen before printing the updated game board.) o Provide a means to allow the user to specify which peg they want to move and which space they want to move into. This must support (valid) multiple jumps.

The Board:

- Make board is five rows by five columns (5x5).

- The board is initialized to fill ALL spaces with pegs.

- To begin the game there must be one empty space. The first empty space on the board may either be a fixed default location, a random location, or the program may allow the player(s) to select the first empty space. o In a two player game, removing the first peg does NOT count toward either players score.

Please make in C++ and keep it as simple as possible. This is not to be a solver for the whole game, but a game to be played by user(s).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!