Skip to content Skip to sidebar Skip to footer

How To Solve A Basic Maze Using Functions In Python?

I am trying to write a code that solves a basic maze made up of a list of lists with '#' symbolizing walls, '.' are free spaces, S is the start and E is the end. My algorithm consi

Solution 1:

The error you are encountering occurs because main calls solve without a required argument.

def main():

    print_maze()
    start()
    solve() # Error! Missing required arg
    print_maze()

Since solve redefines start_point right away you can just remove that required argument:

def solve():

    start_point =start()

Finally, you didn't provide maze so anybody trying to help you beyond this problem won't be able to

Solution 2:

You need to pass the value returned from start() into the solve() function because you listed it as an argument. You can then remove the start_point= portion from the solve() function.

defmain():
    print_maze()
    start = start()
    solve(start)
    print_maze()

Solution 3:

Try to change the def slove format eg; == "X" = "x²"

Post a Comment for "How To Solve A Basic Maze Using Functions In Python?"