Cylindrical dynamic object in Netlogo - netlogo

Is there a way to make in Netlogo an object similar to this?
I would like a dynamic object, formed by 3 circumferences and if possible, I wish I could dynamically resize them, making them larger or thinner.

Maybe something like this? They will have to be different agents, so you will have 3 times as many agents as you actually want.
to makecell
create-turtles 1
[ set shape "circle"
set color green
set size 20
]
create-turtles 1
[ set shape "circle"
set color red
set size 15
]
create-turtles 1
[ set shape "circle"
set color gray
set size 10
]
end

Related

More patches per turtle according to its size Netlogo

I 'm new in Netlogo programming. I would like to make turtles with cloud shape and big size so if another turtle i.e. a person be at the same patch with the cloud to lose energy. The problem is that I can't have a turtle to be in more than one patches, netlogo "can see" that it's in only one patch.
Regardless of the size of an icon depicting a turtle, the turtle is located only at a single point (defined by the variables xcor and ycor). However, you can instead use distance to find if other turtles are close
As JenB said, the turtle only exists as a point, you'll have to come up with logic to make the clouds seem bigger than they are if you want them to be turtles.
Here is some code that demonstrates how to use size and in-radius to make the clouds breed affect the leaves breed color as they move past. It works best with shape = "circle" since then the radius of the cloud will match where the leaves are affected. You can add this code to a basic new NetLogo model to see it work:
breed [ clouds cloud ]
breed [ leaves leaf ]
to setup
clear-all
ask patches [
set pcolor blue + 2
]
create-clouds 10 [
set xcor random-xcor
set ycor random-ycor
set size 1 + random 4
set color white - 2
set shape "circle"
]
create-leaves 35 [
set xcor random-xcor
set ycor max-pycor
set shape "leaf"
set color green
set heading 180
]
end
to go
ask clouds [
ask leaves in-radius (size / 2) [
set color (color - 1)
]
]
ask leaves [
fd (1 + random 10) / 10
]
end
You can also reverse the logic a bit so it's the leaves that check if they are inside a cloud using distance. I find this option more confusing, but it might work better in your case:
to go-leaves
ask leaves [
if any? clouds with [distance myself < (size / 2)] [
set color (color - 1)
]
fd (1 + random 10) / 10
]
end
And finally, instead of using turtles to represent your large areas that turtles move through, you could use patches instead. It would simplify some things, but wouldn't work in every case.

Rotate shape netlogo

I create several turtles with the same shape. One of them I need to rotate 90 degrees.I tried rt and also heading. Nothing works. When I created the shape I cancelled the rotation - does it influence. How ca n I set may shape rotated. All these shapes doesn`t move.
crt 0 [
setxy 0 / 4) 0
set shape "tunnel"
set heading 200
set size 10]
crt 1 [
setxy 10 0
set shape "tunnel"
set heading 200
set size 10]
Some NetLogo turtle shapes are by default not rotatable.
When you open the "Turtle Shapes Editor" (Tools Menu) you will see that some shapes are framed within a circle (rotatable), whereas others are framed within a box (not rotatable). However, you can easily change this setting for the default shapes and also for your own shapes. Just edit a non-rotatable shape and check the rotatable checkbox in the lower left.

setting up turtles with preset distance between them (netlogo)

I am a high school student and I have to make a model about plants and plagues. I want to setup turtles with a preset distance from each other, but I can't figure out how to do that without creating an infinite loop. This is what my code looks like. Now it creates 20 turtles with random distance between them, but I want them to have a preset distance and as much turtles there can be on the screen with that distance between them.
to setup
clear-all
ask patches [ set pcolor 33 ]
make
repeat 20 [maken]
reset-ticks
end
to make
create-aardappelplanten 1[
setxy random-xcor random-ycor
set color green
set size 1.5
set shape "plant"
set age 1
]
end
Thank you so much!!

Dynamic charting in Netlogo

In my model, the number of turtle is dynamic based on the value defined by the user using a slider. The slider can take values between 2 and 10. Each turtle has its own set of co-ordinates and characteristics, hence i used the following code to create them.
create-parties 1
[set color red set label-color red set label who + 1 set size 3 setxy party1-left-right party1-lib-con ]
create-parties 1
[set color green set label-color red set label who + 1 set size 3 setxy party2-left-right party2-lib-con ]
if Num-of-parties >= 3
[ create-parties 1
[set color blue set label-color red set label who + 1 set size 3 setxy party3-left-right party3-lib-con ] ]
I have repeated the above till Num-of-parties =10.
In one of the modules i have created a condition where if a certain value of the turtle reaches 0 it will die.
In the later part of the model i have used set-current-plot to create a chart using the below code:
set-current-plot "Voter Support"
set-current-plot-pen "Party1"
plot 100 * [my-size] of turtle 0 / sum[votes-with-benefit] of patches
set-current-plot-pen "Party2"
plot 100 * [my-size] of turtle 1 / sum[votes-with-benefit] of patches
if Num-of-parties >= 3 [ set-current-plot-pen "Party3"
plot 100 * [my-size] of turtle 2 / sum[votes-with-benefit] of patches ]
so on and so forth for all ten possible turtles.
The problem is if the user has defined 5 turtles and turtle 3 dies at tick 10, then chart portion of the code is throwing an error since there is no turtle 3 but num-of-turtles slider defined by the user has a value of 5.
Please advise on how to solve this. Thanks, appreciate the help.
Regards
When writing model code, you should try to apply the DRY principle: Don't Repeat Yourself. Creating each turtle separately and then trying to do something with each of them by addressing them separately as turtle 0, turtle 1, etc. will lead to all sorts of problems. What you're experiencing with plotting is only the tip of the iceberg.
Fortunately, NetLogo gives you all the facilities needed to deal with a "dynamic" number of turtles. ask is the primitive you will use most often for this, but there are plenty of other primitives that deal with whole agentsets. You can read more about agentsets in the programming guide.
In the case of plotting, you can ask each of your parties to create a "temporary plot pen". We'll use the who number to give a unique name to each of these pens. (That's one of the very few legitimate uses of the who number in NetLogo.)
Put this code in the "Plot setup commands" field of your plot:
ask parties [
create-temporary-plot-pen (word "Party" (who + 1))
set-plot-pen-color color ; set the pen to the color of the party
]
(Note that you won't need the plot pens that you previously defined anymore: you can just delete them. New plot pens will be dynamically created every time you set up your plot.)
To do the actual plotting, we can use very similar code. Put this code in the "Plot update commands" field of your plot:
ask parties [
set-current-plot-pen (word "Party" (who + 1))
plot 100 * my-size / sum [ votes-with-benefit ] of patches
]

Creating landscapes of different shapes in NetLogo

Currently the landscape I setup in NetLogo includes patches of "typrAgro" in a strip on top and "typeTrop" in a block along the bottom.
to setup
ca
clear-all-plots
clear-output
set typeAgro 1 ;where people will be located
set typeTrop 2 ;where animals will be located
ask patches
[ set habitat typeAgro ]
ask patches with [pycor <= 500] ;world is 600 x 600 pixels
[ set habitat typeTrop]
set AgroForst patches with [ is-Agro? ]
set TropForst patches with [ is-Trop? ]
ask AgroForst
[ set pcolor 75 ]
ask TropForst
[ set pcolor 65 ]
reset-ticks
end
Instead I'd like to create landscapes that have several generic shapes, for example, like those in the image below. In particular, I have no idea how to create the last two shapes (a long linear shape and the random polygon). Any suggestions on how to get started on that would really help. Thanks!
One way I would suggest is creating your map using paint or anything else and define your regions using different colors and then import is as background.
Using
import-pcolors "test.png"
In your setup procedures you can ask different patches with different colors to set their arguments based on your model requirements.