Skip to content

Instantly share code, notes, and snippets.

@glinscott
Created February 4, 2014 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glinscott/8814218 to your computer and use it in GitHub Desktop.
Save glinscott/8814218 to your computer and use it in GitHub Desktop.
Eval tuning
#!/usr/bin/python
import math
import numpy
import subprocess
from scipy.optimize import fmin_cg
bestv = 9999999
def sferror(x):
global bestv
with open('params', 'w') as f:
for value in x:
f.write('%d\n' % (int(value + 0.5)))
p = subprocess.Popen('./stockfish', stdout=subprocess.PIPE)
output = p.communicate()[0]
v = float(output)
print v
if v < bestv:
bestv = v
with open('params.best', 'w') as f:
for value in x:
f.write('%d\n' % (int(value + 0.5)))
return v
def main():
with open('params') as f:
params = [float(x) for x in f.readlines()]
fmin_cg(sferror, params, epsilon=20)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment