![]() Since there's only one thread and don't really have the ability to suspend our current thread, switch to a different task, and come back at will, primitives like display cannot work as expected. In the browser, there's just one thread for everything (caveat: that's not strictly true, but multi-threaded browser-based programs are unacceptably slow, for the time being, at least). This is allows a program to have one thread for running heavy computations (like executing NetLogo code) and another thread that works to update what you see on your screen, to reflect the computations that have been done by the other thread (while that hard-working thread is still doing other hard work). Normal desktop applications allow programs to have multiple "threads" of code running at the same time. Wait is a primitive that functions significantly differently in NetLogo Web. What this translates to is that, in the uncommon case that your procedure relies on an import-* primitive executing before that procedure has ended, NetLogo Web will behave differently than desktop NetLogo, and your model might need to be re-architected a bit in order to get the two models running in the same way on both platforms. Once those lines have been run and the browser doesn't have anything else to do, then it will import the file. Instead, they are always read asynchronously, with line 10 of the aforementioned, hypothetical 20-line procedure now telling the browser that it should import the file whenever the browser is ready, followed by the browser immediately running lines 11-20 before actually importing that file. In browser-based applications, though, files cannot be read synchronously. In desktop NetLogo, importing a file happens "synchronously", which is to say that, if your model says to run import-world on line 10 of a 20-line procedure, NetLogo will not run lines 11-20 until after import-world has completed. Secondly, these primitives behave differently in a way that, under particular circumstances, can be surprising. Instead, NetLogo Web will open up a file dialog and ask you to manually select the to-be-imported file from your file system, regardless of the value of the string argument. For one, when importing a file in NetLogo Web, the string argument to the import-* primitive is accepted (out of a need for compatibility with desktop NetLogo) but ignored (due to the fact that browser-based applications cannot automatically read files directly from your computer). These constants, too, will turn brown in code.Here in NetLogo Web, import-* primitives work a bit differently from how they work in desktop NetLogo. NetLogo also includes some handy keywords for mathematical constants such as pi and e. Numbers, any text that is wrapped around quotation marks ( ""), and names of the built-in NetLogo colors (e.g., green, yellow, black, red) will all turn brown in code. Some examples to reporter primitives are: one-ofīrown text indicates a specific value, not a primitive, in NetLogo code. Lastly, the basic agent breed primitives such as turtles, patches, links, turtle, patch, and link are reporters, too, so they turn purple in code. The built-in agent characteristics such as color, pcolor, xcor, size, and thickness are also reporters, so they turn purple in code. Purple text indicates reporter primitives that reports a value, but does not change anything in the world themselves. ![]() Some examples to action primitives are: create-turtles Some examples to definition primitives are: globalsīlue text indicates action primitives that allow us to ask our agents to do things. Green with bold text indicates definition primitives that allow us to define new things in NetLogo. Below is a list of colors and what they indicate. Some primitives become green, some blue, some brown, and some purple. Whenever we write a piece of code in NetLogo, the editor automatically highlights each primitive. What does each color indicate in NetLogo code?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |