Skip to content

Commit 01ae6e0

Browse files
committed
feat(grid2d): add grid2d parent class
1 parent ba68db9 commit 01ae6e0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

algorithms/grid2d.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import numpy as np
2+
3+
class Grid2D:
4+
5+
def __init__(self, grid_width, grid_height, visited=None):
6+
self.grid_width = grid_width
7+
self.grid_height = grid_height
8+
if visited is None:
9+
self.visited = np.zeros((grid_height, grid_width))
10+
else:
11+
self.visited = visited
12+
self.steps_taken = np.zeros((grid_height, grid_width))
13+
14+
def neighbour(self, x, y):
15+
neighbours = []
16+
for dx in [-1,0,1]:
17+
for dy in [-1,0,1]:
18+
neighbours.append([x + dx, y + dy])
19+
return neighbours

0 commit comments

Comments
 (0)