-
Notifications
You must be signed in to change notification settings - Fork 2
/
modifiedFF.py
78 lines (59 loc) · 1.29 KB
/
modifiedFF.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
import numpy as np
grid = 6
a = np.zeros((grid,grid))
walls = np.zeros((grid,grid))
walls = np.array([
# [11,8,10,8,10,12],
# [9,6,9,2,12,5],
# [5,13,1,14,3,4],
# [1,4,5,9,12,5],
# [5,3,6,5,5,5],
# [3,10,10,6,3,6]
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[0,0,0,0,0,0],
[0,0,0,4,5,4],
[0,0,0,4,3,4],
])
print('walls')
print(walls)
n = 1 #goal value
a[5,0] = n #setting location of goal
#print(a)
while n < 50:
for i in range(0,grid):
for j in range(0,grid):
# print('n is ' +str(n))
# print('i is ' + str(i))
# print('j is ' + str(j)+'\n')
if a[i,j] == n:
#print('yes')
if (i+1)<grid:
#Check South side
if a[i+1,j] != 1 and a[i+1,j] == 0 and (walls[i,j] & 2 == 0):
#print('1')
a[i+1,j] = n+1
#print(a)
if (i-1)>-1:
#check North
if a[i-1,j] != 1 and a[i-1,j] == 0 and (walls[i,j] & 8 == 0):
#print('2')
a[i-1,j] = n+1
#print(a)
if(j+1)< grid:
#check east
#print('no')
if a[i,j+1] != 1 and a[i,j+1] == 0 and (walls[i,j] & 4 == 0):
#print('3')
a[i,j+1] = n+1
#print(a)
if (j-1)>-1:
#check weset
if a[i,j-1] != 1 and a[i,j-1] == 0 and (walls[i,j] & 1 == 0):
#print('4')
a[i,j-1] = n+1
#print(a)
n+=1
print('final array')
print(a)