Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Munchkin Swarm;not enough time?


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.

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



after tinkering, this code works aswell`

    enemy = self.findNearestEnemy()
    enemyDistance = self.distanceTo(enemy.pos)
    if enemyDistance < 5:
        if self.isReady("cleave"):
    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


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.


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.


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