-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
91 lines (76 loc) · 4.41 KB
/
utils.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import numpy as np
def get_representation(representation):
arr = representation.split("\n")
maxlen = len(max(arr, key=len))
return np.array([list(x + (' ' * (maxlen - len(x)))) for x in arr])
layouts = [
[
'',
' 3333333333333333 ',
' 222222222222 222222222222 ',
' 111111111111 111111111111 ',
' 00000000 00000000 ',
],
[
' 3333333333333333 ',
' 222222222222 222222222222 ',
' 111111111111 111111111111 ',
' 00000000 00000000 ',
' ',
' 1111 1111 ',
' 111100001111 111100001111 ',
' 111100001111 111100001111 ',
' 1111 1111 ',
' ',
' ',
' 55555555 ',
' 33333333 ',
' 22222222 ',
' 11111111 ',
' ',
' 33333333 33333333 ',
' 11111111 11111111 ',
' 44444444 44444444 ',
' 44444444 ',
],
[
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
' 0000 0000 0000 0000 0000 0000',
' 0000 0000 0000 0000 0000 0000',
' 0000 0000 0000 0000 0000 0000',
' 0000 0000 0000 0000 0000 0000',
' 0000 0000 0000 0000 0000 0000',
' 0000 0000 0000 0000 0000 0000',
],
]
def get_bricks(Brick, level=0):
if level >= len(layouts):
return None
bricks = []
layout = layouts[level]
for y in range(len(layout)):
x = 0
while x < len(layout[y]):
ch = layout[y][x]
if ch == ' ':
x += 1
continue
if ch == '0':
strength = -1
else:
strength = int(ch)
bricks.append(
Brick(position=np.array([y+2, x]), strength=strength))
x += 4
return bricks