Savern Sentry - gameplay help


The code for this level is simple enough, but I’m running into a funny gameplay problem: every time I’ve played in real-time, at some point my hero gets stuck behind his (or her) own fence. I was thinking of modifying the code so that the hero wouldn’t put the trap/fence right on the flag, but I’d have to come up with a whole pile of variables, one for each of the six directions, so that my hero would ‘know’ which direction from the flag to put it (e.g. if a yak is coming from due east, flag.pos.x + 5), which is tedious, in my opinion. Is there another solution?


In the end, I just went for the hard code. Here’s an idea for how, just with two of the if/elif parts. If someone is reading this because they’re also stuck, this is only part of the code. You’ll need to finish off the code yourselves:

while True:
    flagGreen = hero.findFlag("green")
    flagBlack = hero.findFlag("black")
    if flagGreen:
        hero.moveXY(flagGreen.pos.x, flagGreen.pos.y)
        if flagGreen.pos.y < 15:
            hero.buildXY("fence", flagGreen.pos.x, flagGreen.pos.y - 5)
        elif flagGreen.pos.x < 22:
            hero.buildXY("fence", flagGreen.pos.x - 5, flagGreen.pos.y)

That kept my hero on the right side of the fence. I’m still interested in a simpler solution, though.


Do you move back to the center? Because either this is a bug you shouldn’t have to do that much code I didn’t need to do that much code. So could you show me all of your code to find out any other problems within your code or to prove that it is a bug?


I already got a warning for what I did post, though the rest is just a basic code for laying fire-traps.

I believe this is a bug; my hero would get caught on the wrong side of the fence, literally. The code I used before hard coding was the code suggested by the editor. The code was clean enough not to get any error messages.

And yes, I had the move back to center included. Since my hero was on the wrong side of the fence, they’d get stuck, and issue a “I can’t get there.”