Munchkin Swarm;not enough time?


#1

So I am on munchkin swarm, and my code doesn’t have problems as far as I know, but when I use it, I don’t break the chest in time, I don’t think I can do this without like a claymore or something.

loop:
    enemy = self.findNearestEnemy()
    enemyDistance = self.distanceTo(enemy.pos)
    if self.isReady("cleave"):
        if enemyDistance < 10:
            self.cleave(enemy)
        else:
            self.attack(enemy)
    else self.attack("Chest")

code^^


#2

after tinkering, this code works aswell`

loop:
    enemy = self.findNearestEnemy()
    enemyDistance = self.distanceTo(enemy.pos)
    if enemyDistance < 5:
        if self.isReady("cleave"):
            self.cleave(enemy)
    else: self.attack("Chest")

however i still think a time limit is stupid cause if a code works it should have enough time to work
`


#3

You have a very specific task:
Only cleave when they come close, otherwise attack the chest.
Your first code does not accomplish this.
Your second code does.


#4

As J_F_B_M states, the task is to attack the chest.
This (I suspect) is to help teach us how to prioritize our operations better.
I created a bit of code that detects how many units are nearby, and I only cleave when the number exceeds a threshold.


#5

You should be able to attack the chest constantly except for cleaving once every 10 seconds to clear the munchkin attacks.