MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / main

Function main

src/gamesbyexample/pegsolitaire.py:19–33  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18
19def main():
20 print('''Peg Solitaire, by Al Sweigart al@inventwithpython.com
21Jump a peg over another and into the empty space. Jumped pegs get
22removed from the board. Try to remove as many pegs as you can.''')
23
24 theBoard = getNewBoard()
25
26 while True:
27 displayBoard(theBoard)
28 space, jumpDirection = askForPlayerMove(theBoard)
29 makeMove(theBoard, space, jumpDirection)
30 if checkIfPlayerHasWon(theBoard):
31 displayBoard(theBoard)
32 print('You have solved the puzzle! Thanks for playing!')
33 sys.exit()
34
35
36def getNewBoard():

Callers 1

pegsolitaire.pyFile · 0.70

Calls 5

checkIfPlayerHasWonFunction · 0.85
getNewBoardFunction · 0.70
displayBoardFunction · 0.70
askForPlayerMoveFunction · 0.70
makeMoveFunction · 0.70

Tested by

no test coverage detected