in python code please without graphics 9-8, 81%. 12:50 PM Solitaire Pog Gam Ovcr
ID: 3700950 • Letter: I
Question
in python code please without graphics
9-8, 81%. 12:50 PM Solitaire Pog Gam Ovcrvicw:In this program, you will implement a vcrsion of the game of Pog Solitaire. I is played on a rectaugular grid of holes. Some of the holes will have pegs in them and some will not. On a turn, the player can jump a pg A over another pog B in a horizoutal or vertical fashion) f there is a space just after B aud this space is unoccupied. Pog B is then removed from the board (but peg A stays). The user docs this till she has no moves, tlhe goal beig to have as few pegs left as possible (lhaving just onc lft is the best possible nder some contigurations) Rcquircments: You must 1) create a class named PogSolitaire, which wll bo described below, 2) create other classes as ueeded, which will all be kuown by the top levcl class PogSolitaire, 3) write a simple console application (no graphics!) that uscs the class PcgSolitaire, with a fow simple method calls, to ccatc an interactive gamc of Peg Slitaire In the following discussion, by a position we mcan a tuple (X, Y), where X and Y arc positive integers, a position is meant to refer to a location on the board. The class PegSolitaire, ?ust have ul least lhe followiug ??1hods (it inay have ??re ??1hods) (a) The initialzr takes two positive intoger arguments X and Y. This creates a X by (b) placePeg: Takes integer arguunents X and Y, aud places a peg at row X aud (c) removePeg: Takes intoger arguments X and Y, and removes a pog at row X and Y grid of holes as the playing board. column Y colu Y (d) jumpPeg: Takes two positions aud attempts to ove the peg a the first position to the location indicated by the sccond poston. If the movc is lcga, it is carried out, along witlh all appropriale adjustinents to the board, and True is returned. If therc is anything that forbids this move, the the method docs not changc the board, ad returus False (e) isStuck: Takes no iputs, aud returns True if there are no possible s left and Falsc if therc a pssiblo movcs. (f) display: This creatos a text output of the curront state of the board. It shoulod just be a grid of letters with the character "P for hole occupied by a peg, and n example of a possible result of display a pog. A for a hole not occupi ou a 2 by 3 board XPP PXPExplanation / Answer
class PegSolitaire: def __init__(self, X, Y): self.X = X self.Y = Y self.board=[["X"] * X]*Y def placePeg(self, x, y): self.board[x][y]="P" def removePeg(self): self.board[x][y] = "X" def jumpPeg(self,P1,P2): if(self.board[P2(0)][P2(1)]!="P" & self.board[P1(0)][P1(1)]=="P" & P1(0)Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.