/home/cis130/simmsric/lab4 $ more lab4 # # CIS 130 (Spring Term) # # Rich Simms # # lab 4 (work way through maze and find a ring) # # To get out of a maze you can always just follow the wall on the # left or right and you will eventually get out. The algoritm for # following the wall on the right is: # # 1) no wall on right - turn right and move # 2) wall on right, clear ahead - move forward # 3) wall on right, blocked - turn left # source libfrodo check_for_ring () { next_to_ring && pickring } follow_wall_right () { if is_clear RIGHT then turnright; move else if is_clear then move else turnleft fi fi } check_for_ring while ! any_rings do follow_wall_right check_for_ring done stop