Question: PYTHON 3 3. Solitaire Peg Game Overview I this program, ywl implement a version of the game of Peg Solitaire. It is played on a

 PYTHON 3 3. Solitaire Peg Game Overview I this program, ywl

PYTHON 3 3. Solitaire Peg Game Overview I this program, ywl implement a version of the game of Peg Solitaire. It is played on a rectangular grid of holes. Some of the hoes wil have pegs in them and some will not. On a turn, the player can jump a peg A over another peg B (in a horizontal or vertical fashion), if there is a space just after B and this space is unoccupied. Peg B is then removed from the board (but peg A stays). The user does this till she has no moves, the goal being to have as few pegs left as possible (having just one left is the est possible under some configurations) Requirements: You mst 1) create a class named PegSolitaire, which will be described below, 2) create other classes as needed, which will all be kwn by the top level class PegSolitaire, 3) write a simple console application (no graphics!) that uses the class PegSolitaire, with a few simple method calls, to create an interactive game of Peg Solitaire In the following discussion, by a position we mean a tuple (X, Y), where X and Y are positive integers; a position is meant to refer to a location on the board. The clas PegSolitaire, must have at least the following methods it may have more methods) (a) The initializer takes two positive integer arguments Xad Y This creates a X by (b) placePeg: Takes integer arguments X and Y, and places a peg at row X and (c) renovePeg: Takes integer arguments X and Y, and removes a peg at row X and Y grid of holes as the playing board. colun Y column Y (d) junpPeg: Tales two positions and attempts to move the peg at the first position to the location indicated by the second position. If the move is legal, it is carried out, along with al appropriate adjustments to the board, and True is returned. If there is anything that forbids this move, the the method does not change the board, nd rets False. (e) isStuck: Takes no inputs, and returns True if there are no possible moves left, and False if there are possible moves. (f) display: This creates a text output of the current state of the board suld just be a grid of letters with the character "P for a hole occupied by a peg, and X for a hole not occupied by a peg. An example of a possible result of display on a 2 by 3 board: XPP PXP

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!