Do you know any good strategy for Brawls?


#1

This is my code for Anya in Cloudrip Brawl, I ran out of ideas to pass the level


def coins():
    coin = self.findNearest(self.findItems())
    if coin:
        self.move(coin.pos)

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

def flag():
    flag = self.findFlag("green")
    if flag:
        self.pickUpFlag(flag)
        
def command():
    for friend in self.findFriends():
        enemy = self.findNearest(self.findEnemies())
        if enemy:
            self.command(friend, "attack", enemy)
            

            
def headhunter():
    for enemy in self.findEnemies():
        if enemy and enemy.type == "headhunter":
            if self.isReady("bash"):
                self.bash(enemy)
            elif self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)
def warlock():
    for enemy in self.findEnemies():
        if enemy and enemy.type == "warlock":
            if self.isReady("bash"):
                self.bash(enemy)
            elif self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)

loop:  
    coins()
    summon()
    command()
    headhunter()
    warlock()
    flag()
    self.attack(enemy)

#2

Click on the brawl level, look at the high scores, and spectate the high scoring players. Learn their strategy
The top 5 scores are private (so if you want the best strategy you’ll need to find it yourself).

===========================================

When you command troops it does not take time but when you command the hero it takes. Because of this you want to command your hero only once per loop, so you can order your troops as much as possible. Make each hero command function return true if the hero got busy, or false if it is still idle.

Example: pickCoin will return false if there are no coins to pick or if the enemies are too near, summonTroop will return false if there is no gold to summon, etc.

loop{
# update enemies list
# update allies list
# update items list
# command troops once per loop
commandTroops(allies,enemies)

# command hero once per loop
if( self.pickUpCoin(items,enemies)) continue;
if(self.summonTroop(summonList)) continue;
if (self.bashHeadhunters(enemies)) contine;
self.heroAttack(enemies)
}

#3

I didn’t understand, I haven’t seen those functions yet and I don’t know what you mean with “take time”


#4
  1. There are your own functions, that you declare with def. I am just putting different names to make it clear what they do. Here is your own summing function that you call just “summon” instead “summonTroop”. The name is not important:
def summon():
    if self.gold > self.costOf("soldier"):
        self.summon("soldier")
  1. Every thing the hero does in the game takes time. Moving takes time, attacking takes time, bashing takes time …

Otherwise you can just put 3 attacks in the same loop:

loop{
enemy=self.findNearesEnemy()
self.attack(enemy)
enemy=self.findNearesEnemy()
self.attack(enemy)
enemy=self.findNearesEnemy()
self.attack(enemy)
}

Wow! I just put 3 attacks in the same loop so my hero should attack 3 times faster. It will kill everyone 3 times quicker.
Well, it does not work this way. Each attack basically says: I am busy for this amount of time, so all you enemies feel free to keep attacking me until I finish what I am doing now.


#6

This is my best strategy for Cloudrip Brawl.

Moderator Edit: Please don’t give correct code.

I hope this code help you.


#7

Please do not give away working code or revive dead threads. :slight_smile:
(Nice strategy though)