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

Function getScoreOfBoard

src/gamesbyexample/reversegam.py:170–181  ·  view source on GitHub ↗

Returns a dictionary with keys 'X' and 'O', whose values.

(board)

Source from the content-addressed store, hash-verified

168
169
170def getScoreOfBoard(board):
171 """Returns a dictionary with keys 'X' and 'O', whose values."""
172 scores = {'X': 0, 'O': 0} # The scores start at 0.
173 # Loop over each space on the board:
174 for x in range(8):
175 for y in range(8):
176 # Increment the score if there is an X or O on this space:
177 if board[(x, y)] == 'X':
178 scores['X'] += 1
179 if board[(x, y)] == 'O':
180 scores['O'] += 1
181 return scores
182
183
184def askForPlayerMove(board):

Callers 2

displayBoardFunction · 0.70
getComputerMoveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected