-
Notifications
You must be signed in to change notification settings - Fork 0
/
tictactoe.py
67 lines (49 loc) · 1.15 KB
/
tictactoe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
Tic Tac Toe Player
"""
import math
X = "X"
O = "O"
EMPTY = None
def initial_state():
"""
Returns starting state of the board.
"""
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]]
def player(board):
"""
Returns player who has the next turn on a board.
"""
raise NotImplementedError
def actions(board):
"""
Returns set of all possible actions (i, j) available on the board.
"""
raise NotImplementedError
def result(board, action):
"""
Returns the board that results from making move (i, j) on the board.
"""
raise NotImplementedError
def winner(board):
"""
Returns the winner of the game, if there is one.
"""
raise NotImplementedError
def terminal(board):
"""
Returns True if game is over, False otherwise.
"""
raise NotImplementedError
def utility(board):
"""
Returns 1 if X has won the game, -1 if O has won, 0 otherwise.
"""
raise NotImplementedError
def minimax(board):
"""
Returns the optimal action for the current player on the board.
"""
raise NotImplementedError