Skip to content

Commit

Permalink
engine stable load
Browse files Browse the repository at this point in the history
  • Loading branch information
stevexyz committed Apr 28, 2018
1 parent 035530e commit 8d1beac
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 94 deletions.
4 changes: 2 additions & 2 deletions ValueNetwork/Eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

class Eval:

def __init__(self, modelfile=Const.MODELFILE+".hdf5", openingbookfile=None, tablebases=None):
def __init__(self, modelfile=Const.MODELFILE+".hdf5", openingbookfile=None, tablebases=None, quiet=False):
self.model = load_model(modelfile)
sys.stderr.write("Model "+modelfile+" loaded")
if not quiet: sys.stderr.write("Model "+modelfile+" loaded")
#if openingbook != None: self.openingbook = chess.polyglot.open_reader(openingbookfile)

def EvaluatePositionB(self, board):
Expand Down
81 changes: 0 additions & 81 deletions ValueNetwork/OnePlyEngineUci.py

This file was deleted.

23 changes: 12 additions & 11 deletions ValueNetwork/OnePlyEngineXBoard2.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/python3

import Const
from Eval import Eval
import chess.uci
import sys

Expand All @@ -12,9 +11,9 @@
forcemove = False
while True:

try: line = input()
try: line = sys.stdin.readline()
except KeyboardInterrupt: pass # avoid control-c breaks
line = line.strip(' \t\n')
line = line.strip(' \t\n'+chr(3))
parts = line.split(' ')

if parts[0]=='xboard':
Expand All @@ -23,17 +22,16 @@
print('tellics say by Stefano Maragò 2018')
print('tellics say https://github.com/stevexyz/SlyMlego')

elif parts[0]=='quit':
break

elif parts[0]=='protover':
elif parts[0]=='protover' and parts[1]=='2':
print('feature done=0')
sys.stdout.flush() # ensure xboard wait to activate network
print('feature debug=1')
from Eval import Eval
board = chess.Board()
if len(sys.argv)<=1: eval = Eval()
else: eval = Eval(modelfile=sys.argv[1])
if len(sys.argv)<=1: eval = Eval(quiet=True)
else: eval = Eval(modelfile=sys.argv[1], quiet=True)
eval.EvaluatePositionB(board) # just to startup engine
print('feature myname="oneply"')
print('feature myname="1ply-v0.1"')
print('feature variants="normal"')
print('feature setboard=1')
print('feature ping=1')
Expand All @@ -45,6 +43,9 @@
print('feature sigint=0')
print('feature done=1')

elif parts[0]=='quit':
break

elif parts[0]=='new':
board = chess.Board()

Expand Down Expand Up @@ -72,7 +73,7 @@
if board.is_checkmate():
val = -999999
else:
val = eval.EvaluatePositionB(board)[0] * ( -1 if board.turn==chess.BLACK else 1 )
val = eval.EvaluatePositionB(board)[0] * (-1 if board.turn==chess.BLACK else 1)
print("# currmove "+str(m)+" score "+str(-val))
if val<bestval: # look for minimum value for adversary
bestmove = m
Expand Down

0 comments on commit 8d1beac

Please sign in to comment.