hero.requestGoalkeeperHelp(python)

Why did my peasants kick the ball into the goal?
Screenshot 2021-03-23 at 11.50.06

balls = hero.findByType("ball")
defendPoints = [{"x": 30, "y": 40}, {"x": 30, "y": 30}]
while True:
    peasants = hero.findByType("peasant")
    index = 0
    dIndex = 1
    b = 0
    ball = balls[b]
    defendP = defendPoints[dIndex]
    peasant = peasants[index]
    for peasant in hero.findByType("peasant"):
        hero.command(peasant, "move", defendP)
        dIndex += 1
        if peasant.distanceTo(ball) <= 5:
            hero.command(peasant, "move", {"x": ball.pos.x, "y": ball.pos.y})
        index += 1

Could you send me a link?
Lydia

Well, the ball bounces off everything, so if it touches your peasants, it might end up ricocheting into your owl goal. Have your peasant guard only the entrance, so they can easily block the ball, and there is a lower chance of it going in.

No, my peasants actually kicked it into the goal.

I am guessing that the ball was closer to the goal than them, so they went back and knocked the ball into the goal?

It may have to do with the fact that peasants can’t defend.

Yep. Don’t command them to move out of the crease. Only command them to move up and down. If they go out, then they won’t defend, all they can do is bump the balls. They can’t actually control the ball.

Is there a bug here? (It got me the bonus :slightly_smiling_face:)
Screenshot 2021-03-24 at 14.11.24

I guess that this code causes three options.

  1. I get destroyed by the ogres.
  2. I watch a bug and get bonus.
  3. HILARIOUS INFINITE LOOP :joy:
    Screenshot 2021-03-24 at 14.14.53

Hilarious infinite loop time yay.