Skip to content

Commit

Permalink
more changes
Browse files Browse the repository at this point in the history
Signed-off-by: jparisu <[email protected]>
  • Loading branch information
jparisu committed Aug 26, 2024
1 parent af2f4d8 commit 5e55622
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/sIArena/terrain/generator/MazeGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ def generate_random_matrix_(
maze_m = (1 + m) // 2

maze = Maze(maze_n, maze_m)
print(maze)

matrix = np.ones((n, m))
matrix = np.zeros((n, m))

for i in range(maze_n):
for j in range(maze_m):
Expand All @@ -47,18 +48,12 @@ def generate_random_matrix_(
if 2*i+1 < n and 2*j+1 < m:
matrix[down_right] = 1

# If n is odd, add a last space at the bottom
if n % 2 == 1:
matrix[n-1][-1] = 0

# If m is odd, add a last space at the right
if m % 2 == 1:
matrix[-1][m-1] = 0

# If both are odd, add a last space at the bottom right
if n % 2 == 1 and m % 2 == 1:
matrix[n-1][m-2] = 0
# Assure last cell is 0
matrix[-1][-1] = 0

# If both n and m are even, add a connection between the last two cells
if n % 2 == 0 and m % 2 == 0:
matrix[-2][-1] = 0

return matrix

Expand Down Expand Up @@ -91,12 +86,16 @@ def visit(self):

class Maze:

def __init__(self, n, m):
def __init__(self, n, m, start_point=None):
self.n = n
self.m = m
self.matrix = [[Tile() for _ in range(m)] for _ in range(n)]

current = (n//2, m//2)
if start_point is None:
current = (n//2, m//2)
else:
current = start_point

self.matrix[current[0]][current[1]].visit()
to_visit = self.surrounding_coordinates(current)

Expand Down

0 comments on commit 5e55622

Please sign in to comment.