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

Function getScore

src/gamesbyexample/pegsolitaire.py:175–181  ·  view source on GitHub ↗

Returns the number of captured pegs.

(board)

Source from the content-addressed store, hash-verified

173
174
175def getScore(board):
176 """Returns the number of captured pegs."""
177 pegCount = 0
178 for space in ALL_SPACES:
179 if board[space] == PEG:
180 pegCount += 1
181 return 32 - pegCount
182
183
184def checkIfPlayerHasWon(board):

Callers 2

askForPlayerMoveFunction · 0.70
checkIfPlayerHasWonFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected