-
Notifications
You must be signed in to change notification settings - Fork 5
/
game.py
45 lines (39 loc) · 1.35 KB
/
game.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
from state import State
width = 15
height = 15
board_size = width * height
class Game:
def __init__(self):
self.state = State()
self.legal_actions = []
self.illegal = []
self.history = []
self.end = None
self.legal_actions, self.illegal, self.end = self.state.referee()
self.game_count = 0
self.game_length = 0
self.w1, self.w2, self.w3 = 0, 0, 0
self.last = None
def next(self, action):
if action in self.legal_actions:
self.last = action
self.state = self.state.next(action)
self.legal_actions, self.illegal, self.end = self.state.referee()
self.history.append(action)
self.game_length += 1
# 패배 혹은 무승부
if self.end >= 1:
count = self.game_count + 1
length = self.game_length
if self.end == 1:
if self.state.check_turn():
winner = '백'
self.w2 += 1
else:
winner = '흑'
self.w1 += 1
print(str(length) + '수', winner, '승')
else:
self.w3 += 1
print(str(length) + '수', '무승부')
#self.__init__()