-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforest.py
43 lines (42 loc) · 1.08 KB
/
forest.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
from random_direction import generate_random_value
import numpy as np
def create_forest(num, wind = False):
forest = np.zeros((num, num))
x = y = num//2
forest[x, y] = 1
lst = []
#print wind
for i in range(num//2-1):
value = generate_random_value(wind)
lst.append(value)
if wind == "East":
y += 1
x -= value
elif wind == "West":
y -= 1
x -= value
elif wind == "North":
y -= value
x -= 1
elif wind == "South":
y -= value
x += 1
else:
if value in [1, 2, 3]:
x -= 1
if value == 1:
y -= 1
elif value == 3:
y += 1
elif value in [5, 6, 7]:
x += 1
if value == 5:
y += 1
elif value == 7:
y -= 1
elif value == 4:
y += 1
else:
y -= 1
forest[x, y] = 1
return forest