netlogo turtles moving on coordinates - 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)

Related

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.

Move to the opposite location of a detected turtle

I have an agent mouse and an agent cat.
When a mouse detects the presence of a cat around him, I want the mouse to rotate to the opposite positions where it detected the cat.
You can make one agent face another with face. You can then make the agent turn around with rt 180. The result will be that they're facing exactly away from the other agent!
When you have the option of multiple cats there might be a problem when running away from just one of them...
In that case you might want to make some weighted new direction, depending on the cats in the surroundings. But then your definition of the 'empty directions' and possible problems with multiple groups of cats coming in from different directions...
alternatively, you just move-to one-of neighbors with [count cats-here == 0]
(which will probably cause a run-time error if all neighbors harbour a cat.. :-)

How to give turtles directional commands when moving along a drawn out network?

I want turtles to be able to flow along the paths I have drawn out for them. To do this I think it might be a reasonable idea to have a list in the u.i that allows the user to select a preordained direction of movement for that patch so the turtles know how to flow along the network. Has anyone else produced a model with this feature? If so would it be possible to give an example of the relevant source code for implementation into my own project?
I did something a while back where each patch had a direction variable that turtles set their heading to when on the patch.
Something like
patches-own[dir]
to go
ask turtles [set heading dir fd .1]
end

Efficient access to a Turtle's variable which is a patch address, or How to filter patches that are not assigned to turtles?

In my simulation each turtle has a my-home variable which is the patch agent family lives in, so agents with same Family-ID have same my-home until one of agents moves out or family grows to more than 7 agents.
when an agent wants to move out , I have to check if there is any patch nearby which is not another's agent my-home, what I have done is to store all my-homes in a list and check if any selected possible next home is not a member of this list, but I believe there should be better way to do this:
let all-homes [my-home] of agents with [belongs_to = BS]
set my-home min-one-of patches with [not member? self all-homes and label_ = BS][distance m]
m is current home address
min-one-of patches with ... assesses every patch in the entire world before picking a winner. That's going to be slow. I'd suggest searching nearby patches first, then farther patches, and so forth. Most of the time the turtle will find a new home after only a very brief search, so you'll have replaced code that's O(n) in the number of patches with code that's O(1)-ish. That should fix the main performance problem with this code.
The simplest such search routine I can think of is for the turtle to simply head in a random direction and keep moving fd 1 until it lands on a free patch. But if you want to do something more rigorous that always results in finding the closest possible new home, you could do that too; you'll just have more code to write.
Building the all-homes list is probably only a secondary performance problem here, but it's fixable too. The simplest fix I can think of is to add:
patches-own [home?]
initialize it with ask patches [ set home? false ], and then make sure that whenever a turtle adopts a patch as its home, it does ask my-home [ set home? true ]. Now you can replace member? self all-homes with simply home?. After all, you don't really need to know what all of the home patches are; you only need to know whether some particular patch is a home patch.