Level "Mixed Unit Tactics" Problems


#1

It seems that I can only summon about 3 units before 20 enemy units are summoned in 25 seconds.

I’m not sure if this is fair or there is something I’m missing.

Also the palisade is counted as an enemy, not sure if intended.


#2

Hello Justin,

Help us help you, what is your code? If we know your code, we can inspect it for errors that might cause your problem.


#3

I’ve been trying different things but this is the last thing I had

loop:
coin = self.findNearest(self.findItems())
self.move(coin.pos)

summonTypes = ["soldier","soldier","archer"]
type = summonTypes[len(self.built) % len(summonTypes)]
if self.gold >= self.costOf(type):
    self.summon(type)

friends = self.findFriends()
for friend in friends:
    enemies = self.findEnemies()
    enemyIndex = 0 
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        if enemy.type != "palisade":
            if enemy.type == "thrower":
                self.command(friend, "attack", enemy)
            elif enemy and friend.distanceTo(enemy) < 40: 
                self.command(friend, "attack", enemy)
        enemyIndex += 1

#4

Ah. First things first,

#Indentation is everything!

In Python, whitespace is mandatory to the running of a program. None of your commands are inside the loop. put them is, then see that happens.


#5

woops, thats just when I copied and pasted it. I have it indented properly


#6

Please read the FAQ and learn how to post your code so that is appears in the forum properly.
Then fix the code in your post, so that it is indented properly.

The palisade being an enemy forces you to control your soldiers, instead of just letting them run wild attacking whatever they see…


#7

I got it, thanks.

The palisade was changed to being one of your troops instead.


#8

Yeah. :frowning: I liked it better the other way, but being a friend makes it easier to tell when you have killed all the orges (if whole team is dead, you’re done, instead of if certain team members are dead…)


#9

I wish pailsides were neutral