Question
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.
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 XIStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started