-
-
Notifications
You must be signed in to change notification settings - Fork 266
Unofficial features
These features are not officially supported. They are (mostly) not in the User Manual and they may not continue to exist or work in future versions of NetLogo. If any of these are important to your work, stay in touch with the devel team about their status.
- You can quickly open any model in the Models Library by typing a name, or a part of its name, into the Command Center, preceded by three underscores. For example, to open Flocking, you might type
___flock -
__reloadwill reload the current model from disk -
__pwdwill print the working directory -
__check-syntax <string>reports a string result indicating whether was successfully parsed as a NetLogo statement. Either the result is the empty string "", indicating that string will not result in a compiler error if immediately passed to run, or it is an error message indicating the compile error that occurred. -
__set-line-thicknesssets the thickness of lines in the shape ( if any are contained in the turtles current shape). it takes a double measured in patches. So 1.0 means one patch wide, zero will always be 1 pixel wide regardless of patch size. (This one is actually in the User Manual.) -
__export-drawingexports only the drawing layer to an image file
HubNet can control plots specific to each client:
-
__hubnet-make-plot-narrowcast <plotname>designates a plot as narrowcast.
Both the model and the client should have a plot named plotname. The plot can then be controlled with the following narrowcast plotting primitives.
__hubnet-clear-plot <client-id>__hubnet-plot <client-id> <number>__hubnet-plot-pen-down <client-id>__hubnet-plot-pen-up <client-id>__hubnet-plot-point <client-id> <number> <number>__hubnet-plotxy <client-id> <number> <number>__hubnet-ppd <client-id>__hubnet-ppu <client-id>__hubnet-set-histogram-num-bars <client-id> <number>__hubnet-set-plot-pen-interval <client-id> <number>__hubnet-set-plot-pen-mode <client-id> <number>
Every model in the models library needs a PNG preview image. This image is used in the Models Library window. The preview image should have the same name, and live in the same directory, as the model, but extension .png instead of .nlogo.
NetLogo can automatically generate preview images for models. From the command line, ./sbt all-previews redoes the whole models library and ./sbt preview can be used to remake a single preview.
By default, NetLogo generates a preview image by executing random-seed 0 setup repeat 75 [ go ], and then exporting the contents of the 2D view. You can specify custom preview commands for a particular model by hand-editing the model file and putting your custom preview commands in the section near the end right after the NetLogo version, or by using the Preview Commands Editor (accessible from the Tools menu). (Even if you specify custom commands, NetLogo still does random-seed 0 before running them, so you don't need to set the random seed yourself unless you don't like 0.)
For example, you'll notice the custom preview commands in the Wolf Sheep Predation model:
...
false
0
Polygon -7500403 true true 270 75 225 30 30 225 75 270
Polygon -7500403 true true 30 75 75 30 270 225 225 270
@#$#@#$#@
NetLogo 3.0beta2
@#$#@#$#@
set grass? true
setup
repeat 75 [ go ]
@#$#@#$#@
@#$#@#$#@
@#$#@#$#@
If a model needs a hand-generated preview (for example, a model that requires user interaction), set the custom preview commands to a single pseudo-command, need-to-manually-make-preview-for-this-model. Then NetLogo will ignore that model when generating previews.
Note that custom preview commands are also used to generate model checksums, for use in regression testing the compiler and engine.
The features that follow are probably only of interest to Scala/Java developers.
- You can quickly convert a Models Library model into a "normal" model (allowing you to save over it) by using the
__editcommand. This is a bit dangerous, but it's very nice since it allows you to load a model using triple-underscore and then quickly save it. Note that the title bar does not reflect the change until you save the model. Note that the command will complain if it doesn't find a.gitdirectory undermodels, since if you're not doing this from a Git repo, you're probably making a mistake. -
__gitlets you commit a model to Git or run another Git command on the currently open model. Note it does not save the model for you; normally, you'll need to use__editfirst, then File->Save, then__git "commit". -
__stdoutand__stderrlet you send output to the standard output or standard error streams. -
__dumpreports a string representation of the compiled form of your program; this is helpful for debugging the compiler. -
__dump1reports a string representation of the current procedure only, so you can get a dump of stuff other than the procedures tab -
__donekills the current context; this is used internally in a few places, but might be useful during debugging as well -
__boomis a reporter that does "throw new EngineException", which can be useful during testing and debugging -
__ignoreis a command that takes a single input and does nothing with it. May be useful when writing tests -
__framesis a reporter that tells you how many times the graphics window is been painted since startup or the last time you calledreset-timer-- handy for measuring graphics performance -
__dump-extensionsprints information about loaded extensions;__dump-extension-primsprints information about loaded extension primitives -
__reload-extensionsforces NetLogo to reload all extensions the next time you compile your model. -
__random-statereports a very long string encapsulating the state of the random number generator. it's the same string that export-world writes at the top of export files.
You can pass these to NetLogo in any of the following ways:
make go ARGS="arg1 arg2 ..."
java -jar NetLogo.jar arg1 arg2 ...
or by editing dist/NetLogo.install4j (Windows) or dist/NetLogo.app/Contents/Info.plist (Mac OS X) or netlogo.sh (Linux/other)
-
--eventsturns on event tracing, so you can see what components raise events and what components handle them; note that some very commmon events, e.g. PeriodicUpdateEvent, are omitted from the trace -
--open MODELNAMEopens the given model in "library" mode which forces Save-As if you try to save (you may use an absolute or relative path) -
--launch MODELNAMEopens the given model in normal mode so you can save your changes in place (you may use an absolute or relative path) -
--magic MODELSTRINGopens a model matching the given string (just like triple underscore) -
--versionprints the NetLogo version number and exits; this is used during the installer-building process -
--shortversionprints the NetLogo version number, not including the revision (e.g. "Rev B"), and exits; this is used during the installer-building process
Model checksums make sure that when we change NetLogo, we don't inadvertently change the results of model runs.
-
The file
test/checksums.txthas a list of models and checksums. The first column is the model name; the second column is the checksum of the world after running the model's preview commands, and the third column is the checksum of the contents of the 2D view after running the model's preview commands. There is also a file for 3D,test/checksums3d.txtand theheadlessprojecttest/checksums-headless.txt. -
Variants for a model can be defined in the
test/checksum-variants.txtfile. Each model is defined on a line starting with*and then the relative model path. The variants go the lines after, and are the raw NetLogo commands to setup the variant to checksum. One variant is defined per line. -
./sbt netlogo/checksumadds an entry for a new model, or updates the entry of a model inchecksums.txt. It runs the preview commands for the model and calculates both a checksum of the world and of the contents of the view. Type, for example, in sbt,checksum "models/Sample Models/Biology/Wolf Sheep Predation.nlogo" -
To generate new checksums for the entire library, type
./sbt netlogo/allChecksums. For the headless engine./sbt headless/allChecksumsand 3D would be./sbt threed netlogo/allChecksums. -
To check current checksums against the values saved in
checksums.txt, type./sbt netlogo/testOnly *TestChecksums, or./sbt headless/testOnly *TestChecksumsforchecksums-headless.txtor./sbt threed netlogo/testOnly *TestChecksumsforchecksums3d.txt. This is mostly useful for the CI/build environment to catch unintended changes. If you suspect there are changes or differences in the checksums, you're better off re-generating the checksums from scratch usingallChecksums(see above), comparing the changes usinggit diff, and making sure the changes are expected and merging if so or reverting if not. Running theTestChecksumswill tell you that the checksums have changed, but won't update the files to commit the changes if the differences are intentional.
-
The reporters
__hubnet-in-q-sizeand__hubnet-out-q-sizewill tell you if HubNet's internal queues are getting backed up -
A "robo-client" is available for testing HubNet models: it simulates a human participant by randomly generating button clicks, slider moves, etc. in the client interface; open a robo-client with __hubnet-robo-client num; where num is the number of milliseconds between client sends; contact the HubNet team for details
You can pass these command line arguments to HubNet:
-
--robo numopens a robo client that sends a widget change every num milliseconds. if num is not specified, 500 is used. -
--ip hostname or ipuse a specified server as the host of a simulation -
--id user-identers user-id into the user name field
If both --ip hostname or ip and --id user-id are present, the client connects automatically using these parameters. You don't have to press the enter in the client. This is useful for automating runs.
-
__hubnet-broadcast-user-messageand__hubnet-send-user-messageare analogous to user-message to all clients and one client respectively -
__hubnet-create-clientcreates a local client. this is the same as pressing the Local button in the HubNet Control center. an 'invisible' client is created in headless. -
__hubnet-send-from-local-clientclient-name tag value (Headless only) - send a message from a local client to the server -
__hubnet-set-view-mirroringon-or-off (only tested in Headless) - takes a boolean argument and turns view mirroring on or off. -
__hubnet-wait-for-clientsnr-clients-to-wait-for timeout - waits up to timeout ms for the specified number of clients to connect. throws an exception if that number of clients didn't connect before the timeout. -
__hubnet-wait-for-messagesnr-messages-to-wait-for timeout - waits up to timeout ms for the specified number of messages to arrive. throws an exception if that number of messages didn't arrive before the timeout.
- Extensions
- NetLogo Libraries
- Controlling API
- Extensions API
- 6.0 Extension and Controlling API Transition-Guide
- Optimizing NetLogo Runs
- Setting English as the Default Language when Running NetLogo
- Unofficial Features
- Advanced Installation
- Optimization List
- Java System Properties and how to use them
- NetLogo on ARM Devices
- Multiple Views via HubNet
- Branches
- Building
- Tests
- Windows Setup
- Continuous Integration
- Draft: How to Help
- NetLogo Project Ideas
- Syntax Highlighting
- Building with IntelliJ
- Code Formatting
- Localization
- XML File Format
- Pre‐7.0.0 File Format (.nlogo) and Widget Format
- Benchmarking
- Releasing/Publishing
- Preparing the Models Library for Release
- Documentation
- NetLogo Bundled Java Versions
- JOGL
- Plugins API
- Architecture
- LazyAgentset
- Model Runs and Review Tab
- Model Runs: To Do and Code Overview
- Notes on in Radius
- Archived Branches
- Touch API Proposal
- Why isn't NetLogo "Parallel"?
- Potential Speedups
- Tortoise
- SimServer, WebStart, and NetLogo in Classrooms