Simpler is better? (Sacred Statue)


#1

Fun level, btw. Not sure if this is interesting, but I was shocked to find that some really simple code worked way better than what I would have thought was better and more sophisticated code. I’ll play around with this tomorrow and try to figure it out but thought I’d do a quick post in case this is interesting to others.

This is Sacred Statue 2 and this code is at the end of the level (staying near the statue) I use it for both the ogre invasion and cyclops. I’m using Tharin and start out with 782 in health.

# this stupidly simple code works great
loop:
    self.moveXY(61,66)
    enemy = self.findNearest(self.findEnemies())
    if enemy: 
        self.attack(enemy)

# i thought i would spruce it up a little, but now it works much worse!     
loop:
    enemy = self.findNearest(self.findEnemies())
    if enemy and self.distanceTo(enemy) < 3: 
        while enemy.health > 0:
            if self.isReady("bash"):
                self.bash(enemy)
            elif self.isReady("power-up"):
                self.powerUp()
            self.attack(enemy)
    else:
        self.moveXY(61,66)

#2

Hmm… I think it might be the distance < 3 part. I changed that to 5 and it works about the same as the simpler code. The sword attack range is only 3, but I guess the 5 is better because with enemies moving towards you you need to start attacking before they are in range.


#3

The first few difficulties are pretty easy and intended to be. Wait til you start getting the harder enemies…


#4

You probably don’t want to always attack after bashing in your while loop, and you might want to only bash if the enemy you’re attacking has more health than your attack damage, and you could also save the power-up for when the enemy has so much health that the powerup will be high DPS (or do the powerup when the enemies aren’t around).


#5

OK, thanks Nick. Good tip about the power-up, I hadn’t thought about that. It takes a full second so need to be careful about doing that while surrounded by a swarm of enemies.