Leader selection for crowd of turtles (NetLogo) - netlogo

I am using NetLogo for a simulation in which i have to deal with many turtles each representing a robot. I need to find an algorithm for leader selection. I want to make leaders in between the crowd which will ultimately lead crowd toward the predefined target. Or is there any other way to which any turtle dynamically changes its behavior to become a leader. Any one if could help.
As we see in the model library a model named "Flocking". In which a random turtles leads all turtles. But i don't need random turtle i need the leader which should be at center or at corners of crowd.

There are two immediate possibilities: a leader breed, or an is-leader? turtle attribute. Note that a turtle's breed can be changed dynamically, just like any other attribute.
If you will have multiple leaders you may need to keep track of who follows them. Three ways to do this: a leader can maintain an agent set of followers, or each robot can have a leader attribute set to the appropriate leader (which might be nobody or self for a leader 'bot), or (as a more powerful variant of the second approach) you could create a directed links from each follower to its leader.
hth.

Related

Is there a way in netlogo to get a turle to leave the simulation area and then come back after a certain number of ticks?

I am working on a evacuation simulation, my turtles represent vehicles that leave an area, I currently do this by having the turtle die when it reaches the evacuation point, however I would like to have the vehicle return show up elsewhere on the map and return to the original point of origin (to pick up more passengers to evacuate) I am unsure hide turtle will do this properly, because I don't want the turtle interacted with while it is "off the map" Is there a way to do what I want?
Jon,
Two ways I can think of.
One would be to indeed make the vehicle hidden and then have all your normal interactions with turtles be instead with vehicles with [not hidden?]. You could then refer to the hidden vehicles as vehicles with [hidden?]. I'm assuming that you have a vehicles breed, but if all turtles are vehicles, then it would be turtles with [not hidden?], etc.
But breeds suggests a different approach. Turtles can change their breeds, so if you have a breed vehicles, then you could create another breed (say) inactive-vehicles. When a vehicle has reached the evacuation point, you could ask it to set breed inactive-vehicle and set hidden? true. You could then continue to refer to active cars as vehicles and these inactive cars as inactive-vehicles. So, ask vehicles ... will just refer to those that are still active. You could then ask inactive-vehicles to go wherever you wish and then reset their breed to vehicles. (I'm not sure inactive-vehicles is great breed name, but it can be anything you want.)
Hope this helps,
Charles

Can a patch in net logo have two color and one is hidden sometimes?

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.

Turtle Movement Netlogo

I have a network of turltes that each share two links. At the start of each turn the turtles decide to cooperate or defect, which updates a beta distribution of likelihood of cooperation in the next tick. If the turtles fail to cooperate over n turns they no longer interact. Through this I am able to create clusters in the cooperation network.
Right now, I am trying to figure out how to make the turtles move closer together proportional to the weight of their ties. Is there code to do this? I have only been able to find example code for patches.
I think this model might have something similar to what you want:
http://modelingcommons.org/browse/one_model/3632#model_tabs_browse_procedures

Is it possible to control link heading between two turtles and how?

I have two atoms (turtles) on a screen. On a candidate turtle(when mouse down) , there is a link 2 3 (between turtle 2 and turtle 3).
I want that this link will be headed towards the other turtle called "atomOther". I tried facexy/set heading/towards, but none of them works.
Is it possible to control link heading and how?
Have you tried create-link-to or create-link-from ?
the first makes a directed link to (pointed at) the target the other from it.
They are both called by turtles.
Remember, you can not mix directed and un-directed links in the same model (unless they are of different breeds). One work around for this is make one like from and the other thus
ask turtle 1 [create-link-to turtle 2]
ask turtle 1 [create-link-from turtle 2]
This creates 2 links between turtles 1 and 2. One to and one from turtle 1.
Based on your clarification, the answer is no. You cannot make a link point in an arbitrary direction, because a link represents a relationship between two agents and therefore points from one of the two agents to the other in the relationship.
If you truly want a link to point from turtle 3 to turtle 1, even though the relationship is between turtle 3 and turtle 2, then use two different breeds of links. One breed is for the actual relationship and the other is for pointing. So, when whatever happens to make the arrow point in a different direction, you can use hide-link to make the link that points in the wrong direction invisible, and create-link-to for the arrow that points.

How to Increase the Patch Search Range for Turtles

I'm new in netlogo, and i want to know is it a right way to set turtles vision by using this code?
set leader patches in-radius vision
the vision is set as slider and can change from 0-10. The problem is, when i vary the vision from 0-10, seems nothing is change in turtles behavior. Really need some advice on this. thanks for help.
to setup
setup-leader
end
to setup-leader
ask max-n-of 10 turtles [count turtles in-radius 3]
[
set leader? true
set color black
set size 1.5
set leader self
set leader patches in-radius vision
]
end
This part of your code doesn't make sense:
set leader self
set leader patches in-radius vision
If you set leader twice in a row, the second set overwrites the first, so you might as well just omit the first.
In itself, this line:
set leader patches in-radius vision
could be correct, depending on what you're trying to do, although calling a variable containing a patch set leader is strange.
re: "when i vary the vision from 0-10, seems nothing is change in turtles behavior", impossible to comment without seeing the code for the turtles behavior. (If you were expecting set leader ... to have some effect on the turtles behavior all by itself, that won't happen. That one line just sets a variable. If nothing is looking at the value of that variable, then nothing further will happen as a result.)
I'd suggest looking at some of the many models in Code Examples and Sample Models that give turtles some kind of "vision", so for example Flocking, Fireflies, and so forth.