-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPredictionVisualization.py
More file actions
72 lines (58 loc) · 2.23 KB
/
PredictionVisualization.py
File metadata and controls
72 lines (58 loc) · 2.23 KB
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
import torch
import torch.utils.data
import CNN
import pickle
import TrainingData as data
"""
fun class to visualize board alongside a network's evaluation of the position - manual testing / sanity checking
"""
def displayBoard(board):
# create display
display = [[' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' '], [' ',' ',' ',' ',' ',' ',' ',' ']]
# set up piece representations
pieces = dict([ (0, "K+"), (1, "Q+"), (2, "R+"), (3, "B+"), (4, "N+"), (5, "P+"), (6, "K-"), (7, "Q-"), (8, "R-"), (9, "B-"), (10, "N-"), (11, "P-") ])
# transcribe board tensor
for channel in range(0,12):
for x in range(0,8):
for y in range(0,8):
if board[0][channel][y][x] == 1:
display[y][x] = pieces[channel]
print('')
if board[0][13][0][0] == 1:
print("Black to move")
else:
print("White to move")
print('')
print('8', end=' ')
print(display[0])
print('7', end=' ')
print(display[1])
print('6', end=' ')
print(display[2])
print('5', end=' ')
print(display[3])
print('4', end=' ')
print(display[4])
print('3', end=' ')
print(display[5])
print('2', end=' ')
print(display[6])
print('1', end=' ')
print(display[7])
print('')
print(' ', end=' ')
print(['a ', 'b ', 'c ', 'd ', 'e ', 'f ', 'g ', 'h '])
print('')
# with open(r'D:\Machine Learning\DeepLearningChessAI\Data\ratioDataset.db', 'rb') as file:
# train_set = pickle.load(file)
# with open(r'D:\Machine Learning\DeepLearningChessAI\Networks\Statistician.cnn', 'rb') as file:
# network = pickle.load(file)
# #train_set, validation_set, dummy_set = torch.utils.data.random_split(train_set, [166000, 18000, 72])
# train_loader = torch.utils.data.DataLoader(train_set, 1, shuffle=True)
# for batch in train_loader:
# board, result = batch
# displayBoard(board)
# pred = network(board.cuda())
# print('Evaluation:')
# print(pred)
# input()