StarLogo

Kybernetes

ISSN: 0368-492X

Article publication date: 1 March 2002

127

Keywords

Citation

(2002), "StarLogo", Kybernetes, Vol. 31 No. 2. https://doi.org/10.1108/k.2002.06731bad.001

Publisher

:

Emerald Group Publishing Limited

Copyright © 2002, MCB UP Limited


StarLogo

Developers: Mitchel Resnick et al.The Media Laboratory, Massachusetts Institute of Technology, Cambridge, Massachusetts, USA

Keywords: Simulation, Collective dynamic, Programming language, Simulation environment, Complex systems, Space-time dynamic

Abstract: StarLogo is a programming language and a simulation environment aimed to assist in building models of complex systems from simple elements. StarLogo's architecture of programming and methodology of simulation are briefly tackled in the paper.

To teach decentralised thinking about decentralised world. This was one of primary objectives in developing a language of concurrent programming – StarLogo (Resnick, 1990, 1991). To give non-experts a tool for interactive playing with and consequential understanding of complex systems was another goal (Resnick, 1994; Colella et al,2001). Both of the tasks successfully achieved. Kids and adults, zoologists and mathematicians, physicists and computers scientists, mostly driven by curiosity, are building in StarLogo their models of real-life phenomena.

A complex system usually consists of enormous amount of simple uniform entities acting in parallel by mere rules. Commonly all entities of the complex system looks similar and obey the same rules of local behaviour. Therefore to simulate a development of a complex system it is enough to formally describe reactions of one element and initial conditions. After that we start evolution and observe dynamic of spacetime pattems of the system. What are elementary programmable entities of StarLogo world?

Who inhabits StarLogo worlds?

The programmed modelling environment features three classes of objects: turtles, patches and an observer.

Turtles are mobile finite automata moving on a two-dimensional lattice. Each automaton has some implicit sensors and a pen. The turtles can detect changes in their local environment and change this environment by themselves. Mapping various parts of a real world onto the StarLogo environment we say that the turtles are molecules if we think about gas; they are cars if we want to simulate traffic; or they are species of preys and predators if we analyse population dynamic.

Essentially turtles live on a lattice. The lattice nodes are called patches. The patches can be coloured. Differently form turtles patches do not move. They are passive. Patches do not execute commands on their own. An observer issues orders to them. The observer is a Big Brother who initialises the virtual world, e.g. draws roads and sets up signals in case of traffic simulation, programs "passive" elements of the world and collects statistics about the world functioning.

StarLogo commands can be classified into three groups: commands attributed only to turtles, commands attributed only to observer, and commands attributed to both observer and turtles. Some illustrative commands are listed below.

  1. 1.

    Turtle commands:

    • motion/rotation/direction/homing/visibility commands (which are the "standard" ones), also using jump and leap command turtle can implement "teleportation" as well as "collision sensitive movement";

    • breed, color and age (return breed, color and age of the turtle);

    • count-frogs-here (returns the number of turtles of the breed frog sharing the same position with caller-turtle); count-turtles-here (returns number of turtles at the same position with the caller, or sitting on the caller-turtle's patch);

    • die (the turtle disappears forever); hatch (turtle makes exact copy of itself and ask the copy to run certain commands);

    • if breed=breed_name (checking the turtle breed, it would be better to attribute this command to observer); list-of-frogs-here (returns a list of frogs on the caller-turtle's position/node/patch); list-of-turtles-here (similarly to the previous command); one-of-frogs-here (returns a frog randomly chosen amongst the frogs on the caller-turtle's patch); one-of- turtles-here (similarly with the previous); commands reporting colors of patches neighbouring to the turtle, setbreed breed_name (set the turtle's breed);

    • stamp-towards angle distance (the turtle colours a path distance away and heading angle); pendown (the turtle draws as it moves, i.e. generate a trail).

  2. 2.

    Observer's commands

    • Ask-frogs, ask-patches, ask-turtles, ask-turtle index (order frogs, patches and turtles to execute list of commands); create-turtles-and- do list of commands;

    • diffuse variable percentage, diffuse4 variable percentage (extremely useful commands, they make each patch give 1/8 or 1/4 of percentage of its variable to its neighbouring patches; there is no other language that incorporate a diffusion primitive in its structure);

    • creation of global variables; working with files; auxiliary graphics; monitoring turtles;

    • local summation over patches, namely nsum varl vat2 and nsum4 varl vat2 take a sum of the variable varl from 8 or 4 neighbouring patches and put the sum in the variable vat2;

    • "colour contagion" from patches to turtles; scaling colours of patches, gradation.

  3. 3.

    Observer's and turtle's commands

    Arithmetical and logical operations; reporting ages and breeds of turtles, colours of patches at various positions and directions; reporting positions and headings of the turtles; asking turtles and patches to execute a list of commands; count number of turtles and patches (in)dependently of specified colour; plotting, processing information from input devices; setting colours to patches.

    I believe the list is enough to impress ignorants and to make creative readers appreciate potential power of StarLogo. To warm up their imagination I could remind you that turtles and patches act in parallel and sometimes even asynchronously. They execute their codes independently on each other. The asynchroneity is "so good" that one needs sometimes to synchronise the turtles or patches, when, e.g., runs a cellular automaton like simulation where central clocks are assumed.

What can be done in StarLogo?

Virtually anything. It is enough to look at the list of demonstration projects to appreciate the power of StarLogo. The projects include

  • collective building in social insects (bees and termits);

  • synchronisation of biological oscillators (flashing of fireflies);

  • simple population dynamic (rabbits and grass);

  • particle dynamic and space-time dynamic of reaction-diffusion

  • systems (a primitive instance of lattice chemistry);

  • simple traffic models;

  • pattern formation (aggregation of a slime mould);

  • spreading of diseases, dynamic of shopping, optimisation on graphs, and even volcanic activity.

To familiarise ourselves with the programming environment we modify an example taken from StarLogo distribution package. This example shows how a diffusion-limited aggregation can be simulated in StarLogo. Very roughly, a diffusion-limited aggregation happens when there is an immobile seed of several particles and a certain amount of mobile particles in a fixed volume. The mobile particles move at random. When a particle hits a stationary cluster, i.e. immobile particles, the particle stops moving. A specific of the diffusion process causes growing cluster of immobile particles to form weird branches. Eventually a fractal structure is produced (Figure 1).

Figure 1. A fractal cluster grown in StarLogo model of diffusion-limited aggregation

The observer's procedure defines some global variables and call set up routine of turtles:

'observer'globals [particles]

to setupcaset particles 0crt 25ask-turtles [place]end

So, the observer defines particles variable. This is used to colour the cluster in such a manner, that colours reflect the number of particles that joined the cluster. In observer's set up everything is cleared and turtles are called.

In the beginning, 25 created turtles set their coordinates at the center of simulation arena (setxy 0 0), they are headed in random directions (seth random 3 6 0) and translated in the chosen direction on a half-screen distance (fd screen-half-width). The turtles are hidden (ht) during the installation and they are visible again after taking their start positions (st). The relevant procedure is provided below:

to place set particles particles + 1 setc 15 + 10 * (round (particles / 500)) ht setxy 0 0 seth random 360 fd screen-half-width st seth random 360 end

Each turtle imitates a randomly moving particle. Therefore the turtle randomly deviates from its current heading (rt random l0 and lt random l0) and checks whether a patch ahead is unoccupied (output pc-ahead = black). If the patch is free the turtle moves forward. (fd 1):

to go ifelse free [fd 1] [place] endto free rt random 10 lt random 10 output pc-ahead = black end

Otherwise, the procedure place is executed, where the turtle colours itself and a patch beneath it with a colour derived from a cluster size: setc 15 + 10 * (round (particles / 500)). As you see programming of this physical phenomenon is quite straightforward.

Conclusion

The StarLogo occupies an original niche at the edge between parallel programming languages and discrete simulators of decentralised multicomponent systems. The software is impeccable for educational purposes. Children unconditionally love it. The language may also assist to "classical" biologists and sociologists in development of simulationoriented thinking (Batty, 1998).

It is also quite good for the Web: one can prepare a project to run on the web as a Java applet. As soon as StarLogo interpreter/compiler is written mostly in Java no encoding is necessary when exporting your projects as Java applets.

There are obvious short-term advantages in using StarLogo for fast design of model prototypes. However, even zoologists working in long term simulation ventures would rather prefer to write their own models in "standard" programming environment or to use specialised simulators with richer capabilities in data gathering, fitting, and prognostication.

Programming of robot collectives is yet another field, where StarLogo may flourish. This is particularly topical in a context of mass parallel robotic architectures, like, e.g., Joe Michael's shape-changing robots (Michael, 1996- 2000).

In any situation, it would be absolutely unfair to criticise StarLogo comparing it with more advanced simulators or programming languages. StarLogo represents rather proof-of-concept and a computer realisation of a discrete virtual world.

Distribution

The StarLogo, together with documentation and sample projects, is downloadable free of charge on its MIT site http://www.media.mit.edu/starlogo/ . Both PC's and Mac's versions are available.

Andrew Adamatzky Intelligent Autonomous Systems LabUniversity of the West of EnglandAndrew.Adamatzky@uwe.ac.uk

References

Batty M. (1998), Urban evolution on the desktop: simulation with the use of extended cellular automata. Environment and Planning A, vol. 30, pp. 1943-1967.

Colella V., Klopfer E. and Resnick M. (2001), Adventures in Modeling. Exploring Complex, Dynamic Systems with StarLogo. Teachers College Press, New York.

Michael J. (1996-2000), Fractal Robots http://www. stellar. demon. co. uk/

Resnick M. (1990), Animal simulations with Logo. In: Meyer, J.-A., Wilson, S.W. (Editors), From Animals to Animats, MIT Press.

Resnick M. (1991), MultiLogo: a study of children and concurrent programming. Interactive Learning Environments, vol. 1, pp. 153-70.

Resnick M. (1994), Turtles, Termites, and Traffic Jams. Explorations in Massively Parallel Microworlds. MIT Press (A Bradford Book).

Related articles