Ace Of Coders Tips?

and it also isnt attacking wher it should be its attackign the nearest enemy again im literally so confused

oh nvm this it was cuz i was dumb

sorry for annoyance again but this code

    friends = hero.findFriends()
    a = hero.findNearest(hero.findByType("artillery",friends))
    hero.command(a, "move", {"x":30, "y":26})
    if a:
        hero.command(a, "attackPos", {"x":106, "y":46})
        hero.command(a, "attackPos", {"x":63, "y":93})

th artillery should be firing one postition then firing the other one but it only fires one instead?

It’s a known thing, a friend can’t do 2 commands in a row.

oh that means im stupid then i need to think of another method to fire one after the other then

You are not stupid, you are learning. :slightly_smiling_face:

2 Likes

thanks also if your wondering this is all my code

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

hero.summon("artillery")


def commandArmy():
    friends = self.built
    enemies = self.findEnemies()
    points = self.getControlPoints()
    for i, friend in enumerate(friends):
        point = points[i % len(points)]
        if self.now() < 30:
            self.command(friend, "defend", point.pos)
        else:
            enemies = self.findEnemies()
            nearestEnemy = self.findNearest(enemies)
            self.command(friend, "attack", nearestEnemy)

def controlHero():
    friends = hero.findFriends()
    a = hero.findNearest(hero.findByType("artillery",friends))
    hero.command(a, "move", {"x":30, "y":26})
    if a:
        hero.command(a, "attackPos", {"x":106, "y":46})
        hero.command(a, "attackPos", {"x":63, "y":93})
    hero.moveXY(57, 44)
    


while True:
    buildArmy()
    commandArmy()
    controlHero()
1 Like

i havent worked on contrl points yet i will get to that

AND THE CODES BROKEN AGAIN

    friends = hero.findFriends()
    a = hero.findNearest(hero.findByType("artillery",friends))
    hero.command(a, "move", {"x":28, "y":24})
    if a:
        hero.command(a, "attackPos", {"x":106, "y":46})
    hero.moveXY(57, 44)

That is because you are again commanding two things in a row and for the first command you don’t check artillery’s existance.

oh…3. 20 charsssssssssssssssss

also hwo do i do two commands at once

You can’t do that I think. You can use something like “wait” between two commands but it’s not really effective.

ill try to do that but what do you exactly mean by not very effective is it inconsisitent or does it not work sometimes

Well, if your hero waits for some time, your enemies can do something bad to you.

ohhh so thye can attack m while i wait

also waht is the command for taht? i tried hero.wait(1)

The command is hero.wait, yes.

weird it didnt work 20 charssssssss

Is this strategy better?

def buildArmy():
    #buildOrder = ["archer"]
    #type = buildOrder[len(self.built) % len(buildOrder)]
    # update needed
    if self.gold >= self.costOf("archer"):
        hero.buildXY("archer", hero.pos.x + 2, hero.pos.y +3)

def commandArmy():
    
    #update needed
    
    friends = self.built
    enemies = self.findEnemies()
    points = self.getControlPoints()
    points2 = self.getControlPointsMap()
    for i, friend in enumerate(friends):
        point = points[i % len(points)]
        points = self.getControlPoints()
        friends = self.findFriends()
        for i in range(len(friends)):
            self.command(friends[i], "defend", points[i % len(points)].pos)

def controlTower():
    friends = hero.findFriends()
    a = hero.findNearest(hero.findByType("artillery",friends))
    #hero.command(a, "attackPos", {"x":106, "y":48})
    if a:
        hero.command(a, "move", {"x":a.pos.x+5, "y":a.pos.y+5})

def controlHero(): 
    enemy = hero.findNearestEnemy()
    pointsMap = hero.getControlPointsMap()
    center = pointsMap['center']
    enemy_artillery = hero.findNearest(hero.findByType("artillery",hero.findEnemies()))
    if hero.distanceTo(center.pos) > 12:
        hero.moveXY(57, 46)
    else:
        # consider update
        hero.buildXY("arrow-tower", hero.pos.x-5, hero.pos.y-5)
    if hero.isReady("throw"):
        if enemy_artillery :
            hero.throw(enemy_artillery)
        else:
            nearest = hero.findNearest(hero.findByType("goliath"),hero.findEnemies())
            if nearest:
                hero.throw(nearest)
    
    if enemy:
        hero.attack(enemy)
    if hero.isReady("stomp"):
        hero.stomp()

def earlygame():
    points = hero.getControlPoints()
    
    #archer
    for i in range(4):
        hero.buildXY("archer", hero.pos.x+2,hero.pos.y+2)
    friends = hero.built
    for index,friend in enumerate(friends):
        point = points[index]
        hero.command(friend, "defend", point.pos)
    # tower
    enemys = hero.findEnemies()
    hero.buildXY("artillery", hero.pos.x-5, hero.pos.y-5)
    

while True:
    if hero.time < 1:
        earlygame()
    else:
        buildArmy()
        commandArmy()
        controlHero()
        controlTower()



just finished devoleoping the early game