Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please refer to image attached for an example of the output screen. Create a C++ program for the game Peg Solitaire. Peg Solitaire is played

Please refer to image attached for an example of the output screen.

image text in transcribed

Create a C++ program for the game Peg Solitaire.

Peg Solitaire 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.

Requirements:

Provide the option for a single-player game or two players to play against each other.

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:

1. Jump into a location that is occupied.

2. Jump into any invalid location (i.e.: off the board).

3. Jumps that are not straight lines.

4. Move without jumping an adjacent peg.

Print to output screen an updated ASCII board after each move.

Provide a means to allow the user to specify which peg they want to move and which space they want to move into.

The board size is five rows by five columns (5x5).

To begin the game there must be one empty peg hole in the middle of the 5x5 board.

Your Game Board does not necessarily have to use graphics for a display. Ideas for an ASCII Game Board (Using Courier New font in his example): Game Board (5x5 square): Move: Updated Game Board: A BC DE From: C1 A B C D E C3 To 1 IX IX I IX IX XIXIXIXIX 2 IXIXIXIXIXI 2 IXIX, I XIX 3 IXIX 3 IX XIX XIX XIX 4 IX, XIX XIX 4 XIXIXIXIXI 5 IXIXIXIXIXI 5 XIX XIX XI Your Game Board does not necessarily have to use graphics for a display. Ideas for an ASCII Game Board (Using Courier New font in his example): Game Board (5x5 square): Move: Updated Game Board: A BC DE From: C1 A B C D E C3 To 1 IX IX I IX IX XIXIXIXIX 2 IXIXIXIXIXI 2 IXIX, I XIX 3 IXIX 3 IX XIX XIX XIX 4 IX, XIX XIX 4 XIXIXIXIXI 5 IXIXIXIXIXI 5 XIX XIX XI

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Bioinformatics Databases And Systems

Authors: Stanley I. Letovsky

1st Edition

1475784058, 978-1475784053

More Books

Students also viewed these Databases questions

Question

Explain the meaning of the changing nature of HR practices.

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago

Question

Have roles been defined and assigned?

Answered: 1 week ago