forked from NicoGol/pontu_game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
state.py
81 lines (67 loc) · 1.56 KB
/
state.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
State history
"""
class State():
def __init__(self):
self.cur_player = 0
self.winner = None
self.timeout_player = None
self.invalid_player = None
def set_timed_out(self, player):
self.timeout_player = player
self.winner = 1 - player
def set_invalid_action(self, player):
self.invalid_player = player
self.winner = 1 - player
"""
Return a deep copy of this state.
"""
def copy(self):
pass
"""
Return true if and only if the game is over.
"""
def game_over(self):
if self.winner != None:
return True
self.game_over_check()
def game_over_check(self):
pass
"""
Return the index of the current player.
"""
def get_cur_player(self):
return self.cur_player
"""
Checks if a given action is valid.
"""
def is_action_valid(self, action):
actions = self.get_current_player_actions()
return action in actions
"""
Get all the actions that the current player can perform.
"""
def get_current_player_actions(self):
pass
"""
Applies a given action to this state. It assume that the actions is
valid. This must be checked with is_action_valid.
"""
def apply_action(self, action):
pass
"""
Return the scores of each players.
"""
def get_scores(self):
pass
"""
Get the winner of the game. Call only if the game is over.
"""
def get_winner(self):
return self.winner
"""
Return the information about the state that is given to students.
Usually they have to implement their own state class.
"""
def get_state_data(self):
pass