MaDKit forum

Welcome All !
Please, use explicit topic names when creating new threads. Thanks.

You are not logged in.

#1 TurtleKit questions (how to) » Termite colony simulator using java? » 2012-11-14 10:17:01

Replies: 1

: JAVABUG: A termite colony simulator
1. Introduction
The aim of this assignment is to design, implement and test a Java simulator that could be used
for artificial life research. Specifically, an application is required that will allow investigation of
the global behaviour that emerges in an environment where simulated termites and predators
act according to simple local rules. The main tasks for this project are:
1. To design an object oriented model of the structure and the behaviour of the simulation
using UML diagrams;
2. To implement your design in Java.
You should aim to spend between 10 and 15 hours working on this assignment.
2. Requirements
Your simulator will maintain an environment, which consists of a collection of patches arranged
in a rectangular grid of arbitrary size (Figure 1). Each patch contains zero or more wood chips.
A patch may be occupied by one or more termites or predators, which are mobile entities that
live within the world and behave according to simple rules.
A termite can pick up a wood chip from the patch that it is currently on, or drop a wood chip
that it is carrying. Termites travel around the grid by moving randomly from their current patch
to a neighbouring patch, in one of four possible directions (Figure 2). Termites can only move
within the boundary of the environment. New termites may hatch from eggs, and this is
simulated by the appearance of a new termite at a random patch within the environment.
A predator moves in a similar way to termites, and if a predator moves onto a patch that is
occupied by a termite, then the predator eats the termite.
To initialise a simulation, the user specifies the following parameters either on the command
line, or in a simple text file which is read by the program:
 The size of the environment, which is an (n × m) integer number of patches.
 The number of predators and wood chips.
 The initial number of termites.
 The probability that a new termite will hatch from an egg at each timestep or iteration of
the model. Thus if this value is 0.1, then on average we would expect a new termite to
hatch every 10 timesteps.
Richard Clayton - 2 – Last updated 11-Nov-10
Figure 3: text
display of the
environment shown in
Figure 1.
At initialization, the termites, predators, and wood chips are distributed randomly in the environment. Simulation then proceeds in a loop, and the new state of the environment is obtained at each iteration. Typically, several thousand iterations will be required before interesting behaviour emerges. The new state of the environment is obtained by updating each termite and predator in turn (for simplicity, we assume that the behaviour of the termites is serialized in this implementation rather than using a separate thread for each termite).
When each termite is updated, it obeys the following behavioural rules:
1. Move in a random direction to another patch.
2. If the termite enters a patch containing any wood chips and the termite is not carrying a chip, it picks up the chip.
3. If the termite enters a patch containing any wood chips and the termite is already carrying a chip, it drops the chip.
When each predator is updated, it obeys the following behavioural rules:
1. Move in a random direction to another patch.
2. If the destination patch contains a termite, then the termite is eaten and if the termite is carrying a wood chip then the wood chip remains on the patch.
At each iteration, new termites may hatch, and the probability of a new termite hatching in each iteration is a specified parameter. If a new termite does hatch, then it is placed on a randomly chosen patch.
The state of the grid is observed on a display. It should be possible for the user to choose whether the display is a simple text-based output on the command widow or terminal, or is graphical. A graphical display could take a number of forms, e.g. an image in which the state of each patch in the grid is mapped to pixel colour, or an image in which each termite and wood chip is drawn. In general, for each patch, the display could illustrate whether it contains any termites, whether any of those termites is carrying a wood chip, and the number of wood chips on the patch. Figure 3 shows a text display corresponding to the environment shown in Figure 1, in which the number of wood chips is shown as an integer, termites carrying wood chips are marked with a ‘*’ and termites carrying nothing are marked with an ‘X’. Empty patches are marked with a dot. You can see that since only one character can be displayed in a cell, the ‘highest ranking’ information for a cell is displayed, e.g. if a cell contains termites carrying a wood chip and termites not carrying a wood chip and wood chips, the only thing displayed is an *.
Certain constraints have been placed

Board footer