[SOLVED] Help, stuck with mixed unit tactics, in cloudrip mountain

it says there is an error
here is my code:
summonTypes =
def summonTroops():

type = summonTypes[len(hero.built) % len(summonTypes)]
if(hero.costOf(type) <= hero.gold):
    hero.summon(type)

def gatherCoins():
items = hero.findItems()
item = hero.findNearest(items)
if item:
hero.move(item.pos)
def commandTroops():
friends = hero.findFriends()
for i in range(len(friends)):
friend = friends[i]
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, “attack”, enemy)
while True:
summonTroops()
gatherCoins()
commandTroops()
plz help…

Hi @Peterpan an welcome to the forum! :partying_face:

Can you format your code as it is described below so we will be able to help you at this level?

Andrei

1 Like

how? I don’t see it…

Here is the link again:

Andrei

summonTypes =
def summonTroops():

type = summonTypes[len(hero.built) % len(summonTypes)]
if(hero.costOf(type) <= hero.gold):
    hero.summon(type)

def gatherCoins():
items = hero.findItems()
item = hero.findNearest(items)
if item:
hero.move(item.pos)
def commandTroops():
friends = hero.findFriends()
for i in range(len(friends)):
friend = friends[i]
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, “attack”, enemy)
while True:
summonTroops()
gatherCoins()
commandTroops()``

uhh…
didn’t work

summonTypes = []
def summonTroops():
    
    type = summonTypes[len(hero.built) % len(summonTypes)]
    if(hero.costOf(type) <= hero.gold):
        hero.summon(type)

def gatherCoins():
    items = hero.findItems()
    item = hero.findNearest(items)
    if item:
        hero.move(item.pos)
def commandTroops():
    friends = hero.findFriends()
    for i in range(len(friends)):
        friend = friends[i]
        enemy = friend.findNearestEnemy()
        if enemy:
            hero.command(friend, "attack", enemy)
while True:
    summonTroops()
    gatherCoins()
    commandTroops()
1 Like

ok I got it now …

Here put the types of units that you want to summon.

Andrei

still the same problem.

Can you show us your recent code?

Andrei

nvm, I think I got it

2 Likes

Then congratulations for completing the level! :partying_face:

Andrei

2 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.