-
Notifications
You must be signed in to change notification settings - Fork 0
/
ai_human_gui_demo.py
36 lines (32 loc) · 1.05 KB
/
ai_human_gui_demo.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
from goboard import GomokuGameHandler
from goboard.judge import Win, Lose
from goboard.player import Human
from goboard.logger import log
from ai.normal_ai import Ai as NormalAi
import time
black_player = NormalAi("black", board_size=(13, 13))
white_player = Human("white", board_size=(13, 13))
try:
with GomokuGameHandler(black_player, white_player, board_size=(13, 13)) as (black_round, white_round, board):
for _ in range(13 * 13 // 2):
black_round()
white_round()
except Win as e:
time.sleep(3)
log('[end game] %s' % e)
except Lose as e:
time.sleep(3)
log('[end game] %s' % e)
black_player = NormalAi("black", board_size=(13, 13))
white_player = Human("white", board_size=(13, 13))
try:
with GomokuGameHandler(black_player, white_player, board_size=(13, 13)) as (black_round, white_round, board):
for _ in range(13 * 13 // 2):
black_round()
white_round()
except Win as e:
time.sleep(3)
log('[end game] %s' % e)
except Lose as e:
time.sleep(3)
log('[end game] %s' % e)