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

Function makeMove

src/gamesbyexample/reversegam.py:208–219  ·  view source on GitHub ↗

Place a tile on the board, flipping any of the opponent's pieces. Returns False for invalid moves, True for valid.

(board, tile, xstart, ystart)

Source from the content-addressed store, hash-verified

206
207
208def makeMove(board, tile, xstart, ystart):
209 """Place a tile on the board, flipping any of the opponent's pieces.
210 Returns False for invalid moves, True for valid."""
211 tilesToFlip = isValidMove(board, tile, xstart, ystart)
212
213 if tilesToFlip == False:
214 return False
215
216 board[(xstart, ystart)] = tile
217 for x, y in tilesToFlip:
218 board[(x, y)] = tile
219 return True
220
221
222def getComputerMove(board):

Callers 2

mainFunction · 0.70
getComputerMoveFunction · 0.70

Calls 1

isValidMoveFunction · 0.70

Tested by

no test coverage detected