Maze

# Create a basic maze with a random walk algorithm (for simplicity)
def random_walk_maze(maze, start, end):
    current_pos = start
    stack = [current_pos]
    maze[start] = 0

    while stack:
        x, y = current_pos
        neighbors = []

        # Define potential moves (up, down, left, right)
        moves = [(-1, 0), (1, 0), (0, -1), (0, 1)]
        for dx, dy in moves:
            nx, ny = x + dx, y + dy
            if 0 < nx < size-1 and 0 < ny < size-1 and maze[nx, ny] == 1:
                if sum(maze[nx-1:nx+2, ny-1:ny+2].ravel()) >= 7:  # Ensure enough walls remain
                    neighbors.append((nx, ny))

        if neighbors:
            chosen_cell = random.choice(neighbors)
            maze[chosen_cell] = 0
            stack.append(chosen_cell)
            current_pos = chosen_cell
        else:
            current_pos = stack.pop()
            
    maze[end] = 0
    return maze

start = (1, 1)
end = (size - 2, size - 2)
maze = random_walk_maze(maze, start, end)

# Overlay a bear theme with paw prints in the maze
paw_coords = [(3, 3), (size - 4, 4), (size//2, size//2), (4, size - 4), (size - 5, size - 5)]
for x, y in paw_coords:
    if 0 < x < size and 0 < y < size:
        maze[x-1:x+2, y-1:y+2] = 0.5  # Indicate paw prints with a different value

# Plotting the maze with bear theme
plt.figure(figsize=(8, 8))
plt.imshow(maze, cmap="gray_r", origin="upper")
plt.title("Bear-Themed Maze (Medium Difficulty)")
plt.axis("off")

# Add start and end points
plt.text(1, 1, "Start", ha='center', va='center', color='blue', fontsize=12, fontweight='bold')
plt.text(end[1], end[0], "End", ha='center', va='center', color='green', fontsize=12, fontweight='bold')

plt.show()