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

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.

Related

How to hide part of agents in NetLogo 6.2?

I have a 5x5 world with 10 agents in each patch in the world. I would like to hide almost everyone and only make one or 5 agents visible in the world to see their way. I only know how to do this by inspecting each agent in the interface and asking to hide it. But, I think there must be some easier way to ask to hide the 245 agents and make 1 or 5 agents visible in the world. Does anyone have any suggestions how I can do this?
Sure- there are turtle commands hide-turtle and show-turtle.
You could, for example, use this code either in setu or in a button on the interface:
ask turtles [hide-turtle] ; hide all the turtles
ask n-of 5 turtles [show-turtles] ; un-hide 5 of the turtles, selected randomly

How do I make linked turtles move together in NetLogo?

I'm trying to model fish movement and need them to form schools when there is more than 1 of the breed in a given patch. So far I have managed to get them to form links when they encounter each other with the function below, but then they continue moving independently. I'd also like to re-scale the color of turtles in a linked group so that the more turtles in the group the darker the color is (I'm guessing this is similar to the way you make contour maps according to environmental gradients but I haven't figured it out yet).
Any assistance is always appreciated!
to form_link
if count breed_1-here > 1
[
ask breed_1
[create-links-with other breed_1-here]]
end
If linking isn't the way to get them to move together, I'm fine with another method.

What is the sequence of Netlogo execution?

Have I got this correct please?
If I write:
ask turtles
[go_forward
go_backward]
is it correct that a random turtle will move forward then move backward, and then a second random turtle will do the same, and so on? As opposed to:
ask turtles [go_forward]
ask turtles [go_backward]
which will get all turtles in a random order to move forward, and then all turtles in a (different) random order to move backward.
That is correct. There's a very similar example right at the end of the section on ask in the NetLogo Programming Guide: http://ccl.northwestern.edu/netlogo/docs/programming.html#ask
See also Ask Ordering Example, in the Code Examples section of NetLogo's Models Library.

netlogo turtles moving on coordinates

I created turtles called "birds" that shall move on a specific route. The route is made out of links between turtles I called "rasts". As I couldn't find a way to make the turtles move from the first rast to the second, third, fourth and fifth, I changed the rasts an created them as patches.
So, now I have patches in red (rests).
How do I get the birds moving to exactly these patches and, when they are at the patch, how do I make them go to the next one?
I have no code at the moment, because I always hope to find the fault in my first model (see my other questions).
Is there anybody who knows how to solve my problem?
the move-to command moves your turtle to any other turtle or patch you specify. You can also use the face and forward commands to gradually move along a route (see the 'Move Towards Target' code example in the Models Library that comes with NetLogo)

What is the difference between face and towards?

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.)