Table of Contents
This example shows the following features:
Moving between habitats.
Getting statistics of the habitat.
The source can be found in src/tryllian/scenarios/chat2. It contains the following files:
| ChatTask.java (The task which sends chat messages) |
| ChatterAgent2.java (The agent) |
| ChatterGenerator.java (Interface for generating chatter texts) |
| SimpleChatterGenerator.java (Implementation of the interface for generating chatter texts) |
| CreateCopiesTask.java (The task which handles the cloning) |
| GoPlacesTask.java (The task which moves the agent to other places) |
| PlacesFileReader.java (Read the place2go.txt file to get the locations where the agents should move) |
| ReplyToChatterTask.java (The task which receives chat messages and chats back) |
| StartChattingTask.java (Task which starts a chat) |
To build the example, type in the scenarios directory :
build chat2
To run the example, type:
habitat chat2.xml
These agents will chat and move. They obtain the list of habitats.
In this demo, a separate file is used to describe the places for agents. Reading the file is the same in java without using agents. Look in the PlacesFileReader.java class to see how it is done.
The agents in this example move using tryllian.afc.task.standard.MoveTask. Look at GoPlacesTask.java.
To make the demo work in a network, first install ADK on another computer in the network. Start a habitat on all hosts except one. As an example, start a nearly empty habitat with the following:
habitat helloworld.xml
Start the chat agent demo by calling
habitat chat2.xml
The agents will now try to go to the habitat running on the host jolly. After modifying the places2go.txt file, start the habitat and watch the agents move to the other habitat.
Tip: To create more chat agents, add some extra "agent" tags to chat2.xml, or use the extra argument to specify the number of extra agents wanted.