-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlearn-op
executable file
·89 lines (86 loc) · 2.02 KB
/
learn-op
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env coffee
require './rejection_handler'
{ pos_array_from_str } = require './board'
{ watch_file } = require './util'
Book = require './book'
op_eval = require './op_eval'
argv = require 'yargs'
.options
o:
alias: 'opening'
desc: 'Opening to learn'
default: 'F5'
type: 'string'
requiresArg: true
n:
desc: 'Number to learn'
type: 'number'
default: Infinity
requiresArg: true
u:
alias: 'uct'
desc: 'Use UCT to evaluate leafs (default is minimax)'
type: 'boolean'
default: false
s:
desc: 'Number of evaluation UCT search'
type: 'number'
default: op_eval.defaults.max_search
requiresArg: true
d:
alias: 'depth'
desc: 'Minimax search depth'
type: 'number'
default: op_eval.defaults.depth
requiresArg: true
w:
alias: 'wld'
desc: 'Depth of win-loss-draw solve'
type: 'number'
default: op_eval.defaults.wld
requiresArg: true
f:
alias: 'full'
desc: 'Depth of full solve'
type: 'number'
default: op_eval.defaults.full
requiresArg: true
S:
alias: 'scope'
desc: 'UCT constant to find opening'
default: .6
type: 'number'
requiresArg: true
B:
alias: 'book'
desc: 'Database file'
default: 'book.db'
type: 'string'
requiresArg: true
watch:
desc: 'Watch the file and exit when it changes'
default: 'weights.json'
requiresArg: true
v:
alias: 'verbose'
default: false
type: 'boolean'
h:
alias: 'help'
.strict()
.version false
.argv
evaluate = op_eval
uct: argv.uct
max_search: argv.s
depth: argv.depth
wld: argv.wld
full: argv.full
do ->
book = new Book argv.book, evaluate: evaluate, verbose: argv.verbose
book.init()
opening = pos_array_from_str(argv.opening)
reload = if argv.watch then watch_file(argv.watch) else -> false
for i in [0...argv.n]
book.extend argv.scope, opening
break if reload()