can I set the min/max pxcor and pycor in Netlogo interface from code? Want to choose a state, and then use its min/max lat/long to set the display so it fills up the whole world. I guess the alternative is to make the world wide enough and high enough for the biggest state and then adjust all lat/long values to fit that. I'm only looking at lower 48 states since Alaska is huge and Hawaii spread out, but still makes Rhode Island teeny next to Texas.
Sure. Just take a look at the resize-world primitive.
Just be aware that:
As a side effect, all turtles and links die, and the existing patch grid is discarded and new patches created.
Related
I am doing a tree grow in net logo, I have to implement a hidden trunk. But how can I make a patch assign to trunk color when there is no leaf and sometimes hidden behind leaves and showing leaf color ?
When we standing in front a tree, we sometimes cannot see the upper trunk cause the leaves. That is what I am going to model for now.
This may not be the answer you were hoping to get, but it might be the one that helps you the most in the long run:
The tree leaves should not be represented by patches. They should be represented by turtles.
If you use turtles, you get the "hiding what's behind" property for free, but that's just one of the reasons to use turtles.
NetLogo beginners tend to resort to patches as their "go-to" type of agents because they seem easier to use, but it's a trap. Turtles are much more flexible, and it pays to use them in the long run, even if you don't expect to move them around.
A few examples:
Patches are just coloured squares, but turtles can be any shape you want, which usually looks nicer. In your case, you could use the "leaf" shape that comes with NetLogo.
Turtles can have different breeds. Even if you plan to only use one breed of turtles, this makes your code more readable and also more flexible.
You can't have links between patches, but you can have links between turtles. Even if your model is not explicitly a network model, NetLogo links are a surprisingly useful way to represent relationship between agents.
Turtles can be created and killed. This is often a much better approach than trying to modify the state of a patch to reflect the fact that something is there or not. This applies directly to your problem: instead of changing the colour of a patch to signal that there is a leaf on it, just ask your patch to sprout-leaves 1.
So do yourself a favour and start your model with:
breed [ leaves leaf ]
to setup
clear-all
set-default-shape leaves "leaf"
; ...
reset-ticks
end
You'll make your own life much easier.
I am trying to develop a model to demonstrate a field principle I am trying to work with. I am having trouble finding information on how to control specific groups of turtles. Essentially I would like to make a grid of turtles and links that I can distort, relative to an objective coordinate grid, based upon the placement of a different type of turtle, like a particle interacting with a field?
Any suggestions would be greatly appreciated. Is it possible to write a command that only talks to specific turtles by their who value? for instance if i had a coordinate plane that went from -3,3 in both x and y, rendering 49 vertices, could I set up those first 49 turtles, and then spawn my particle turtles (lets say 3), which would be who 49,50, and 51. could I write a command specifically for those 3 turtles based upon their relations to the first 49 turtles?
I hope this question makes sense.
I was using in-cone, but then I noticed my turtle was "missing" a lot of other turtles inside the cone. From what I understand, this is due to the fact that, for instance:
ask other turtles in-cone 6 60 [set seen? true]
only "detects" turtles if their xy is within the cone. They are basically points without dimensions. Is there an easy way to make a turtle of size 20 be much more "visible" than one of size 2? I've searched this and the yahoo group for answers and didn't find what I was looking for... maybe I'm not searching for the right terms... I'm new to programming and netlogo and everything so I'm probably missing something obvious here.
Thank you very much.
I have distributed turtles on the world having size x and I wish to increase their size to y but the I want to keep their location of their lower further point same (Check figure below). How can one accomplish this?
EDIT:
I wished to write a procedure that could be applicable for all turtle heading, that is if the turtle is heading 0 or 90 or 45. Direct math in such case could be complicated.
As Seth said, this should be relatively straight forward math. If you don't want to do the math, though, and this is only for visual purposes, you could make a new turtle shape, where the "bottom" of the shape is actually at the center. Then, when turning, it will like the turtle is turning around their bottom. When changing size, again, the "bottom" will stay in the same place.
I have used face in NetLogo without any problems, but isn't towards just the same? (in the context of an agent facing towards the direction of a patch/agent)
towards
towards agent
Reports the heading from this agent to the given agent.
If wrapping is allowed by the topology and the wrapped distance (around the edges of the world) is shorter, towards will use the wrapped path.
Note: asking for the heading from an agent to itself, or an agent on the same location, will cause a runtime error.
set heading towards turtle 1
;; same as "face turtle 1"
See also face.
Is there any scenario in which using set towards heading is better than using face?
towards only reports the heading
face is like towards and set heading combined into one.
Are there circumstances in which you would like to know the heading towards something without actually turning to face it? I'm sure you could think of many. One example situation would be choosing between two possible headings according to some criteria.
Let's say you want to face one of two agents, whichever one requires you to turn the least amount:
let first-heading towards first-agent
let second-heading towards second-agent
; compare my current heading to the two calculated headings:
let first-angle subtract-headings heading first-heading
let second-angle subtract-headings heading second-heading
if-else abs first-angle < abs second-angle
[ rt first-angle ]
[ rt second-angle ]
(In real life, you would probably do things a bit differently, but I hope this carries the point across.)