-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
99 lines (90 loc) · 1.97 KB
/
main.py
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
90
91
92
93
94
95
96
97
98
99
import click
import multiprocessing
from config import Config
from typing import Optional
from mode.uci import main as uci_main
from mode.api import main as api_main
def run(config: Config):
if config.mode == "uci":
uci_main(config)
elif config.mode == "api":
api_main()
else:
raise ValueError("mode not supported, type --help to see supported modes.")
@click.command()
@click.option(
"--mode",
type=str,
help="Mode to run the engine, one of [uci, api].",
default="uci"
)
@click.option(
"--algorithm",
type=str,
help="Algorithm to use to search move.",
default="alpha_beta"
)
@click.option(
"--depth",
"--negamax-depth",
type=int,
help="Depth of negamax search.",
default=4
)
@click.option(
"--null-move",
type=bool,
help="If True, use null move prunning.",
default=False,
)
@click.option(
"--null-move-r",
type=int,
help="Null move reduction factor.",
default=2,
)
@click.option(
"--quiescence-search-depth",
type=int,
help="Max depth of quiescence search.",
default=3
)
@click.option(
"--syzygy-path",
type=str,
help="Path to syzygy endgame tablebases.",
default=None
)
@click.option(
"--syzygy-pieces",
type=int,
help="Remaining pieces to use syzygy endgame tablebases.",
default=5
)
def main(
mode: str,
algorithm: str,
depth: int,
null_move: bool,
null_move_r: int,
quiescence_search_depth: int,
syzygy_path: Optional[str],
syzygy_pieces: int,
):
"""
Starts the engine according to the options provided.
"""
config = Config(
mode=mode,
algorithm=algorithm,
negamax_depth=depth,
null_move=null_move,
null_move_r=null_move_r,
quiescence_search_depth=quiescence_search_depth,
syzygy_path=syzygy_path,
syzygy_pieces=syzygy_pieces,
)
run(config)
if __name__ == "__main__":
multiprocessing.freeze_support()
main()