-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeds_2d.py
94 lines (72 loc) · 2.22 KB
/
seeds_2d.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
92
93
94
#!/usr/bin/env python
__author__ = 'Fred Flores'
__version__ = '0.0.1'
__date__ = '2020-04-27'
__email__ = '[email protected]'
import numpy as np
def center(shape):
mid_point = int(shape[0]/2)
x = np.zeros(shape)
x[mid_point, mid_point] = 1
return x
def center_row_7(shape):
mid_point = int(shape[0]/2)
x = np.zeros(shape)
x[mid_point, mid_point-3:mid_point+4:1] = 1
return x
def random(shape):
return np.random.randint(0, 2, shape)
def triomino_1(shape):
mid_point = int(shape[0] / 2)
x = np.zeros(shape)
x[mid_point - 1, mid_point + 1] = 1
x[mid_point, mid_point] = 1
x[mid_point + 1, mid_point] = 1
return x # nothing; all dies
def triomino_2(shape):
mid_point = int(shape[0] / 2)
x = np.zeros(shape)
x[mid_point - 1, mid_point] = 1
x[mid_point, mid_point] = 1
x[mid_point + 1, mid_point] = 1
return x # col -> row -> col repeats
def triomino_3(shape):
mid_point = int(shape[0] / 2)
x = np.zeros(shape)
x[mid_point, mid_point + 1] = 1
x[mid_point, mid_point] = 1
x[mid_point + 1, mid_point] = 1
return x # stable 4 square
def triomino_4(shape):
mid_point = int(shape[0] / 2)
x = np.zeros(shape)
x[mid_point - 1, mid_point + 1] = 1
x[mid_point, mid_point] = 1
x[mid_point + 1, mid_point - 1] = 1
return x # stable 4 square
def tetromino_4(shape):
mid_point = int(shape[0] / 2)
x = np.zeros(shape)
x[mid_point, mid_point - 1] = 1
x[mid_point - 1, mid_point] = 1
x[mid_point, mid_point] = 1
x[mid_point, mid_point + 1] = 1
return x # stable 4 square
def glider(shape):
mid_point = shape[0] - 4
x = np.zeros(shape)
x[mid_point, mid_point] = 1
x[mid_point, mid_point + 1] = 1
x[mid_point, mid_point - 1] = 1
x[mid_point + 1, mid_point - 1] = 1
x[mid_point + 2, mid_point] = 1
return x # like a flying bird
initialize = {'center': center,
'random': random,
'triomino_1': triomino_1,
'triomino_2': triomino_2,
'triomino_3': triomino_3,
'triomino_4': triomino_4,
'tetromino_4': tetromino_4,
'glider': glider,
'center_row_7': center_row_7}