Directed Kicker Bots

Agent Algorithm

A directed kicker agent chooses a visible ball at random and tries to "kick" it so that the ball will move in the the agent's goal direction. The agent calculates the spot on the ball it needs to hit to knock the ball in the right direction. If it senses that moving directly towards the target spot will result in kicking the ball in another direction, the agent accelerates around the agent (orthagonal to the vector towards the target spot) until it can hit the target spot.

Pseudocode

visibleBalls = {}
for all visibleObjects
   if visibleObject is ball
      visibleBalls <-- visibleObject
if visibleBalls is not empty
   ball = selectRandom(visibleBalls)
   targetVector = vectorToBallCenter - (ball.radius + agent.radius) * goalDirection
   if dotProduct(targetVector, vectorToBallCenter) > 0
      acceleration = targetVector
   else
      orthagonalToTarget = rotate(targetVector, 90°)
      if dotProduct(orthagonalToTarget, goalDirection) > 0
         orthagonalToTarget = -1 * orthagonalToTarget
      acceleration = orthagonalToTarget
else
   set acceleration to zero

Observed Behavior

The agents definitely do organize themselves on the correct sides of the ball, and depending on how many agents of which color are concentrating on a ball, the ball is moved in the goal direction of the team with the majority focused on that ball.

It seems, however, that the agents do a lot more "positioning to kick" than actual kicking. They all line up on their side of the ball and follow the ball around. This could be good for defense in a soccer-style game, but not aggressive enough for offense.

The Applet

If you see this, you need to either enable java, or install the Sun Java Virtual Machine in your browser. To do so, click here.

Source Code

Back to the Applet Bots Home
The official version of this file is at applet-bots.sourceforge.net