Jaak: When Janus Agents become Turtles

Jaak Logo

Jaak is a reactive agent execution tool that runs on the synchronous engine of Janus. It provides a discrete 2D environment model and a simplified interaction model based on LOGO-like primitives. Its purpose is similar to NetLogo, StarLogo, and TurtleKit.

Jaak relies on a logo-based simulation model. Unlike StarLogo or NetLogo, Jaak proposes a Logo programming approach while giving all the possibilities afforded by high level programming languages such as Java and Ruby.

Jaak is particularly well suited for modeling complex systems developing over time. Modelers can give instructions to hundreds or thousands of "agents" all operating independently. This makes it possible to explore the connection between the micro-level behavior of individuals and the macro-level patterns that emerge from the interaction of many individuals.

Jaak lets students open simulations and "play" with them, exploring their behavior under various conditions. It is also an authoring environment which enables students, teachers, and junior and senior developers to create their own models.

Lecture Slides on Jaak are available on the teaching document section.



Our primary goal when developing Jaak is to provide a simple but powerful library to develop situated multi-agent simulations. Additionally Jaak permits to test the Janus modules on a more complex system than the already provided demos.

The aims of the Janus/Jaak pair is to fill the gap between the easy-to-use platforms, eg. TinyMAS, NetLogo, StarLogo), and the advanced simulation platforms, eg. Swarm.

From Logo to Jaak

Logo is a reflexive and functional programming language from the Massachusetts Institute of Technology (MIT). In the 21st century, Logo is mainly known for its famous graphical turtle, even if it is able to use lists, files and several inputs/outputs. It is well suited for teaching, especially algorithmics.

Powerful language, Logo was paradoxically victim of his turtle which confined to a childish image. It was a good introduction to structured and modular programming, and artificial intelligence. But in Jaak only a part of the turtle's features has been exhibited. The Java language primitives are preferred to support the rest of the Logo primitives.

In Jaak a Turtle in an situated Agent which is able to move on a 2D discrete grid.

Motion Primitives

The supported motion primitives are listed in Table 1. Descriptions are given in the Jaak context, not in Logo context.

Table 1: Mapping between Logo and Jaak Concepts
Definition Logo Primitive Jaak Function
Turtle moves forward by n cells. FD n or Forward n moveForward
Turtle moves backward by n cells. BK n or Back n moveBackward
Turtle turns about n degree on the right. RT n or RIGHT n turnRight
Turtle turns about n degree on the left. LT n or LEFT n turnLeft
Turtle peeks something from the grid cell. PU or PENUP pickUp
Turtle puts something on the grid cell. PD or PENDOWN dropOff
Set the direction of the turtle to an angle of n degree on a trigonometric circle. SETH n or SETHEADING n setHeading
Turtle moves on the given direction by n cells, without turning itself. move

Environment Model

Jaak provides an environment model defined by a discrete 2D grid with a finite number of cells. This grid is close or wrapped according to design choice:

  • Closed Environment: when turtles try to go outside the grid, their actions are ignored.
  • Wrapped Environment: when turtles try to go outside the grid, they arrive in the opposite side of the grid.

Each cell may contains:

  • zero or one turtle
  • a collection of data put and peek by turtles

Environment model owns an endogenous engine which permits to evolve environment state according to internal laws. These laws are not managed by turtles.

Turtle perceives on the grid and emits influences to it. The agent-environment interaction mechanism used in Jaak is the Influence-Reaction model, which may be illustrated by the following algorithm:

while (true) {
    influences = new ArrayList();
    // Compute all the turtle perceptions
    // from the same grid state
    // Run turtles and collect influences
    for(Turtle turtle : getAllTurtles()) {
    // Run endogenous engine and retreive influences
    // produced by internal environment mechanisms
    // Solve conflicts between influences and
    // produce resulting reactions
    reactions = environment.solveConflicts(influences);
    // Update the state of the grid

This mechanism permits to solve two problems of synchronous execution of agents:

  1. execution order of agents is no more significant because all agents are perceiving the same environment state;
  2. agents actions are supposed to act at the same time, so that simultaneous actions are now possible, and potential conflicts are solved.


Turtle is able to perceive the states of the cells around the cell on which it is located. Perception distance is given by designers.

All turtles perceive the same state at the same time. It is due to the Janus synchronous execution engine based on the Influence-Reaction approach.

Influence Gathering

A turtle action may be a movement or a cell content update. Each turtle runs its live function to decide what to do. They save there decisions in the form of influences. An influence is a "desire of action": it contains the same information content as an action, but it is not directly applied on the environment grid.

Endogenous Engine

The endogenous engine computes evolutions of the environment state outside the control of the turtles. For example, in a ant-colony simulation, pheromones evaporate. It is the role of the endogenous engine to apply such evaporation.

To avoid potential conflict with turtle's actions, the endogenous engine is not able to directly update the state of the grid. In instar turtles, endogenous engine provides influences. This feature is taken from the JaSIM environment model.

Influence Conflict Detection and Solving

When all influences are collected, conflicts between them should be detected and solved. Unfortunately, there is not a general algorithm to provide such a feature. Conflict detection and solving are application-dependent.

The influence solver has the role to transform influences into reactions. Reaction is an update primitive for the environment grid. It could be one of:

  • turtle move from cell to cell;
  • turtle turn around;
  • data put inside cell;
  • data removal outside cell;
  • data update in cell.


Jaak library is available on the global download page: Download Jaak daily builds and stable releases

API Documentation

The API documentation of Jakk is included in the API document of the Janus platform.

Other Environmental Extensions

2016-01-24SARL 0.3.1 and Janus are available.
2015-11-30SARL 0.3.0 and Janus are available.
This page was last modified on 24 August 2012, at 16:29. This page has been accessed 19,390 times.
Copyright 2010-2017 © Janus Core Developers - Privacy policy