![]() 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). ![]() If instead for some reason you don't want to have those lines of code in your model, an option would be to create your initial environment once and then use export-world to export it as a file that can be read at later moments using import-world.Here in NetLogo Web, import-* primitives work a bit differently from how they work in desktop NetLogo. a patch-set) and then asking them to change color would be faster? I don't know, you can find it out using the Profiler extension if you want. Maybe creating an agentset of patches (i.e. Doing it with at-points is a way to do it, and I don't think it is particularly inefficient. If instead you have a situation in which there is no particular pattern to follow, but you still want some very specific patches to change color, I am afraid that you will have to hard code it. The code above does the exact same thing as your example. You can definitely address patches within a range of coordinates values, by using with and remembering that pxcor and pycor are nothing more than patch variables for which each patch holds specific values: to setupĪsk patches with [
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |