Table of Contents
The following chapter describes how to run agent examples provided by Tryllian. Some of these examples are found within the Quickstart and Developer Guides and demonstrate the following agent behavior: sending an agent on a mission; creating, sending and receiving a message; and returning an agent home and finding other agents. This chapter provides some introductory information on how to start up these examples.
Be sure to have Java 1.3 installed on all computers used. The Java Runtime Environment is sufficient (JRE 1.3) as well. The Java Development Kit (JDK 1.3) is necessary for modifying code examples and recompiling. The ADK does not work with JDK 1.4 or up.
All of the examples are started in a similar manner. The HelloWorld example is used to show how to do this. To start this example, go to the bin sub-directory of your ADK root directory and enter:
habitat ..\examples\hello\helloworld.xml [DOS]
./habitat.sh ../examples/hello/helloworld.xml [Unix]
The examples do not stop by themselves, you'll have to press Control-C to stop them. For the other examples, change helloworld.xml to the desired XML file.
If you want to experiment with making modifications to existing code, this is most easily done using the scenarios from chapter 3. The scenarios folder is self-contained so no additional steps need to be taken to be able to rebuild the modified agent source code.
The best way to demonstrate recompiling the examples from this chapter is to use the Agent Template. Here is the step-by-step procedure, using the helloworld example:
Remove or rename the src directory within the agent-template directory.
Copy the src directory of your example to the agent-template directory.
Create a descriptor.xml by either using the one included in the existing hello.dna or by using example.descriptor.xml as a template.
Edit build.xml and modify agent.jar in hello.jar, example.dna in hello.dna and example.descriptor.xml in descriptor.xml.
Execute build to create your agent.
Edit exampleHabitat.xml and replace example.dna with hello.dna.
Run the example by executing the habitat exampleHabitat.xml.
The following list provides a brief overview and description of the examples provided with the ADK software in the examples directory.
| Name | Description |
|---|---|
| Hello | A basic "hello, world!" example agent. |
| Message | A basic agent communication example. Two agents communicate, one sending and the other receiving a single message. |
| Guesser | Another communication example. Two agents exchange messages; one tries to find a number randomly chosen by the other. Described further in the Developer Guide. |
| Remotemessaging | An example using remote messaging. Two agents on different computers can 'chat' - exchange messages that users type in. |
| Move | This agent will move to another habitat and perform a task in that habitat. |
| Move2 | Similar to "Move" but uses the TaskScheduler to schedule the tasks. |
| Move3 | Similar to "Move" but uses the MoveListener to detect that the agent has moved. |
| ReturnHome | Again, similar to "Move". Here, the task performed in the remote habitat is passed as a parameter and the agent returns to the home location after performing the task. |
| Iterator | An agent that uses a standard task, the IteratorTask. |
| FileTransfer | Distribute files by sending them to another agent. |
| Languages | An agent finds other agents in the habitat and prints language information obtained from these agents. Described further in the Developer Guide. |
| GUI | An agent will show a user interface. You can perform several actions with your user interface like suspend or terminate your agent. You can also move your agent to another habitat with an optional file attached. This example makes use of the SwingAgentBridge. |