Movement of turtles between nodes following the shortest path

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Movement of turtles between nodes following the shortest path


I hope you are having a nice day.

I am stuck in developing my NetLogo code.

I am trying to move my citizens from one node (slocation) to another node
(new-location) calculating the shortest path.
I could only calculate the distance from slocation to new-location using set
total-expected-path [distance [slocation] of myself] of new-location.

However, I am pretty sure that the next following lines in blue are not

*How can I define this distance calculate in the total-expected-path as the
minimum between nodes using the link connection between nodes?*
*and after that, how can I move the turtles following this short path?*

I attached an image of my work in NetLogo. Any help will be very useful!

Thank you so much,


to go
ask citizens

to set-timekeeper
let counter ticks
if (counter = 2)
[set timekeeper 2]

to find-day-activities
if (timekeeper = 2)

to Do_7AM_9AM
if (sex = 0 and age = 1 and employment = 0 and household-size = 0

to move-work
set slocation min-one-of nodes [distance myself]
let new-location min-one-of nodes [distance one-of workbuildings]
set total-expected-path [distance [slocation] of myself] of new-location
*ask min-one-of (citizens) [total-expected-path]*
*[ask [link-neighbors] of slocation*
*[let connection link-with slocation*
*let length-path [link-length] of connection]]*
*[move-to new-location]*

figure 2.png (380K) Download Attachment