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

Can't figure out capture their flag

I don’t have any code I want to develop a strategy as I go. I don’t know who the level really works. I tried to do basic code like this.

while True:
    friends = hero.findFriends()
    friend = hero.findNearest(friends)
    flag = hero.findEnemyFlags()
    enemies = hero.findEnemyFlags()
    nearest = hero.findNearest(enemies)
    if nearest:
        hero.move(nearest.pos)
        if hero.distanceTo(nearest) <= 3:
            hero.captureFlag(flag)
            hero.moveXY(43, 60)
    if flag:
        hero.placeFlag(friend.pos)

I don’t understand why it does not work.

Your hero can only find flags when your hero is a certain distance from them. Then, your hero can only pick them up if they are even closer.

What is that range exactly. Whenever my hero moves he slides and ends up somewhere else.

I got the distance part set for how to capture it read this

So I moved to the middle but still I don’t do anything. Also how do you command your robo-walker.

Move close to the flags:
Screenshot 2021-01-23 at 5.22.19 PM
find the enemy flags, then bring them back.

so retrun nearest do that