Robot Grid Simulator's Doc

To write an algorithm, you need to do the following:

Setting the options

The options are set in the options tab, in a YAML format. The default options are:

walls: [[0,0,0], [6,6,6]], # the size of the grid
        # the size can be overwriten when creating initial configurations
visibilityRange: 1
chirality: true
seed: 0 # the default seed for the random generator
        # the seed can be overwriten when creating initial configurations
dimension: 3 # only 2 and 3 are supported
colors: # the rgb colros associated with the letters
    F: 0xff0000
    L: 0x00ff00
    A: 0x0000ff
    B: 0x00004f

Setting the initial configuration(s)

The initial configuration(s) are set in the Initial tab.

If you only want to set one initial configuration, each line correspond to a line of the grid, and each letter to a robot with the corresponding color. The next layer (with higher z) is created after two newlines.

Example:

.
..A
..XB

.
.
..C

In this example, the robot with state X has 3 neighbors: the robot with state A, the robot with state B, and the robot with state C, which is located ‘above’ it.

Declaring multiple initial configurations

You can declare multiple initial configurations as follows:

name-of-the-configuration:[sizeX, sizeY, sizeZ], randomSeed
.
..A
..XB

configuration-2:[sizeX2, sizeY2, sizeZ2], randomSeed2
.
..A
.....XB

where sizeX, sizeY, sizeZ, and randomSeed are integers representing the size of the grid and the seed of the random generator.

Writing rules

The rules are written in the Rules tab.

Rules are separated by a two newlines. Each rule is composed of a view and a destination, separated by a ->. In two dimension, the view is a visual representation of the neighborhood of the robot. In three dimension, it is similar, but starting with the layer above it, and going down to the last layer below it.

The destination is a direction, which can be left, right, front, back, above, below, or idle.

Example of a view in two dimension:

 A
.XB -> left
 .

Here, the robot with color X, seeing a robot with color A in front of it and a robot with color B on its right, will move to the left.

Example of a view in three dimension:

C
 A
.XB -> left
 .
.

This rule is executed if the robot X sees a robot A in front of it, a robot B on its right, and a robot C above it.

When the visibility range is 2, there are 5 layers, for instance:

.
 .
.C.
 .
  .
 .A.
..XB. -> left
 ...
  .
 .
...
 .
.

In this case, the robots sees the same robots as in the previous example, but but it also sees that there is no other robots at distance 2.

If the color the robot is modified, it is defined after the direction, separated by a ,. For instance:

 A
.XB -> left, Y
 .

Dealing with ambiguous rules

If the view is symmetric, the destination might be ambiguous. For instance, the following rule:

 A
.X. -> left
 A

Depending on the orientation of the view, the destination could be left or right. In this case, the simulator will complain and ask you to specify the destination. To solve this problem, you have to declare that the destination is ambiguous by specifying all the possible destination as follows:

 A
.X. -> [left,right]
 A

In the execution, a random destination is choosen. You can change the seed of the random generator in the options or when declaring the initial configurations.

Aliases

You can define aliases for the rules with the following command:

@alias A {C,D,E}

This means that when the letter A is used in a rule, the rule will be replaced by three rules where A is replaced by C, D and E.