MCPcopy Create free account
hub / github.com/geekcomputers/Python / evaluate

Function evaluate

Tic-Tac-Toe Games/tic-tac-toe4.py:68–82  ·  view source on GitHub ↗

Evaluate the board. Returns: 0 if no winner yet, 1 or 2 for the winner, -1 if tie.

(board: np.ndarray)

Source from the content-addressed store, hash-verified

66
67
68def evaluate(board: np.ndarray) -> int:
69 """
70 Evaluate the board.
71
72 Returns:
73 0 if no winner yet,
74 1 or 2 for the winner,
75 -1 if tie.
76 """
77 for player in [1, 2]:
78 if row_win(board, player) or col_win(board, player) or diag_win(board, player):
79 return player
80 if np.all(board != 0):
81 return -1
82 return 0
83
84
85def play_game() -> int:

Callers 1

play_gameFunction · 0.85

Calls 3

row_winFunction · 0.85
col_winFunction · 0.85
diag_winFunction · 0.85

Tested by

no test coverage detected