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

Function check_winner

tic-tac-toe.py:14–23  ·  view source on GitHub ↗
(player)

Source from the content-addressed store, hash-verified

12 print()
13
14def check_winner(player):
15 win_conditions = [
16 [0,1,2], [3,4,5], [6,7,8], # rows
17 [0,3,6], [1,4,7], [2,5,8], # columns
18 [0,4,8], [2,4,6] # diagonals
19 ]
20 for condition in win_conditions:
21 if all(board[i] == player for i in condition):
22 return True
23 return False
24
25def is_draw():
26 return " " not in board

Callers 1

tic-tac-toe.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected