Skip to content

File (.nlogo) and Widget Format

Jeremy B edited this page Apr 27, 2018 · 2 revisions

Here you can find information on (.nlogo) file format and widget format.

File Format

This is an informal description of the .nlogo format.

The file format has changed and grown over the years. The version described here is the one used by NetLogo 5.x and by NetLogo Web. (NetLogo 5.x is forgiving about some deviations from this format, but the NetLogo Web model reader [from the NetLogo-Headless repo] is not.)

A conforming model file contains exactly 12 sections, separated by @#$#@#$#@ dividers.

The individual sections vary in format.

Code tab
@#$#@#$#@
Interface tab   
@#$#@#$#@
Info tab
@#$#@#$#@
turtle shapes
@#$#@#$#@
NetLogo version
@#$#@#$#@
preview commands
@#$#@#$#@
System Dynamics Modeler
@#$#@#$#@
BehaviorSpace
@#$#@#$#@
HubNet client
@#$#@#$#@
link shapes
@#$#@#$#@
model settings
@#$#@#$#@
DeltaTick

Code

This includes exactly the text that will appear in the Code tab.

Widgets

This includes all the information about what appears in the Interface tab. See Widget Format

Info

All of the text that goes in the Info tab. This tab uses markdown for display. The default is:

## WHAT IS IT?

(a general understanding of what the model is trying to show or explain)

## HOW IT WORKS

(what rules the agents use to create the overall behavior of the model)

## HOW TO USE IT

(how to use the model, including a description of each of the items in the Interface tab)

## THINGS TO NOTICE

(suggested things for the user to notice while running the model)

## THINGS TO TRY

(suggested things for the user to try to do (move sliders, switches, etc.) with the model)

## EXTENDING THE MODEL

(suggested things to add or change in the Code tab to make the model more complicated, detailed, accurate, etc.)

## NETLOGO FEATURES

(interesting or unusual features of NetLogo that the model uses, particularly in the Code tab; or where workarounds were needed for missing features)

## RELATED MODELS

(models in the NetLogo Models Library and elsewhere which are of related interest)

## CREDITS AND REFERENCES

(a reference to the model's URL on the web if it has one, as well as any other necessary credits, citations, and links)
...

Turtle shapes

Turtle shapes go here. If empty, netlogo provides with the default shapes. However, once you specify a shape, it includes them all.

name-of-shape
rotatable?
number of color (its order in the editor's chooser) that is changable in the shape

Then, any number of component pieces of the shape, in a line-by-line format that's something like:

shape-type color-as-int some-bools some-numbers

Version

NetLogo version this model was last saved in. Generally uses the form:

NetLogo <Major>.<Minor>.<Patch>

Preview commands

These are used to generate PNG-format preview images for the models library.

System dynamics modeler

The exact format comes from JHotDraw.

BehaviorSpace

BehaviorSpace experiment specifications, in XML format. (The DTD for the XML is in the Git repo somewhere.)

HubNet client

Widgets in the same format used for the Interface tab.

Link shapes

Like turtle shapes, but for links.

Model settings

Right now, just whether snap-to-grid is on, it looks like. More info needed here.

DeltaTick

relates to a now-abandoned experimental project. should be left empty.

Widget Format

A blank line separates widgets from each other.

The first line of the widget indicates the widget type.

The rest of the widget is fields separated by newlines (with the exception of pens, as below). Each line can be one of the following types:

  • Integer - Any positive or negative, though usually positive is needed
  • Double - Any positive or negative double floating point
  • Reserved - Used in the past, but no longer
  • Boolean
    • numeric - 1/0 == true/false
    • string - true/false == true/false
    • T/Nil - T/NIL == true/false
    • reverse - 0/1 = true/false
  • Set - List of valid inputs (Boolean could be seen as a specific form of this)
  • String - Any input available
    • All code is escaped (new lines get turned into \n)
    • When multiple strings appear on one line, they are quoted to allow spaces, in which case " characters are turned into "
  • Other - as specified below

View

The view includes settings for the 2D view, as well as some information about the underlying world.

GRAPHICS-WINDOW
Integer     // left
Integer     // top
Integer     // right
Integer     // bottom
Reserved    // USED TO BE: maxPxCor or -1
Reserved    // USED TO BE: maxPyCor or -1
Double      // patchsize
Reserved    // shapes on, not used
Integer     // font size
Reserved    // hex settings
Reserved    // and
Reserved    // exactDraw
Reserved    // not used
Boolean     // wrappingAllowedInX
Boolean     // wrappingAllowedInY
Reserved    // thin turtle pens!  Always on
Integer     // minPxcor
Integer     // maxPxcor
Integer     // minPycor
Integer     // maxPycor
0/1         // Update Mode, 0 = Continuous, 1 = Tick Based
Reserved    // Update Mode repeated
Boolean     // showTickCounter
String      // tick counter label
Double      // frame rate (defaults to 30)

Buttons

BUTTON
Integer       // left
Integer       // top
Integer       // right
Integer       // bottom
String        // display
String        // code to execute (collapse to be inline)
T/Nil Boolean // forever?
Reserved
Reserved
String        // buttonType
Reserved
String        // actionkey
Reserved
Reserved
Numeric Boolean // 1 means "always enable"; 0 means "disable until ticks start" (defaults to 1)

Plots

PLOT
Integer             // left
Integer             // top
Integer             // right
Integer             // bottom
String              // display
String              // xaxis
String              // yaxis
Double              // xmin
Double              // xmax
Double              // ymin
Double              // ymax
true/false Boolean  // autoploton
true/false Boolean  // legend on
String String       // Two quoted code lines, defaults to "" ""

Plot pens

Pens are made up of one line each with space separated values, the values are of the following types

  • display - quoted string
  • interval - double
  • mode - integer
  • color - integer
  • inLegend - boolean (true/false)
  • setupCode - quoted, escaped, string
  • updateCode - quoted, escaped, string
PENS
display interval mode color inLegend setupCode updateCode
display interval mode color inLegend setupCode updateCode
...

Text boxes

TEXTBOX
Integer  // left
Integer  // top
Integer  // right
Integer  // bottom
String   // display
Integer  // font size
Double   // color
Boolean  // transparent

Switches


SWITCH
Integer          // left
Integer          // top
Integer          // right
Integer          // bottom
String           // display
String           // varname
Inverted Boolean // on (1 is off, 0 is on)
Reserved
Reserved

Choosers

CHOOSER
Integer  // left
Integer  // top
Integer  // right
Integer  // bottom
String   // display
String   // varname
String   // choices as a list of logo objects
Integer  // current choice

Sliders

SLIDER
Integer  // left
Integer  // top
Integer  // right
Integer  // bottom
String   // display
String   // varname
String   // min
String   // max
Double   // default
String   // step
Reserved
String   // units
VERTICAl/HORIZONTAL // orientation

Monitors

MONITOR
Integer  // left
Integer  // top
Integer  // right
Integer  // bottom
String   // display
String   // source
Integer  // precision
Reserve
Integer  // font size

Output area

OUTPUT
Integer // left
Integer // top
Integer // right
Integer // bottom
Integer // font size

Input boxes

Valid input box types are "Number", "String", "String (reporter)", "String (command)", "Color" with values being of the types Double, String, String, String, Integer respectively

INPUTBOX
Integer   // left
Integer   // top
Integer   // right
Integer   // bottom
String    // varname
String    // value
Boolean   // multiline
Reserved
String    // inputboxtype
Clone this wiki locally