-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot_v_bot.py
41 lines (29 loc) · 925 Bytes
/
bot_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
33
34
35
36
37
38
39
from dlgo import agent
from dlgo import goboard
from dlgo import gotypes
from dlgo.ui import UI
import pygame
import time
def main():
board_size = 9
ui = UI()
game = goboard.GameState.new_game(board_size)
bots = {
gotypes.Player.black: agent.naive.RandomBot(),
gotypes.Player.white: agent.naive.RandomBot(),
}
ui.initialize(game, board_size)
while not game.is_over():
time.sleep(0.5)
ui.handle_events()
bot_move = bots[game.next_player].select_move(game)
color = game.next_player.color
game = game.apply_move(bot_move)
#print(f"last move: {game.last_move.point}")
if game.last_move.point is not None:
ui.draw(game.last_move.point,color)
if len(game.removed) > 0:
for point in game.removed:
ui.remove(point)
if __name__ == '__main__':
main()