Help with making maze solver code more concise
I am trying to make this left hand rule maze solver function as concise as possible, even if it becomes more unreadable. I think the idea is called code golf.
I can't seem to make it less than 9 lines. Any help or suggestions appreciated. Code below.
Solver function ("maze"):
def runner(index = 0, dirs = {North:West, East:North, South:East, West:South}):
`plant(Entities.Bush)`
`use_item(Items.Weird_Substance,get_world_size()*32)`
`while get_entity_type() != Entities.Treasure:`
`if not move(list(dirs)[index]) and not can_move(dirs[list(dirs)[index]]):`
`index = (index + 1) % 4`
`elif can_move(dirs[list(dirs)[index]]):`
`index = (index - 1) % 4`
`harvest()`
Main file:
import maze
set_world_size(6)
while not maze.runner():
`pass`
u/Remarkable_Crab5892 — 3 days ago