-
Notifications
You must be signed in to change notification settings - Fork 0
/
human_v_bot.py
32 lines (27 loc) · 943 Bytes
/
human_v_bot.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
from dlgo import agent
from dlgo import goboard
from dlgo import gotypes
from dlgo.utils import print_board, print_move, point_from_coords
from six.moves import input
def main():
board_size = 9
game = goboard.GameState.new_game(board_size)
bot = agent.naive.RandomBot()
while not game.is_over():
print(chr(27) + "[2J")
print_board(game.board)
if game.next_player == gotypes.Player.black:
human_move = input('-- ')
if human_move == 'pass':
move = goboard.Move.pass_turn()
elif human_move == 'resign':
move = goboard.Move.resign()
else:
point = point_from_coords(human_move.strip())
move = goboard.Move.play(point)
else:
move = bot.select_move(game)
print_move(game.next_player, move)
game = game.apply_move(move)
if __name__ == '__main__':
main()