I’ve got some problem with the level treasured-in-ice, in particular with isPathClear() method.
Here’s some of my code:
def worthHeadingWest():
if treasurePickedUp():
target = exitPosition
else:
target = treasurePosition
return target.x < hero.pos.x and hero.isPathClear(hero.pos, westRoomPos())
In my loop I have:
if worthHeadingWest():
p = westRoomPos()
fromDirection = "east"
elif worthHeadingSouth:
p = southRoomPos()
fromDirection = "north"
elif worthHeadingEast():
# blah
elif worthHeadingNorth():
# blah
hero.moveXY(p.x, p.y)
My character went west for 2 times, then the problem occurs:
South gate is open but west gate is NOT. But my character stood still…
Have I missed something? Any caveats regarding isPathClear method?
(Twilight Glasses)
Found my own problem after posting it out and reviewing the code let.
Missing the brackets after worthHeadingSouth… OMG…
Update:
Hm… this strategy doesn’t work…
Tried the hints and it doesn’t give any algorithm…
Any tips on the path finding logic guys?
Thanks heaps!
Update 2:
Tried to think of a way to record a gates[row][column] variable.
Putting True or False in it indicating if the gate is broken or not.
Don’t know if I’m thinking in the correct direction?