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

Function getRandomEmptySpace

src/gamesbyexample/hungryrobots.py:95–102  ·  view source on GitHub ↗

Return a (x, y) integer tuple of an empty space on the board.

(board, robots)

Source from the content-addressed store, hash-verified

93
94
95def getRandomEmptySpace(board, robots):
96 """Return a (x, y) integer tuple of an empty space on the board."""
97 while True:
98 randomX = random.randint(1, WIDTH - 2)
99 randomY = random.randint(1, HEIGHT - 2)
100 if isEmpty(randomX, randomY, board, robots):
101 break
102 return (randomX, randomY)
103
104
105def isEmpty(x, y, board, robots):

Callers 4

mainFunction · 0.85
getNewBoardFunction · 0.85
addRobotsFunction · 0.85
askForPlayerMoveFunction · 0.85

Calls 1

isEmptyFunction · 0.85

Tested by

no test coverage detected