Purchase Solution

Python code for robot finding path in a maze

Not what you're looking for?

Ask Custom Question

Please produce a Python code for a robot navigating a maze. (Please see the attached file for additional information on the problem).

Purchase this Solution

Solution Summary

The solution contains a working python code that solves the path finding problem. The code is fully documented and contains a detailed explanation of the algorithm.

Solution Preview

(Please refer to the detailed explanations in the .py file attached).
The code is tested under Python 3.3 under Win x64 environment. If you believe a different python version might cause any trouble, please let me know and I will test the code in the environment you specify.

# This might not be the most efficient implementation, but it should work.
# The idea is to walk randomly, but never make the same move again.
# For example, if we move north from x=0,y=1, and we got stucked,
# then the next time we reach the node x=0,y=1, we should never go north again

# This function determines if we can move to node x,y
# Returns false whenever the node is invalid, or the node is a wall
def CanMove(maze, x, y):
if x < 0 or y < 0 or y >= len(maze):
return False

row = maze[y]
if x >= len(row):
return False

if maze[y][x]=='w':
return False

return True

# Move coordinate from x,y forward by 1 unit in the direction facing
def MoveDir(facing, x, y):
if facing == 'N':
return ...

Purchase this Solution


Free BrainMass Quizzes
Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

C# variables and classes

This quiz contains questions about C# classes and variables.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.