initial commit
[applet-bots.git] / applets / directedKicker.html
blob6e6f72515e44e8da6759b30473de09f4d21fa772
1 <html>
2 <head>
3 <title>Directed Kicker Bots</title>
4 <link rel="stylesheet" type="text/css" href="../styles.css"/>
5 </head>
6 <body>
7 <div id="content">
8 <h2>Directed Kicker Bots</h2>
9 <h3>Agent Algorithm</h3>
10 <p>
11 A directed kicker agent chooses a visible ball at random and
12 tries to "kick" it so that the ball will move in the the agent's
13 goal direction. The agent calculates the spot on the ball it
14 needs to hit to knock the ball in the right direction. If it
15 senses that moving directly towards the target spot will
16 result in kicking the ball in another direction, the agent
17 accelerates around the agent (orthagonal to the vector towards the
18 target spot) until it can hit the target spot.
19 </p>
20 <h4>Pseudocode</h4>
21 <div class="pseudocode">
22 <pre>visibleBalls = {}
23 for all visibleObjects
24 if visibleObject is ball
25 visibleBalls <-- visibleObject
26 if visibleBalls is not empty
27 ball = selectRandom(visibleBalls)
28 targetVector = vectorToBallCenter - (ball.radius + agent.radius) * goalDirection
29 if dotProduct(targetVector, vectorToBallCenter) > 0
30 acceleration = targetVector
31 else
32 orthagonalToTarget = rotate(targetVector, 90&deg;)
33 if dotProduct(orthagonalToTarget, goalDirection) > 0
34 orthagonalToTarget = -1 * orthagonalToTarget
35 acceleration = orthagonalToTarget
36 else
37 set acceleration to zero</pre>
38 </div>
39 <h3>Observed Behavior</h3>
40 <p>
41 The agents definitely do organize themselves on the correct
42 sides of the ball, and depending on how many agents of which color
43 are concentrating on a ball, the ball is moved in the goal
44 direction of the team with the majority focused on that ball.
45 </p>
46 <p>
47 It seems, however, that the agents do a lot more "positioning
48 to kick" than actual kicking. They all line up on their
49 side of the ball and follow the ball around. This could be good
50 for defense in a soccer-style game, but not aggressive enough for
51 offense.
52 </p>
53 <h3>The Applet</h3>
54 <applet archive="../dist/appletbots.jar"
55 code="appletbots.directedballs.DirectedBallsApplet"
56 alt="Directed Balls Applet"
57 width="600"
58 height="520">
59 <div>
60 If you see this, you need to either enable java, or install the Sun Java
61 Virtual Machine in your browser. To do so,
62 <a href="http://java.sun.com/getjava/download.html">click here</a>.
63 </div>
64 </applet>
65 <h3>Source Code</h3>
66 <ul>
67 <li>
68 <a href="../src/DirectedBallsApplet.java.html">DirectedBallsApplet.java</a>
69 </li>
70 <li>
71 <a href="../src/DirectedKicker.java.html">DirectedKicker.java</a>
72 </li>
73 </ul>
74 <a href="../" class="return">Back to the Applet Bots Home</a>
75 </div>
76 <div class="official">
77 The official version of this file is at <a href="http://applet-bots.sourceforge.net/applets/directedKicker.html">applet-bots.sourceforge.net</a>
78 <a href="http://sourceforge.net" class="sf-logo"><img border="0" alt="SourceForge.net Logo" src="http://sflogo.sourceforge.net/sflogo.php?group_id=205988&amp;type=1"/></a>
79 </div>
80 </body>
81 </html>