-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadaptationBackboneToGUI.py
More file actions
58 lines (51 loc) · 1.04 KB
/
Copy pathadaptationBackboneToGUI.py
File metadata and controls
58 lines (51 loc) · 1.04 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
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 13 11:00:04 2023
@author: Mario
"""
import numpy as np
import copy
NUMBERS_TO_STRINGS = {
0 : "--",
1 : "wp",
2 : "wN",
3 : "wB",
4 : "wR",
5 : "wQ",
6 : "wK",
7 : "bp",
8 : "bN",
9 : "bB",
10 : "bR",
11 : "bQ",
12 : "bK"
}
STRINGS_TO_NUMBERS = {
"--" : 0,
"wp" : 1,
"wN" : 2,
"wB" : 3,
"wR" : 4,
"wQ" : 5,
"wK" : 6,
"bp" : 7,
"bN" : 8,
"bB" : 9,
"bR" : 10,
"bQ" : 11,
"bK" : 12
}
def convertToStrings(matrix):
mycopy = copy.deepcopy(matrix)
for x in range(len(mycopy)):
for y in range(len(mycopy[0])):
mycopy[x][y] = NUMBERS_TO_STRINGS[mycopy[x][y]]
mycopy[x] = np.asarray(mycopy[x])
return mycopy
def convertToNumbers(matrix):
mycopy = copy.deepcopy(matrix)
for x in range(len(mycopy)):
mycopy[x] = mycopy[x].tolist()
for y in range(len(mycopy[0])):
mycopy[x][y] = int(STRINGS_TO_NUMBERS[mycopy[x][y]])
return mycopy