Please note: we use sxl-utils.nls (a small collection of utility procedures) in many of our models.
This should be placed in the same folder as any models that need it and loaded into the model using an include statement at the start of your model code...
__includes [ "sxl-utils.nls" ]
|general utils||a collection of small NetLogo utilities we use in many models|
|state transitions||a state transition engine for NetLogo|
|agent messaging||two solutions (i) an include file (ii) a NetLogo extension both of which allow NetLogo agents to exchange messages (updates, user guides and examples)|
|NLoops||a partial objects layer for NetLogo (a step towards NetLogo++) - user guides and examples|
|path finding||a NetLogo breadth first search, an A* search from one patch to another and other state space searches (search mechanisms, examples and utilities)|
|string extension||Netlogo extension for handling strings|
|independent JFrames||how to open independent JFrames from a Netlogo extension|
|sock1||a (simple) example using sockets communication between NetLogo and Java|
|sock2||another socket extension -- more developed than sock1|
For more NetLogo resources check the NetLogo site: ccl.northwestern.edu/netlogo.
To cite the work on these pages please quote the web address and use S.C.Lynch as the author name.
A .nls include file of small utilities we use in many models.
Get the .nls file here sxl-utils.nls
utils.nls includes the following...
|wiggle||-- turn randomly +/- 45 degrees|
|trigger p||-- probabilistically report true/false|
|nearest-of b||-- report nearest of breed b|
|mutate v m||-- modifies variable named v by +/- m|
|smooth-value||-- used in plotting smooth graph data|
|bounds lo x hi||-- return x bounded by lo & hi|
state transition engine
A .nls include file which allows you to specify agents as state transition devices.
state transition engine...
- get the .nls file here state-network(1f).nls
- user guide [pdf]
- agents collaboratively constructing a path - an example used elsewhere, now recoded into state machines stn-path(2d).nlogo
- a mine clearance example (inspired by 3APL's "Harry & Sally") agents collaboratively clear a mine field - this example has been used elsewhere but is now recoded into state machines stn-mine-clear(2d).nlogo this model also uses messaging.nls
- example stns(2b).nlogo -- a collection of simple examples
- state-transitions(2e).nlogo -- and some more
- multiple-stns-1b.nlogo -- using multiple transition networks
- multiple-timing-stns-1b.nlogo -- another multiple transition example
- interrupts-1b.nlogo -- interrupting transitions
- probabilistic transition-1b.nlogo -- probabilistic transitions
- turtle-death-state-1b.nlogo -- transitioning to death states
some other code examples...
nlboris is a netlogo extension which allows netlogo agents to communicate by sending each other messages, it also allows agents to communicate between NetLogo and other Boris agents.
We recently found that most users are only really interested in communicating between NetLogo agents running in the same NetLogo world so we have also built messaging.nls a simple messaging system for NetLogo agents which does not need an extension to be installed. messaging.nls provides the same kind of functionality as nlboris but only supports communication within a single NetLogo world (ie: it does not allow NetLogo agents to communicate with boris agents in other subsystems). See below for both nlboris and the smaller messaging system.
- the .nls file messaging.nls
- documentation reference guide
see also the nlboris tutorial for an explanation of some of the example models nlboris tutorial
mine-clear -- 1d(m2).nlogo
path -- 1a(m2).nlogo -- Ants (turtles) find paving slabs and use them to construct a path. Paving slabs come in three colors (red, green & blue) and are scattered around the world at the start. The path is constructed so that the paving slabs are placed in a strict sequence red then green then blue. Ants communicate to achieve this.
ant-food-s1a(m2).nlogo -- this model examines group behaviour and coordination based on messaging. Check the information provided with the model for more details.
NB: this model provides an example of writing move procedures (and others) based on a turtles status.
- the .jar extension nlboris.jar for NetLogo 4.x
- a new .jar extension nlboris.jar
tested with NetLogo5+
- all extensions are called "nlboris", take care not to mix them up, they are not compatible with other versions of NetLogo
- check here for a short tutorial nlboris tutorial
- documentation reference guide
- examples used in the tutorial
mine-clear -- 1d.nlogo
- path -- 1a.nlogo -- Ants (turtles) find paving slabs and use them to construct a path. Paving slabs come in three colors (red, green & blue) and are scattered around the world at the start. The path is constructed so that the paving slabs are placed in a strict sequence red then green then blue. Ants communicate to achieve this.
- ant-food-s1a.nlogo -- this model examines group behaviour and coordination based on messaging. It is a cut-down version of the larger scale model with a similar name (see below). The notes describe the behaviour in terms of foraging ants but the behaviour may also be applicable to fashions, viral messaging, memes, etc. Check the information provided with the model for more details.
-- a fuller version of the model above with a similar name.
This model examines group behaviour and coordination based on messaging.
Check the information provided with the model for more details.
NB: ant-food models above provide an example of writing move procedures (and others) based on a turtles status.
NLoops is a partial objects layer for NetLogo, it is written in NetLogo script (not as a Java extension) so it is used as a .nls include file.
We have a couple of versions of NLoops, if you don't need many features and want something which will easily integrate with existing NetLogo code start with NLoops-lite.
- NLoops (full version)
- for NetLogo-4 NLoops-4b.nls
- for NetLogo-5 NLoops-5.nls -- see here for notes about changes for the new version.
- a short tutorial: NLoops tutorial
- brief reference guide
- examples used in the tutorial
for NetLogo-4: example 4.1 example 4.2 example 4.3
for NetLogo-5: example 5.1 example 5.2 example 5.3 example 5.4
(last example demonstrates NLoops5 used with patches)
- search routines & utilities
- check breadth-search(1a).nlogo for a generalised search routine and an example based on a numbers puzzle, read the info tab for an explanation.
- check also breadth-search(1a)-eg2.nlogo for a second example based on a word transformation problem, as before read the info tab for details.
- to help set up an environment with hills/cost gradients for other types of search see hill-diffusion.nlogo
- see maze(1b).nls for an include file to draw mazes and maze-test(1a).nlogo for a simple model which demonstrates the maze drawing.
- see also patch-to-patch-search(1a).nls for an include file containing a search mechanism to find a path from one patch to another and maze-search-test(1a).nlogo for a simple model which demonstrates the use of the patch-to-patch search.
- some example implementations of search (now upgraded to netlogo 5)
- patches - no obstacles search operating on a blank background of patches. ie: no obstacles, no costs
- patches with obstacles as the previous versions but patches may be marked as "walls" which act as barriers for search paths
- patches with costs this model allows patches to be given costs and implements a best first search
- walk a marked path
this model allows patches to marked as being part of a path and uses a breadth first search
to find a route on the path from a start patch to a goal patch. It looks like this...
- maze traversal
-- this model was developed after a Programming Interest Group competition.
There is a partial maze environment containing pigs (lost and need rescuing), pig stys and
golf carts (mobile agents that find pigs and return them to a sty). The controller for golf-carts
(or maybe they are shopping trollys) is based on search. For more details check the info
tab on the model. It looks like this...
an example of a simple socket extension for NetLogo which allows netlogo to communicate with other (Java) applications via a socket.
- netlogo socket example.pdf -- a v.brief overview outlining how to use the example
- sock1.zip -- a zipped bundle containing the extension jar and the source files used to build it
The sock2 extension which we now use in preference to sock1
this is used for most of our socket-based communication between Netlogo & Clojure and Netlogo & Java.
- example - an outline & example
- sock2.zip - all relevant files (examples, Netlogo, Java & Clojure stubs, etc)
- see also Linking Netlogo to Clojure
For more complex models & extensions you may want to have some kind of dialog with users or pass them information. This example opens a JFrame from a Java extension. The JFrame allows users to communicate with a NetLogo model. Note that you can also use this kind of approach to output debuggging information from your extensions.
The extension and a sample model is wrapped up in test.zip which you should unpack into an extension folder called "test". The (v.simple) example model to demonstrate the idea is called "test.nlogo" and is also contained in test.zip. NB: the extension will run on NetLogo5 (not on earlier versions).
(see above for nlboris, NLoops, etc)
-- this provides a link to some basic Java.String methods (replace, split, trim, etc). For a full list see string extension Javadoc