Any easy way to summon 1 archer for every 2 soldiers?

I have been doing this, but it is not as efficient:

def summon():
    if self.gold > 45:
        self.summon("soldier")
        self.summon("archer")

There are a few ways to do it.

  1. You could add 1 to a counter every time you summon a soldier and reset it when you summon an archer. (similar to decoy drill but resenting the count instead of break)

  2. You could use % and len(self.findFriends())

  3. There is a level in the mountain world that covers that exact topic. You could go play that.

1 Like

I confirm, there is a mountain level teaching you this, bu’t I can remember the name.
The idea is to:

#define a summon array
summonList=["soldier","archer","archer","paladin"]
#an a looping counther through the array
summonNext=0

Then in your summoning function you’ll try to summon from the summonList (pseudocode):

if enough gold to summon summonList[summonNext] :
     summon summonList[summonNext]
     #increment the counter looping back to 0 if it overpasses the array length
     summonNext=(summonNext+1) % len(summonList)
2 Likes

Yeah, that’s definitely the better way to do it.

My method will only work for 2 types. After that will become too complicated.