Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Mixed Unit Tactics

#21

My hero doesnt even walk around to collect gold or summon troops

#22

This is my new code on line 2 it says reference error summontypes is not defined

This is telling you that you are referencing (reference error) a variable that isn’t defined (is not defined). The specific variable you are referencing which is undefined is: summonTypes.

type=summonTypes[len(self.built) % len(summonTypes)]

You need to define summonTypes before manipulating it.

#23

ok i must have forgot to do so

#24

I fixed my code here it is

def summonTypes():
    type=summonTypes[len(self.built) % len(summonTypes)]
def summonTroops():    
    if self.gold >= self.costOf('soldier'):
        self.summon('soldier')
def commandTroops():
    friends=self.findFriends()
    for friend in friends != 'palisade':
        enemies=self.findEnemies()
        enemy=soldier.findNearestEnemy()
        self.command(friend, "attack", enemy)
def collectCoins():
    coin=self.findNearest(self.findItems())
    self.move(coin.pos)
loop:
    summonTypes()
    summonTroops()
    commandTroops()
    collectCoins()
#25

My troops dont even attack my hero is summoning them but they dont attack

#26

nvm i beat it i just collected 300 gold