-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
48 lines (38 loc) · 1.66 KB
/
test.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
import chess_gui as cg
from chessvis import util, Board
import fenparser
import os
# main function
if __name__ == '__main__':
fen_path = r'C:\Users\thewa\Desktop\projects\computational_neuroscience\AI_ML\chess\chess_vis_cli\fens'
pgn_path = r'C:\Users\thewa\Desktop\projects\computational_neuroscience\AI_ML\chess\chess_vis_cli\pgns'
while True:
choice = input("F:Fen, P:PGN, C:Custom -> (f/p/c): ")
match(choice):
case 'f':
fens_path = os.listdir(fen_path)
for i, fen in enumerate(fens_path):
print('-'*(len(fen)+7))
print('|',i,'|', fen, '|')
print('-'*(len(fen)+7))
fen_choice = int(input("Choose a fen: "))
fen = fens_path[fen_choice]
fens = os.path.join(fen_path, fen)
boards = util.boards_from_fens(fens)
cg.gui(boards, 'f')
case 'p':
pgns_path = os.listdir(pgn_path)
for i, pgn in enumerate(pgns_path):
print('-'*(len(pgn)+7))
print( '|',i,'|', pgn, '|')
print('-'*(len(pgn)+7))
pgn_choice = int(input("Choose a pgn: "))
pgn = pgns_path[pgn_choice]
pgn = os.path.join(pgn_path, pgn)
pgn = open(pgn)
boards = util.boards_from_pgn(pgn)
cg.gui(boards, 'p')
case 'c':
fen = input("Enter a fen: ")
boards = [Board(fen)]
cg.gui(boards, 'c')