2018-05-21 23:32:24 ===== Starting: Testing =====
2018-05-21 23:32:29 Run
2018-05-21 23:32:29 id = 0 (machine1); Seed = 0; Starting new sample
2018-05-21 23:32:29 id = 0 (machine1); Seed = 0; Error: No Outcome.
StandardOutput:
StandardError:
Warning: Unknown option: "machine1"
2018-05-21 23:32:29 id = 0 stopped. RunningProcessors = 0
2018-05-21 23:32:29 Stop
I'm guessing I am doing something silly, but cannot figure out what. Can anyone help? Here is my CLOP file:
Code: Select all
# See DummExperiment.clop for documentation about file format
Script C:/Users/Albert/Chess/cutechess/cutechess-cli.exe
Name Testing
LinearParameter Cpuct_MCTS_option 1.2 4.0
LinearParameter First_Play_Urgency_Reduction -1.0 1.0
Processor machine1
Replications 2
DrawElo 100
H 3
Correlations all
Code: Select all
#!/usr/bin/python
# -*- coding: utf-8 -*-
from subprocess import Popen, PIPE
import sys
# Path to the cutechess-cli executable.
# On Windows this should point to cutechess-cli.exe
cutechess_cli_path = "C:/Users/Albert/Chess/cutechess/cutechess-cli.exe"
# The engine whose parameters will be optimized
engine = 'cmd=C:/Users/Albert/Chess/LCZero/lc0-may21.exe name=lc0 option."Network weights file path"=C:/Users/Albert/Chess/LCZero/weights314.txt option."Number of worker threads"=4'
# Format for the commands that are sent to the engine to
# set the parameter values. When the command is sent,
# {name} will be replaced with the parameter name and {value}
# with the parameter value.
engine_param_cmd = 'setoption name {name} value {value}'
# A pool of opponents for the engine. The opponent will be
# chosen based on the seed sent by CLOP.
opponents = [
'cmd=C:/Users/Albert/Chess/wasp_300/wasp300-x64.exe name=Wasp3 option."Threads"=4'
]
# Additional cutechess-cli options, eg. time control and opening book
options = '-resign movecount=2 score=700 -draw movenumber=0 movecount=100 score=10 -openings file=C:/Users/Albert/Chess/ss-large-990.pgn -srand 42 -each proto=uci restart=off tc=1+1'
def main(argv = None):
print('args:', argv, flush=True)
if argv is None:
argv = sys.argv[1:]
if len(argv) == 0 or argv[0] == '--help':
sys.stdout.write(__doc__)
return 0
argv = argv[1:]
if len(argv) < 3 or len(argv) % 2 == 0:
sys.stderr.write('Too few arguments\n')
return 2
clop_seed = 0
try:
clop_seed = int(argv[0])
except ValueError:
sys.stderr.write('invalid seed value: %s\n' % argv[0])
return 2
fcp = engine
scp = opponents[(clop_seed >> 1) % len(opponents)]
# Parse the parameters that should be optimized
for i in range(1, len(argv), 2):
# Make sure the parameter value is numeric
try:
float(argv[i + 1])
except ValueError:
sys.stderr.write('invalid value for parameter %s: %s\n' % (argv[i], argv[i + 1]))
return 2
# Pass CLOP's parameters to the engine by using
# cutechess-cli's initialization string feature
initstr = engine_param_cmd.format(name = argv[i].replace('_', ' '), value = argv[i + 1])
fcp += ' initstr="%s"' % initstr
# Choose the engine's playing side (color) based on CLOP's seed
if clop_seed % 2 != 0:
fcp, scp = scp, fcp
cutechess_args = '-engine %s -engine %s %s' % (fcp, scp, options)
command = '%s %s' % (cutechess_cli_path, cutechess_args)
# Run cutechess-cli and wait for it to finish
process = Popen(command, shell = True, stdout = PIPE)
output = process.communicate()[0]
if process.returncode != 0:
sys.stderr.write('failed to execute command: %s\n' % command)
return 2
# Convert Cutechess-cli's result into W/L/D
# Note that only one game should be played
result = -1
for line in output.decode("utf-8").splitlines():
if line.startswith('Finished game'):
if line.find(": 1-0") != -1:
result = clop_seed % 2
elif line.find(": 0-1") != -1:
result = (clop_seed % 2) ^ 1
elif line.find(": 1/2-1/2") != -1:
result = 2
else:
sys.stderr.write('the game did not terminate properly\n')
return 2
break
if result == 0:
sys.stdout.write('W\n')
elif result == 1:
sys.stdout.write('L\n')
elif result == 2:
sys.stdout.write('D\n')
if __name__ == "__main__":
sys.exit(main())