-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
60 lines (46 loc) · 1.32 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
import sys
from core.zuggenerator import gen_all_masks
from core.utils import Board, Move
from core.aitech.pvs.pvs_sorted_multi_qs import pvs_multi_sort_qs
def get_move(board: Board, time_limit: int) -> Move:
move = pvs_multi_sort_qs(board=board, time_limit=time_limit)
return move
def main():
args = sys.argv[1:]
fen = ""
time_limit = 7
all = False
for i, arg in enumerate(args):
if arg == "-fen":
if len(args) < i + 2:
print("No fen was specified. Abort")
return
fen = args[i + 1: i + 7]
elif arg == "-a":
all = True
elif arg == "-t":
if len(args) < i + 2:
print("No time was specified. Abort")
return
time_limit = args[i + 1]
else:
pass
try:
time_limit = int(time_limit)
except Exception as e:
print("time invalid. Must be int. Abort")
return
if fen == "":
print("No fen was provided. Abort")
return
fen = " ".join(fen)
try:
board = Board(fen)
except Exception as e:
print("fen was invalid. Abort")
return
move = get_move(board, time_limit = time_limit)
print(f"Best move: {move}")
if __name__ == "__main__":
gen_all_masks()
main()