MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / process_game

Function process_game

matrix/matrix_based_game.py:243–265  ·  view source on GitHub ↗

Processes the game logic for the given matrix and moves. Args: size (int): Size of the game board. matrix (List[str]): Initial game matrix. moves (List[Tuple[int, int]]): List of moves as (x, y) coordinates. Returns: int: The total score obtained. >>> pr

(size: int, matrix: list[str], moves: list[tuple[int, int]])

Source from the content-addressed store, hash-verified

241
242
243def process_game(size: int, matrix: list[str], moves: list[tuple[int, int]]) -> int:
244 """Processes the game logic for the given matrix and moves.
245
246 Args:
247 size (int): Size of the game board.
248 matrix (List[str]): Initial game matrix.
249 moves (List[Tuple[int, int]]): List of moves as (x, y) coordinates.
250
251 Returns:
252 int: The total score obtained.
253 >>> process_game(3, ['aaa', 'bbb', 'ccc'], [(0, 0)])
254 6
255 """
256
257 game_matrix = [list(row) for row in matrix]
258 total_score = 0
259
260 for move in moves:
261 pos_x, pos_y = move
262 game_matrix, score = play(game_matrix, pos_x, pos_y, size)
263 total_score += score
264
265 return total_score
266
267
268if __name__ == "__main__":

Callers 1

Calls 1

playFunction · 0.85

Tested by

no test coverage detected