Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
random solution in Creative category for Forgetful Prisoner by Sim0000
from random import choice
def find_path(scanner, olddir):
D = 'NESW'
if sum(scanner[d] > 0 for d in D) == 4: # When crossroad, randomly choice new direction
newdir = (olddir + choice((1,0,-1))) % 4
else:
# Right hand method
for i in (1,0,-1, 2):
newdir = (olddir + i) % 4
if scanner[D[newdir]] > 0: break
return D[newdir], newdir
# This algorithm is substantially right hand method except when crossroad.
Oct. 22, 2014