Search code examples
simulationnetlogomodeling

Two Worlds in Netlogo at the Same Time


Good day,

We're trying to create something wherein we can visually have two simulations running at the same time in Netlogo. It will be divided into two halves, The first half of the world will be simulating a run, and the other half will simulate another run with different variables.

is that possible?

I simply want to have my current program run on half of the screen.


Solution

  • If you look carefully at the image, you will see that it is actually a single world (in the NetLogo sense of the word - a specific type of output window) that has been visually separated with a grey wall down the middle. You can see this by looking at the top bar of the window - the normal panning controls and tick counter are at the left corner only and the 3D button is at the right corner only. That is, this has been constructed with clever coding rather than a NetLogo feature.

    Assume you have turned the middle patches grey (eg ask patches with [pxcor = 0][set pcolor grey]) then the code for the left hand simulation would control agent movements so they have xcor < -0.5 and the right would use xcor > 0.5

    Since you are running the same model with different parameter values, you will probably want the agents to be the same breed. They can have an attribute for whether left or right and use agentsets to construct the left turtles or the right turtles. But you might also want to consider having different breeds.

    Here are some suggestions how to achieve the effect entirely within NetLogo language:

    1. Do the clever programming with left / right as in the screenshot that inspired you
    2. Have separate breeds (eg red-turtles and blue-turtles) for the two scenarios and let them occupy the same world without interacting. If they interact with patches (eg eating grass) then you would need to have a patch variable for each breed (eg red-grass and blue-grass). Create plots and monitors to summarise the aspects of interest. The plots could have both scenarios as different lines, making comparison easy.
    3. As for 2, but also have a choose to switch views between breeds (so you could see how they are placed in their world. For example, create an update-view button which calls code to show/hide turtles and colour patches according to the choices on a chooser (which might be red, blue and both).
    4. Use BehaviorSpace and do the comparison after running the simulations based on the output generated.

    All of the options 2-4 have the advantage that they can run more than 2 scenarios (eg red, blue and yellow turtles).