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

Function addTwoToBoard

src/gamesbyexample/twentyfortyeight.py:224–230  ·  view source on GitHub ↗

Adds a new 2 tile randomly to the board.

(board)

Source from the content-addressed store, hash-verified

222
223
224def addTwoToBoard(board):
225 """Adds a new 2 tile randomly to the board."""
226 while True:
227 randomSpace = (random.randint(0, 3), random.randint(0, 3))
228 if board[randomSpace] == BLANK:
229 board[randomSpace] = 2
230 return # Return after finding one non-blank tile.
231
232
233def isFull(board):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected