NetLogo Web is a version of the NetLogo modeling environment that runs entirely in the browser. One of the immediate goals of the project is to provide a suitable replacement for the NetLogo applet functionality, and, in doing so, once again make NetLogo models easy for users to put on the web for others to try. NetLogo Web runs on more platforms than Desktop NetLogo, including tablets, phones and Chromebooks. In the longer run, NetLogo Web will have most of the features of Desktop NetLogo.
The desktop edition of NetLogo is more polished and fully-featured than NetLogo Web. So, for now, we recommend using NetLogo Web only if one or more of the following describes your desired use of NetLogo:
- I want to use NetLogo on a platform that it does not otherwise run on (e.g., iPad, iPhone, Android, Chromebook)
- I want to embed a NetLogo model in a web page
- I want to distribute a NetLogo model without requiring my audience to have an existing NetLogo installation
The quality gap between NetLogo Web and NetLogo is fairly large right now, but we intend to greatly narrow that gap over the course of the coming years, prioritizing features that are important to large portions of the user community. Even if NetLogo Web doesn't meet all of your needs today, be sure to stay tuned as we work to improve NetLogo Web and expand its feature set.
- Most of the NetLogo programming language
- The Command Center
- Editable "Code" and "Info" tabs
- Widgets
- Authoring support
- The ability to export models for use in the desktop edition of NetLogo
- The ability to export models as standalone HTML pages
- High performance
- Many extensions, see the bundled extensions list to find out which extensions from desktop are supported.
- Reading from and writing to external files with the file primitives, but see the input and output extensions for an alternative method.
- 3D models and the "3D View" of 2D models
- HubNet
- BehaviorSpace
- Other less-central NetLogo features (e.g., System Dynamics Modeler)
- NetLogo language primitives relating to any of the above
- NetLogo language primitives relating to some kinds imports and exports
That said, there are very few things in NetLogo that have been left out of the long-term development plan for NetLogo Web. If support for your favorite primitive or feature is not currently available, it is likely forthcoming. We appreciate your patience as we work to reproduce functionality that has been developed and honed over more than fifteen years of NetLogo development, in our goal to make NetLogo Web the best product we can.
Most NetLogo library models work in NetLogo Web. In the NetLogo Web models library drop-down menu, models that work in NetLogo Web are selectable, whereas the models that don't yet work in NetLogo Web are grayed out. Some selectable models may not work exactly as their NetLogo counterparts. Some grayed out models can easily be modified in Desktop NetLogo so that they run in NetLogo Web.
See the next section for more information on why they may not work.
NetLogo Web opens with a randomly selected model. To load another model, you may select a model from the drop-down menu of models from the NetLogo Web Models Library (Search the Models Library) or use the button next to "Upload a Model" to open a Desktop NetLogo model of your own.
To evaluate whether a model of your own will run in NetLogo Web today, you can use the "Upload a Model" button to open it in NetLogo Web. If the conversion process encounters an error, you will get feedback about what aspects of your model are not yet supported.
That said, here are some general rules for telling ahead of time whether or not a model will work in the current version of NetLogo Web:
- If your model only uses NetLogo features that are commonly used in the NetLogo Models Library, it is very likely that your model will work
- If your model uses unsupported extensions, file primitives, movie primitives, or any of the other currently-unimplemented primitives, it will not work
- If your model uses the
wait
ordisplay
primitives, it generally will not work
If you're still not sure if your model will work or not, we encourage you to simply open your model in NetLogo Web and see for yourself.
NetLogo Web is in continuous development. As NetLogo features are ported over to NetLogo Web, many models that previously could not be opened in NetLogo Web will automatically become runnable.
Click the "File: New" button in the top-right of any NetLogo Web model in order to open a fresh model.
For further information about NetLogo's authoring tools, please see "Authoring in NetLogo Web".
Firstly, the NetLogo Models Library is easily accessible in NetLogo Web. To open a model from the Models Library, simply select it in the "Search the Models Library" dropdown. In that dropdown, models that work in NetLogo Web are selectable, while models that don't work yet are grayed out.
The other option for opening models in NetLogo Web is to click the file-selection button labelled "Upload a Model", and then select a model on your computer. Note that opening a model in this way does not save your model remotely anywhere. In fact, the "Upload a Model" file picker simply asks your web browser to open a file from your computer in such a way that the model never even leaves your computer when it is "uploaded".
NetLogo Web offers two different ways to save a currently open model, including any changes you've made to it. You can download a copy of the model to your computer in the standard NetLogo format for safe-keeping. A downloaded NetLogo model can be opened in NetLogo desktop, re-uploaded to NetLogo Web, or hotlinked to NetLogo Web for display on a web page. You can also export a full HTML page of the model, which includes everything needed to run the model and post that HTML on your web site host to share with others.
To save your model to your computer in the standard NetLogo format, click the Export: NetLogo
button. This will generate a .nlogox
file that has a name of your choosing, which will be placed in your
computer's "Downloads" directory and can then be opened once again in either NetLogo desktop or upload to NetLogo Web. You can also place the model on a web file
host and hotlink it to NetLogo Web so others can use it online.
To save your model as an HTML file that includes everything needed to run the model, click the Export: HTML button in NetLogo Web to generate a single HTML file of your model. Like any other HTML file, files generated in this way can then be hosted on a website and viewed in any modern browser.
If you want to share you NetLogo model in a way that won't require users to open the model in NetLogo desktop or upload it to NetLogo Web, you will need a website host to store your files and display them. If you already have a website, then you have a website host and can skip the rest of these recommendations. If you don't have a website, one popular option for a simple static website host is GitHub Pages. Common website platforms like Wix and SquareSpace should support hosting NetLogo models or static HTML files. There are many other options, and all you need is a simple, static website in order to host NetLogo models. In the future, we're hoping to provide a service just for hosting NetLogo models to make things even simpler.
Once you have a website host, the next choice you have is to post your models as standard .nlogox
files and hotlink them to NetLogo Web, or to post exported HTML files of your models. If you plan to post many models,
or expect to make updates to models fairly frequently, hotlinking to NetLogo files will likely be easier as you won't
have to re-export new HTML pages each time you make an update. If you are just posting a single model as a one-time
thing, then posting the exported HTML page might be simpler. Below are some further benefits to each method.
Benefits to hotlinking your model to netlogoweb.org:
- Network resource usage will be reduced. Every hot-linked model uses the same code from netlogoweb.org, which your web browser can cache and re-use. If you have multiple models on a page, this will greatly reduce the download size of your pages and speed up loading times as models are much smaller than exported HTML files.
- The update process is simpler. When you update your model where it's posted on your website host, the places you link to it will also be updated. You do not have to re-export and post a new HTML file with each model update.
- Your model will automatically get bug fixes, performance enhancements, and other improvements that are made to NetLogo Web.
If you want to hotlink your model, see the hotlinking FAQ entry for more information.
Benefits to using a static HTML export with "Save as NetLogo Web":
- No network access to another site (netlogoweb.org) is required. The model and code to run it are self-contained. This can be a benefit in an environment where network access is very restriced.
- You do not have to worry about setting up cross-origin resource sharing (CORS) access from your website host to
netlogoweb.org
. CORS settings are common and usually easy to change for most website hosts, but if your host is restrictive you may need to use exported HTML files for your models instead. More information on CORS is in the hotlinking section of the FAQ.
If you want to post the static HTML version of your model, your website host's documentation should include information on how to do so.
Another option for sharing your model and linking directly to pages containing NetLogo Web models is to use the Modeling Commons, which is a public space for uploading, sharing, and discussing NetLogo models. All models uploaded to the Modeling Commons have integration with NetLogo Web through the Run in NetLogo Web tab on the model's page. For any model, if you open that Run in NetLogo Web tab and then copy your browser's current URL, that URL can be used for direct access to the NetLogo Web version of the model.
Yes, you can hotlink your model to
netlogoweb.org
. As long as you update your model at the location in the link you create, that link
will always use the latest version.
To generate a runnable link (URL) of your .nlogox
model file to share, follow the below steps. You
will need your model posted on a website host accessible to the Internet to use this technique, see the hosting and sharing FAQ entry for more information. The examples given
reference GitHub Pages, but any website host should be similar.
- Get the URL of your model as posted on your website host.
- For example:
https://octocat.github.io/MyNetLogoModel.nlogox
- For example:
- Create a URL by using
https://netlogoweb.org/launch#myModelURL
.- For example:
https://netlogoweb.org/launch#https://octocat.github.io/MyNetLogoModel.nlogox
- For example:
- Open the link in a web brwoser to test it out, you should see your model load in NetLogo Web and be ready to go.
To embed your runnable model in an HTML page on your site, use an iframe
element:
- Get the URL of your model as posted on your website host.
- For example:
https://octocat.github.io/MyNetLogoModel.nlogox
- For example:
- Create a URL by using
https://netlogoweb.org/web?url=myModelURL
. Note the use ofweb?url=myModelURL
instead oflaunch#myModelURL
. The/web
page loads without the NetLogo Web menus and borders, which is more appropriate for embedding in another site.- For example:
https://netlogoweb.org/web?url=https://octocat.github.io/MyNetLogoModel.nlogox
- For example:
- Open the link in a web browser to test it out, you should see your model load in NetLogo Web and be ready to go.
- On the website page you want to embed your model, add an
iframe
element with asrc=
to your model URL.
For example, here is what a basic HTML page that embeds the model might look like:
<html>
<head>
<title>NetLogo Model Hotlinking Example</title>
</head>
<body>
<p>NetLogo Model Hotlinking Example</p>
<iframe
src="https://netlogoweb.org/web?url=https://octocat.github.io/MyNetLogoModel.nlogox"
width="600" height="600">
</iframe>
</body>
</html>
Cross-Origin Resource Sharing (CORS)
One common issue in hotlinking models is making sure that your website host allows cross-origin resource sharing
(CORS) with NetLogo Web. Essentially this is a way for your website host to tell web browser that's it's okay for
NetLogo Web to load resources, even though they are different websites. Some website hosts, such as GitHub Pages, are
permissive by default and you won't have to make any changes to get them to work. If your website host is not
permissive by default, you might need to have your host set the Access-Control-Allow-Origin
header in the
.nlogox
file's HTTP response to either *
or whichever NetLogo Web domain you're using,
https://netlogoweb.org
or https://netlogo-web.org
. This is a common setting for website
hosts, and they should include some way to update it for your website's files.
NetLogo does not store the speed slider setting with the model file, but NetLogo Web
provides a way to set the slider value on load using a URL query parameter. If
you are linking your model all you need to do is add ?speed=#.#
. If
you are linking to the //netlogoweb.org/web
page you also will need
to use &url=modelURL
instead of the plain ?modelURL
.
You can set the speed
value to any number between -1 (slowest) and 1
(fastest), and 0 is the default. Here are some examples, setting the speed to 0.5:
- If you're linking to
//netlogoweb.org/launch#modelURL
, use//netlogoweb.org/launch?speed=0.5#modelURL
. - If you're linking to
//netlogoweb.org/web?modelURL
, use//netlogoweb.org/web?speed=0.5&url=modelURL
(note theurl=
change for themodelURL
and the&
between the parameters. - If you're linking to an exported model HTML page,
//myhost.com/path/to/myModel.html
, use//myhost.com/path/to/myModel.html?speed=0.5
NetLogo does not store the position of the Command Center, NetLogo Code, and Model Info windows with the model
file, but NetLogo Web provides a way to set the position using a URL query parameter. If you are linking
your model all you need to do is add ?tabs=right
. If you are linking to the
//netlogoweb.org/web
page you also will need to use &url=modelURL
instead of the plain
?modelURL
. At the moment the tabs
parameter can only be set to right
, any other
value will cause the Commands and Code to display underneath the model widgets. See the speed parameter FAQ entry for examples on using query parameters when linking to
models.
I got an error, but most things in the model seem to be working just fine. What was the error message about?
If you enter code into the Command Center and that code is invalid in NetLogo Web, you will receive an error message, and your code may not get fully executed.
If you get an error when the model is first loaded up, but can't tell what's going wrong, it's probably because one of the widgets (e.g. a Plot or Slider) contains code that is currently invalid in NetLogo Web. The widget will not work correctly, but the parts of the model that did not generate errors will continue to be operable.
If you get an error only when you click a button, it usually suggests that the particular button contains code that is currently invalid in NetLogo Web. That button will be unusable, but the parts of the model that did not generate errors will continue to be operable.
A type error in general indicates that a function received one or more arguments
that it didn't know how to operate on. One example of a type error in NetLogo code would be
(turtle 0) + (turtle 1)
, since the +
function doesn't know how to add
turtles together.
When we talk about a type error occurring in the simulation engine, we mean that this kind of error happened in the JavaScript code that is running in the browser. The fact that these errors occurred in JavaScript, though, does not necessarily indicate that the simulation engine is the culprit. In fact, the vast majority of these sorts of errors are caused by ill-formed NetLogo code for which the engine does not yet know how to report nice errors. In desktop NetLogo, you always get informative type errors, but, unfortunately, NetLogo Web's error-reporting functionality is not yet complete enough to always give smart errors.
The area where NetLogo Web's error-reporting is poorest at the moment is in
cases like ask n []
(where n
is a number, or really anything but an agent or
agentset). If ask
were passed a literal value instead of a variable like n
,
the compiler would usually just refuse to compile code that doesn't typecheck, and it would tell
you exactly what went wrong. Unfortunately, in NetLogo, static typechecking goes out the window
when variables are introduced, forcing the engine to fall back on runtime typechecking. Even more
unfortunately, NetLogo Web's runtime typechecking is very poor at the moment.
As for how to fix these errors, that is difficult for now. There is not a lot that the average user can reasonably be expected to do until we implement proper error-reporting for type errors. Advanced users might find some hints in the JavaScript error that gets printed out. We recommend reproducing the error in desktop NetLogo to get a proper error message, or, if that's not possible, then trying to bisect your model's code until you find the source of the error.
NetLogo Web is saying that it "Couldn't find corresponding reader" or "Models must have 12 sections". How can I fix these errors?
If the error message is "Models must have 12 sections, this had 1", the problem is likely that the uploaded file is not actually a NetLogo model. Please verify that you can open this file in the desktop version of NetLogo before proceeding.
If you got the "Couldn't find corresponding reader" error or the "Models must have 12 sections" error with a number at the end other than 1, this usually indicates an attempt to load a model that was saved in an old version of NetLogo. Please note that NetLogo Web only guarantees compatibility with the latest version of NetLogo.
The easiest way to fix this problem is to open the model in the latest version of NetLogo, allow NetLogo to automatically convert the old model, save the auto-converted model, and attempt to open the newly-converted version of the model in NetLogo Web.
If NetLogo Web complains that it cannot load this newly-converted model due to unimplemented primitives (especially those whose names start with underscores), you may need to slightly rewrite some of the code. See the NetLogo transition guide for more details on how to do that for the particular version of NetLogo that your model came from.
Your computer is working very hard to execute some NetLogo Web code. This is especially likely to occur when trying to do something that involves a very large number of agents. Unless you've done something to enter an infinite loop, we recommend just giving NetLogo Web some time to finish its task. If you have entered an infinite loop, the recommended solution is to terminate the browser tab.
A common NetLogo task is to run a procedure a number of times and then stop. This is easy to do by using code
like: repeat 10 [ go ]
or repeat 50 [ my-proc ]
. In desktop NetLogo, if your procedure
uses tick
, then the view will also update for each time the procedure is called. In NetLogo Web,
however, no visual updates will happen until all repeats of the procedure are complete. This is due to technical
limitations of the browser environment.
There is an easy workaround, it just requires a couple small changes to the model. Use a button in your model set
to run forever and have that forever button run a repeat/count procedure. Inside that procedure, you can count ticks
using a global variable and call stop
once you've reached your tick count limit. This will allow view
updates to happen, run the required number of steps, and then stop execution as expected.
; this assumes you have a global variable, 'ticked', declared and set to 0 in 'setup'
; and a procedure named 'go' to run. Just run this proc in a forever button.
to go-repeat
set ticked (ticked + 1)
go
; can change 100 to whatever number of ticks you'd prefer
if (ticked > 100) [
; resetting the ticked value before we stop lets people re-press the buttom
; to run another 100 ticks
set ticked 0
stop
]
end
Similar to the issue with repeat
noted above, using mouse-down?
inside a looping primitive
like while
, loop
, or repeat
will
cause NetLogo Web to freeze instead of operating as it would
in desktop NetLogo.
The workaround is to use a forever button to run the mouse code instead of one of the looping primitives. Global variables can be used if you need the procedure to remember some information about where the original mouse click happened, or the current status of the mouse click action. The Mouse Drag One Example model shows a basic example dragging a single agent. The Mouse Drag Multiple Example model shows a more complex scenario using a simple state machine.
Below is some sample code that will increase the size of one of the turtles a user clicks on. This procedure should be added to a forever button so that when it's enabled the mouse clicks will have the desired effect.
to increase-size
if mouse-down? [
ask up-to-n-of 1 (turtles with [(distancexy mouse-xcor mouse-ycor) <= 1]) [
set size (size + 0.1)
]
]
end
There are a couple of reasons for this. One of the big ones is that the the desktop edition of NetLogo has about fifteen years of development work behind it, and a lot of that was spent on improving performance. With NetLogo Web, our foremost concern has been feature parity. NetLogo Web is still very young and has a lot of catching up to do, so we don't plan to focus hard on performance for a while yet.
Another of the reasons has to do with the maturity of the platforms that these software packages run on. The desktop edition of NetLogo runs on the Java Virtual Machine, whereas NetLogo Web, in the browser, runs on a variety of different JavaScript engines. The Java Virtual Machine tends to be faster than any JavaScript engine, and some JavaScript engines are substantially faster than others. We find that Google Chrome tends to offer the best performance with NetLogo Web.
We recommend first trying to solve the problem by refreshing the page. If that doesn't fix it, we encourage you to report your problem to us at bugs@ccl.northwestern.edu.
One of the great things about running directly in the browser is how easy it is to modify content. If you want to tinker with things in NetLogo Web, go for it! You're entirely free to save a standalone NetLogo Web page and create your own stylesheets or mess with the page's JavaScript—at your own risk, of course. We do ask that you leave the "powered by NetLogo" text in its place. If you think the changes you've made would be useful for others, you might even consider contributing them to NetLogo Web proper (see the next topic, below).
Like NetLogo, NetLogo Web is open-source and hosted on GitHub. The relevant repositories for the project are Galapagos (for the web interface), Tortoise (for the simulation engine and compiler back-end), and the Parser and Headless projects in NetLogo desktop (for the compiler front-end and the tests we use to verify feature parity between NetLogo Web and NetLogo desktop).
Pull requests to these repositories are welcome. If you would like to talk to any of the NetLogo team about some proposed changes of yours, feel free to drop by the relevant repository's chat room on Gitter, where we'll be glad to discuss things with you.
One important source of NetLogo Web's funding is generous community donations. If you're interested in making a donation to the NetLogo project, please visit our donation page here.
Above all else, we gratefully acknowledge that the National Science Foundation has been the primary funder of NetLogo Web (grant number IIS-1147621). We also appreciate the support from Concord Consortium.
NetLogo Web was also made by possible by building on top of the previous two decades of NetLogo funding. Much of the support over the years came from the National Science Foundation -- grant numbers REC-9814682 and REC-0126227, with further support from REC-0003285, REC-0115699, DRL-0196044, CCF-ITR-0326542, DRL-REC/ROLE-0440113, SBE-0624318, EEC-0648316, IIS-0713619, DRL-RED-9552950, DRL-REC-9632612, DRL-DRK12-1020101, IIS-1441552, CNS-1441016, CNS-1441041, IIS-1438813, and REC-1343873. Yet more support for NetLogo over the years was provided by the Spencer Foundation, Texas Instruments, the Brady Fund, and the Northwestern Institute on Complex Systems.
Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.
For NetLogo or NetLogo Web feedback, please send email to feedback@ccl.northwestern.edu and for bug reports, please send email to bugs@ccl.northwestern.edu. We greatly value your comments, feature requests, observations, and bug reports. Please make sure to specify in your email that you are using NetLogo Web. You can also consult this page to determine where best to get in touch.