-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
46 lines (37 loc) · 1.13 KB
/
utils.py
File metadata and controls
46 lines (37 loc) · 1.13 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
import numpy as np
class dotdict(dict):
def __getattr__(self, name):
return self[name]
class read():
def trainingData(boards, size):
boards = boards[3:len(boards) - 2]
boards = boards.split("],[[")
boardTuples = []
for row in boards:
row = row.split("],")
try:
board = row[0]
pi = row[1][1:]
result = row[2]
npboard = read.board(board, size)
nppi = read.pi(pi)
boardTuples.append((npboard, nppi, result))
except:
print("Error")
return boardTuples
def board(board, size):
board = str.split(board, ",")
board = np.array(board)
tempboard = []
for i in range(0, size):
row = []
for j in range(0, size):
row.append(board[(i * size) + j])
tempboard.append(row)
return np.array(tempboard)
def pi(pi):
pi = str.split(pi, ",")
tempboard = []
for i in pi:
tempboard.append(float(i))
return np.array(tempboard)