Pseudocode: defaultVelocity slowVelocity rangeClose rangeTooClose 1. Check for dangers/obstacles: * Some unknown condition that means I am stuck on something DO STUCK-EMERGENCY BEHAVIOR * otherwise Something is rangeTooClose to me in front DO EMERGENCY BEHAVIOR * otherwise Something is within rangeClose of me DO DECISION BEHAVIOR * otherwise There is an Interesting Thing DO INTERESTED BEHAVIOR * otherwise DO NORMAL BEHAVIOR STUCK-EMERGENCY BEHAVIOR Do whatever is necessary to get safely unstuck. I don't know what that would be. EMERGENCY BEHAVIOR Stop Play "emergency sound" or flash warning Choose direction left or right Set degrees to 0 While something is rangeTooClose to me in back Turn 10 degrees direction and increment degrees If thing is closer and not ReversedDirection, reverse direction set ReversedDirection set degrees to -degrees If I have turned 360 degrees, stop and panic While nothing is rangeTooClose to me in back AND something is rangeTooClose to me in front Go back at slowVelocity NORMAL BEHAVIOR While nothing is within rangeClose of me in front AND DETECT INTERESTING THINGS returns false Go forward at defaultVelocity If I went forward If I have been in normal behavior mode for less than some period (i.e. I am following a wall poorly) SWITCH TO ORGANIC PATHFINDING BEHAVIOR INSTEAD OF STANDARD DECISION BEHAVIOR else SWITCH TO STANDARD DECISION BEHAVIOR DETECT INTERESTING THINGS (placeholder for more "intelligent" wandering or other stuff Look for interesting things - these might be openings in the wall, some target, etc. INTERESTED BEHAVIOR (placeholder for more "intelligent" wandering or other stuff) Turn until facing the interesting thing While not blocked and not at the interesting thing Go forward at defaultVelocity Do some unknown behavior based on what the thing is DECISION BEHAVIOR Choose direction left or right While something is within rangeClose of me in front Turn 90 degrees direction If I have turned 360 degrees, DO ORGANIC PATHFINDING BEHAVIOR ORGANIC PATHFINDING BEHAVIOR (for use if the right-angle decision behavior yields poor results, this will hopefully re-orient the robot so it is not walking diagonally into a wall) Choose direction left or right Set degrees to 0 While something is within rangeClose of me in front Turn 10 degrees direction and increment degrees If thing is closer and not ReversedDirection, reverse direction set ReversedDirection set degrees to -degrees If I have turned 360 degrees, stop and panic