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

Function addRobots

src/gamesbyexample/hungryrobots.py:111–118  ·  view source on GitHub ↗

Add NUM_ROBOTS number of robots to empty spaces on the board and return a list of these (x, y) spaces where robots are now located.

(board)

Source from the content-addressed store, hash-verified

109
110
111def addRobots(board):
112 """Add NUM_ROBOTS number of robots to empty spaces on the board and
113 return a list of these (x, y) spaces where robots are now located."""
114 robots = []
115 for i in range(NUM_ROBOTS):
116 x, y = getRandomEmptySpace(board, robots)
117 robots.append((x, y))
118 return robots
119
120
121def displayBoard(board, robots, playerPosition):

Callers 1

mainFunction · 0.85

Calls 1

getRandomEmptySpaceFunction · 0.85

Tested by

no test coverage detected