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

Function check_winner

Tic-Tac-Toe Games/tic-tac-toe3.py:21–32  ·  view source on GitHub ↗

Check if `player` has a winning line on `board`.

(board: Board, player: str)

Source from the content-addressed store, hash-verified

19
20
21def check_winner(board: Board, player: str) -> bool:
22 """Check if `player` has a winning line on `board`."""
23 for i in range(3):
24 if all(board[i][j] == player for j in range(3)) or all(
25 board[j][i] == player for j in range(3)
26 ):
27 return True
28 if all(board[i][i] == player for i in range(3)) or all(
29 board[i][2 - i] == player for i in range(3)
30 ):
31 return True
32 return False
33
34
35def is_board_full(board: Board) -> bool:

Callers 3

minimaxFunction · 0.70
make_moveFunction · 0.70
ai_moveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected