aa
This commit is contained in:
parent
fc060c7da1
commit
18b927a213
@ -17,6 +17,7 @@ import torch.nn as nn
|
||||
import torch.nn.functional as F
|
||||
import numpy as np
|
||||
from torch.utils.data import Dataset
|
||||
import json
|
||||
|
||||
def setup_device():
|
||||
# Allows to use the GPU if available
|
||||
@ -131,17 +132,23 @@ class myPlayer(PlayerInterface):
|
||||
self.maxtime = 1800
|
||||
self.time = 0
|
||||
|
||||
self.plays = []
|
||||
with open("plays-8x8.json") as f:
|
||||
plays = json.load(f)
|
||||
|
||||
l = "W" if self._mycolor == Goban.Board._WHITE else "B"
|
||||
filtered = filter(lambda t: l in t["result"], self.plays)
|
||||
|
||||
lp = l + "+"
|
||||
for el in filtered:
|
||||
el["result"] = float(el["result"].replace(lp, ""))
|
||||
self.plays.append(el)
|
||||
|
||||
self.plays.sort(key=lambda t: t["result"])
|
||||
|
||||
def getPlayerName(self):
|
||||
return "xXx_7h3_5cRuM_M45T3r_xXx"
|
||||
|
||||
@staticmethod
|
||||
def simple_heuristic(board, color):
|
||||
# Simple stone difference heuristic
|
||||
score = board.compute_score()
|
||||
return (
|
||||
score[0] - score[1] if color == Goban.Board._BLACK else score[1] - score[0]
|
||||
)
|
||||
|
||||
def nnheuristic(self, board: Goban.Board, color):
|
||||
if board.is_game_over():
|
||||
if board.winner() == board._EMPTY:
|
||||
@ -184,6 +191,9 @@ class myPlayer(PlayerInterface):
|
||||
move = -1
|
||||
score = math.inf
|
||||
|
||||
elif self._board._nbBLACK + self._board._nbWHITE < 20:
|
||||
move = 1
|
||||
|
||||
else:
|
||||
move, score = IDDFS(
|
||||
self._board, self.nnheuristic, self._mycolor, duration=duration, maxdepth=64
|
||||
|
Loading…
x
Reference in New Issue
Block a user