user: Write me a pseudocode for a maze solving algorithm. Assume the agent navigating the maze can only tell what's directly in front of them (a wall, an exit, or nothing). You can freely assume there are no loops in the maze.

assistant: Sure! Here's an example pseudocode for a maze solving algorithm that uses a depth-first search approach:

```
function mazeSolver(maze):
    create a stack and push the starting position
    create a set to store visited positions
    while stack is not empty:
        current = pop stack
        if current is the goal:
            return "path found"
        if current is not in visited set:
            add current to visited set
            for each adjacent cell in current's four directions:
                if adjacent is not a wall:
                    push adjacent to stack with current as its parent
    return "no path found"
```

This algorithm starts by creating a stack and adding the starting position of the maze to it. It also creates a set to store visited positions. The algorithm then enters a loop that continues until the stack is empty.

In each iteration of the loop, the algorithm pops the last position added to the stack (which is the most recently added position). It then checks if the current position is the goal position, and if so, returns a "path found" message. If the current position is not the goal position and it hasn't been visited before, the algorithm adds it to the visited set.

The algorithm then looks at each of the four adjacent positions to the current position (up, down, left, and right). If a given adjacent position is not a wall, the algorithm adds it to the stack with the current position as its parent. The parent information is needed to reconstruct the final path once the goal position is found.

If no path to the goal position is found after all possible positions have been visited, the algorithm returns a "no path found" message.

user: Write a python script of the above pseudo code

assistant: Here's the Python script for the maze solving algorithm using depth-first search:

```python
def mazeSolver(maze):
    stack = [(0, 0)]  # starting position
    visited = set()
    while stack:
        current = stack.pop()
        if current == (len(maze)-1, len(maze[0])-1):  # goal position
            return "path found"
        if current not in visited:
            visited.add(current)
            x, y = current
            # check adjacent positions
            for dx, dy in [(0,1), (1,0), (0,-1), (-1,0)]:
                next_x, next_y = x+dx, y+dy
                if 0 <= next_x < len(maze) and 0 <= next_y < len(maze[0]) and maze[next_x][next_y] != "wall":
                    stack.append((next_x, next_y))
    return "no path found"
```

In this script, the maze is represented as a 2D list where each element is either a "wall" or a free cell. The starting position is (0,0) and the goal position is (len(maze)-1, len(maze[0])-1). The algorithm uses a tuple to represent each position.

The algorithm is essentially the same as the pseudocode, with the only difference being the syntax and some minor details, such as checking if the adjacent position is within the bounds of the maze.