3 <title>Friendly Bots
</title>
4 <link rel=
"stylesheet" type=
"text/css" href=
"../styles.css"/>
9 <h3>Agent Algorithm
</h3>
11 A friendly agent looks at all the other agents he can see and
12 randomly selects one to be his friend. However, he can only make
13 another agent his friend if the other agent does not already have
14 the agent selected as his friend. The friendly agent then tries
15 to move toward his friend by accelerating towards him. The agent
16 remembers who his friend is and continues to accelerate towards
17 him as long as the friend remains visible. If the agent ever
18 loses sight of his friend he simply selects another one at random
19 given the selection criteria stated above. If ever a friend
20 cannot be found the agent accelerates in a random direction to
24 <div class=
"pseudocode">
25 <pre>if !haveFriend or friend not in visibleAgents
28 if visibleAgent.friend != me
29 availableFriends <-- visibleAgent
30 friend = selectRandom(availableFriends)
32 accelerate towards friend
34 accelerate in random direction
</pre>
36 <h3>Observed Behavior
</h3>
38 Since friendship cannot be mutual, there will never be agents
39 accelerating towards each other. An agent's friend will always be
40 trying to get to another agent (or moving about randomly searching
41 for a friend). What happens is kind of a
"love triangle"
42 phenomenon where agent A is accelerating towards agent B is
43 accelerating towards agent C is accelerating towards agent A.
44 When there is enough space for one of these chains they will spin
45 around in circles chasing one another. When the chains get bigger
46 they tend to look like a snake chasing after his tail with his
47 body getting in the way.
50 Note that if the Agent Sight setting is set too high they tend
51 to choose friends that are to far away and the
"friendship snakes"
52 can get knotted to the point where they can no longer move.
55 <applet archive=
"../dist/appletbots.jar"
56 code=
"appletbots.friendly.FriendlyApplet"
61 If you see this, you need to either enable java, or install the Sun Java
62 Virtual Machine in your browser. To do so,
63 <a href=
"http://java.sun.com/getjava/download.html">click here
</a>.
69 <a href=
"http://repo.or.cz/w/applet-bots.git?a=blob;f=src/appletbots/friendly/FriendlyApplet.java">FriendlyApplet.java
</a>
72 <a href=
"http://repo.or.cz/w/applet-bots.git?a=blob;f=src/appletbots/friendly/FriendlyAgent.java">FriendlyAgent.java
</a>
75 <a href=
"../" class=
"return">Back to the Applet Bots Home
</a>
77 <div class=
"official">
78 The official version of this file is at
<a href=
"http://applet-bots.sourceforge.net/applets/friendly.html">applet-bots.sourceforge.net
</a>
79 <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&type=1"/></a>