JBotSim 1.0-beta has been released with some API changes. All examples have been updated accordingly. Please make sure you are using version 1.0 beta.

Basic movement and timing

This example illustrates how to:

Node algorithms are written by extending the class Node. In this example, we create such a class called MovingNode.

import jbotsim.Node;

public class MovingNode extends Node{
    public void onStart(){
    public void onClock(){

You can tell JBotSim to use this class as default:

public static void main(String[] args) {
    Topology tp = new Topology();
    new JViewer(tp);

Clock and Timing

Movement Specification

Movements can be specified in many ways. In this example, we set an initial direction; then the node moves by one unit in this direction in each round. Method move() could also take an argument, specifying the distance to be moved (equivalent to speed). Method wrapLocation() re-locates the node in a toroidal fashion when it gets out of bounds.