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

Function getScore

src/gamesbyexample/twentyfortyeight.py:109–118  ·  view source on GitHub ↗

Returns the sum of all the tiles on the board data structure.

(board)

Source from the content-addressed store, hash-verified

107
108
109def getScore(board):
110 """Returns the sum of all the tiles on the board data structure."""
111 score = 0
112 # Loop over every space and add the tile to the score:
113 for x in range(4):
114 for y in range(4):
115 # Only add non-blank tiles to the score:
116 if board[(x, y)] != BLANK:
117 score = score + board[(x, y)]
118 return score
119
120
121def combineTilesInColumn(column):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected