-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmctsPlayerNN.py
More file actions
41 lines (31 loc) · 1.05 KB
/
mctsPlayerNN.py
File metadata and controls
41 lines (31 loc) · 1.05 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
# -*- coding: utf-8 -*-
import Goban
from playerInterface import *
from mctsNN import MCTS_TREE
class myPlayer(PlayerInterface):
def __init__(self):
self._board = Goban.Board()
self._mycolor = None
self.tree = MCTS_TREE(self._board)
def getPlayerName(self):
return "MCTS Player"
def getPlayerMove(self):
if self._board.is_game_over():
print("Referee told me to play but the game is over!")
return "PASS"
move = self.tree.apply_mcts(self._board, 50, self._mycolor)
self.tree.relocate_root(move)
self._board.push(move)
return Goban.Board.flat_to_name(move)
def playOpponentMove(self, move):
move = Goban.Board.name_to_flat(move)
self._board.push(move)
self.tree.relocate_root(move)
def newGame(self, color):
self._mycolor = color
self._opponent = Goban.Board.flip(color)
def endGame(self, winner):
if self._mycolor == winner:
print("I won!!!")
else:
print("I lost :(!!")