NetLogo Web

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 or display 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".

If you would like to save the model that is currently open in NetLogo Web (including any changes that you might have made to it), NetLogo Web offers two different ways of doing so.

If you would like to keep your model as a NetLogo Web model and share it with others to view in the browser, you can 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 are interested in saving the model for use in the desktop version of NetLogo, the "Export: NetLogo" button can be used to do so. This will generate a traditional ".nlogo" 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 or NetLogo Web.

With a model downloaded from NetLogo Web, you can use the desktop version of NetLogo, make whatever changes to the model that you would like, save those changes, and then open the new version of the model in NetLogo Web (using "Upload a Model" in NetLogo Web, like before).

Unfortunately, free and simple-to-use hosting services are surprisingly few in number these days. We realize that this makes things difficult for many of our users, and we definitely plan to provide our own service that makes this easier for people in the future. For the time being, though, there are still a couple of options that we can suggest, based on what kind of files you would like hosted.

If you're just looking to host .nlogo files, you can use Dropbox or GitHub or basically any service that allows linking directly to hosted files. Once your .nlogo file has been hosted somewhere, follow the page-generation instructions, and share the //netlogoweb.org/web?modelURL link, using the .nlogo file URL from your hosting service as the modelURL value.

Another option for 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" 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.

If you want to host an HTML standalone model (as generated by following the instructions in the section about "Export: HTML", then your options are more limited. One option is to use GitHub Pages, or some other static web host. Advanced users might even be comfortable with simply hosting the HTML files for themselves on a public-facing web server.

That said, hosting a .nlogo file on your own web server is more complicated, though. To do that, host the file, and make sure that your web server allows it to be accessed cross-origin. To do this, you might need to have the server set the Access-Control-Allow-Origin header in the .nlogo file's HTTP response to either * or whichever NetLogo Web domain you're using (i.e. http://netlogoweb.org or https://netlogoweb.org or http://netlogo-web.org or https://netlogo-web.org). Then, follow the instructions given here, and share your model through the //netlogoweb.org/web?modelURL link, using the URL of the model on the web server for the modelURL value.

You can link to //netlogoweb.org/web?modelURL (where modelURL is the URL of your model). Every time someone goes to that link (or an iframe is loaded that uses that link as the source URL), the most recent version of your model will be fetched from modelURL and turned into a simple model page.

This method requires the ability to make a connection to our website (netlogoweb.org) in order to work, and you must make sure your web server has CORS access for netlogoweb.org correctly setup (see hosting NetLogo Web models for more info). This is different than exported standalone NetLogo Web HTML model pages, which can be hosted entirely on your own server that won't require any CORS configuration. The exported HTML will also not automatically update every time you change your model.

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 the url= change for the modelURL 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.

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.

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.