You’ll find the NetLogo Manual to be useful.

Download NetLogo 5.0.4 (Windows, Linux, OS X)


Building the “ant brood sorting” model

The model is described in the Ant intelligence notes.

NetLogo code


Each turtle will have a seen variable that will be a list.

Each patch will have a barrier? variable that will be true or false depending on whether the patch is a barrier.

The “setup” button will run this procedure. First, the NetLogo procedure clear-all clears the screen. Then, the setup-patches and setup-turtles procedures (which we’ll create) are executed.

The patches will have colors or be black if they are blank space. The probability of being some color or black depends on sliders. All patches by default are not barriers.

Now we set up the turtles (ants):

The “go” button moves each ant around the space, avoiding barriers (how to draw barriers is described below). An ant may choose to pickup or drop a colored object if appropriate. But first we “look” by updating the ant’s “seen” list.

This is how the ant “looks” (note that the memory-size variable is set by a slider):

The ant may choose to “pickup” an object. Picking up an object actually just turns the patch to black, and turns the ant to the color that it “picked up.”

Dropping is the opposite:

Now we just need to make the ant move:

The “make-barrier” and “remove-barrier” buttons on the interface call these two procedures. These procedures figure out where you click your mouse and set the barrier? variable to true/false on those patches (and turn them white/black):

AI Su13 material by Joshua Eckroth is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Source code for this website available at GitHub.