-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.py
More file actions
77 lines (63 loc) · 1.98 KB
/
interface.py
File metadata and controls
77 lines (63 loc) · 1.98 KB
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
from copy import deepcopy
class Status(object):
def get_current_player_idx(self):
raise NotImplementedError
def get_available_actions(self):
raise NotImplementedError
def get_round(self):
raise NotImplementedError
def perform(self, action):
raise NotImplementedError
def is_terminal(self) -> bool:
raise NotImplementedError
def get_result_score(self):
raise NotImplementedError
def to_number(self):
raise NotImplementedError
def copy(self):
return deepcopy(self)
class Player(object):
def get_action(self, status):
raise NotImplementedError
class Game(object):
def get_player_num(self):
# 最好支持多玩家,比如斗地主
raise NotImplementedError
def set_player(self, idx, player):
raise NotImplementedError
def start(self):
raise NotImplementedError
# def add_callback(self, callback):
# if hasattr(self, 'callbacks'):
# self.callbacks.append(callback)
# else:
# self.callbacks = [callback]
#
# def on_game_begin(self):
# for callback in self.callbacks:
# callback.on_game_begin(self.status)
#
# def on_game_end(self):
# for callback in self.callbacks:
# callback.on_game_end(self.status)
#
# def on_round_begin(self):
# self._current_player_idx = self.status.get_current_player_idx()
# for callback in self.callbacks:
# callback.on_round_begin(self._current_player_idx, self.status)
#
# def on_round_end(self):
# for callback in self.callbacks:
# callback.on_round_begin(self._current_player_idx, self.status)
# class GameCallback(object):
# def on_game_begin(self, status):
# pass
#
# def on_game_end(self, status):
# pass
#
# def on_round_begin(self, player_idx, status):
# pass
#
# def on_round_end(self, player_idx, status):
# pass