Moving turtles from extension in NetLogo - netlogo

I am working on creating a traffic grid in NetLogo. I would like to create an extension to go along with the model that contains the rules for updating the grid and moves the cars, turtles in this case, accordingly.
I am having trouble getting the turtles to actually move. The set of turtles is being passed as an argument to the function that should update the turtles' positions. I tried using setVariable(), but it isn't working for me:
Turtle car = args[0].getTurtle();
car.setVariable(AgentVariableNumbers.VAR_XCOR, 29);
car.setVariable(AgentVariableNumbers.VAR_YCOR, 40);
Since it is a traffic grid, I am focused on just moving the turtles forward for now. Is there a way (other than using setVariable) to move turtles from an extension?

Related

Netlogo - Controlling specific sets of turtles

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.

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.

Netlogo multiple patch layer

Can I create multiple patch layers in Netlogo, instead of using several patch variables in one layer?
I'm trying to integrate different maps (geology, traffic, etc.) into the Netlogo environment. So far, I've defined multiple patch variables using patches-own command. But the maps I have are not always stackable. So if I can have separate patch layers for different maps, it would be clearer.
You can't make more patch layers. The structure of the NetLogo patch world is fixed.
But you might consider representing the information using turtles instead. You can sprout them, one per patch, or you could define several breeds of turtle, and have each patch sprout one of each breed. The order in which the breeds are defined will determine the layers' stacking order, and you can hide or show whole layers using hide-turtle and show-turtle. If you want the turtles to look just like patches, do set shape "square" (adjusting the size of the "square" shapes in the turtle shapes editor if necessary).

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)

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