Hi there! I’ve taken it upon myself to complete the Stranded in the Dunes level without using flags to avoid obstacles. Here is the current version of my code.
def searchAndDestroy(target): if hero.canCast("lightning-bolt"): hero.cast("lightning-bolt", target) elif hero.canCast("chain-lightning"): hero.cast("chain-lightning", target) else: hero.attack(target) pass def treadLightly(target): safety = hero.distanceTo(target) if safety < 8: if (hero.pos.y >= target.pos.y + 3) or (hero.pos.y <= target.pos.y - 3): hero.moveXY(target.pos.x + 5, hero.pos.y) else: hero.moveXY(hero.pos.x, hero.pos.y + 8) pass while True: enemy = hero.findNearestEnemy() mine = hero.findNearestItem() if hero.health < hero.maxHealth - 100 and hero.canCast("regen"): hero.cast("regen", self) elif enemy: if enemy.type != "sand-yak": searchAndDestroy(enemy) elif mine: treadLightly(mine) else: hero.moveXY(hero.pos.x + 5, hero.pos.y)
This works well enough to move my hero through the level alive except for 2 issues.
Issue 1: Yaks thankfully have ran around my hero in all the tests, but ideally I’d want to be able to check the position of the yak herd in reference to the hero’s position so he can dodge those as well while still making sure not to run into fire-traps.
Issue 2: The big one. If terrain gets in the way (which it does on the last part of the stage or if while dodging fire-traps on the edge of the map) the hero just gets stuck and can’t proceed. So how can I have my program check for impassible terrain so that I can have him maneuver past it?