feat: add opeinign
This commit is contained in:
parent
18b927a213
commit
3b2fe7671d
@ -137,7 +137,7 @@ class myPlayer(PlayerInterface):
|
||||
plays = json.load(f)
|
||||
|
||||
l = "W" if self._mycolor == Goban.Board._WHITE else "B"
|
||||
filtered = filter(lambda t: l in t["result"], self.plays)
|
||||
filtered = filter(lambda t: l in t["result"], plays)
|
||||
|
||||
lp = l + "+"
|
||||
for el in filtered:
|
||||
@ -145,6 +145,7 @@ class myPlayer(PlayerInterface):
|
||||
self.plays.append(el)
|
||||
|
||||
self.plays.sort(key=lambda t: t["result"])
|
||||
self.turn = 0
|
||||
|
||||
def getPlayerName(self):
|
||||
return "xXx_7h3_5cRuM_M45T3r_xXx"
|
||||
@ -185,6 +186,8 @@ class myPlayer(PlayerInterface):
|
||||
duration = 64 - (self._board._nbBLACK + self._board._nbWHITE)
|
||||
|
||||
duration = min(duration, (self.maxtime - self.time) / 10)
|
||||
move = -1
|
||||
score = 0
|
||||
|
||||
# move = alphabeta(self._board, self.nnheuristic, self._mycolor, 1)
|
||||
if self.last_op_move == "PASS" and self._board.diff_stones_board() * (1 if self._mycolor == Goban.Board._BLACK else -1) > 0:
|
||||
@ -192,9 +195,13 @@ class myPlayer(PlayerInterface):
|
||||
score = math.inf
|
||||
|
||||
elif self._board._nbBLACK + self._board._nbWHITE < 20:
|
||||
move = 1
|
||||
turn = self._board._nbBLACK + self._board._nbWHITE
|
||||
for play in self.plays:
|
||||
if len(play["moves"]) > turn and Goban.Board.name_to_flat(play["moves"][turn]) in self._board.legal_moves():
|
||||
move = Goban.Board.name_to_flat(play["moves"][turn])
|
||||
score = 1
|
||||
|
||||
else:
|
||||
elif move == -1:
|
||||
move, score = IDDFS(
|
||||
self._board, self.nnheuristic, self._mycolor, duration=duration, maxdepth=64
|
||||
)
|
||||
@ -203,6 +210,7 @@ class myPlayer(PlayerInterface):
|
||||
print(move, score, file=stderr)
|
||||
nd = time.time()
|
||||
self.time += (nd - st)
|
||||
self.turn += 1
|
||||
|
||||
# New here: allows to consider internal representations of moves
|
||||
# move is an internal representation. To communicate with the interface I need to change if to a string
|
||||
@ -213,6 +221,7 @@ class myPlayer(PlayerInterface):
|
||||
# the board needs an internal represetation to push the move. Not a string
|
||||
self._board.push(Goban.Board.name_to_flat(move))
|
||||
self.last_op_move = move
|
||||
self.turn += 1
|
||||
|
||||
def newGame(self, color):
|
||||
self._mycolor = color
|
||||
|
Loading…
x
Reference in New Issue
Block a user