Making turtles avoid stepping on patches they already stepped on

274 views
Skip to first unread message

Nikol Dimitrov

unread,
Feb 18, 2021, 1:26:13 PM2/18/21
to netlogo-users

Hi, 

I am new to NetLogo and am quite confused on how to model turtle movement. I have a landscape that consists of different landcover types: roads, residential areas, forests, and open fields. Each landcover type has its own resistance to movement value, where high values denote high resistance to movement (i.e. lower probability of stepping into that patch) and low values denote low resistance to movement:

Forest - 1 (green) 

Open Field - 2 (yellow) 

Roads - 4 (grey)

 Medium density residential - 9 (orange) 

High density residential - 10 (red)

I added some noise to the resistance values using this line of code:

   set resistance resistance + random-float 1.0

which gave me the following landscape: (linked to this question - this is a zoomed in version to show the resistance values for each patch).

I want my turtles to move down patches of lower resistance while maintaining a global direction towards forest patches. I used the downhill function and some random choice of movement using a probability variable q:

 to move 
 if landcover = 1 [set move-qualified? false]
 ifelse random-float 1.0 < q 
 [downhill resistance]
 [move-to one-of neighbors] 
  end

Using this doesn't seem to work very well because the turtles will move back to a previous patch if the resistance of its neighbors is higher. I would like them to continuously maintain a forward direction. Is there a way to make the turtles not go back to a patch they already visited?

Thanks! 

netlogo_example.png

Aaron Andre Brandes

unread,
Feb 18, 2021, 7:37:21 PM2/18/21
to Nikol Dimitrov, netlogo-users

Hi,

Just a couple of quick thoughts.

 

  1. There is a NetLogo model “Hill Climbing Example” that makes use of the uphill command to find peaks.

It makes use of the diffuse command, rather than random numbers to smooth out a distribution. You would need to make changes in order to have your different region types, and also have things go downhill.

 

  1. An artificial way of keeping a turtle from returning would be for  patches with at least one turtles-here set a high resistance.

ask patches with [ count turtles-here > 0 ] [ set resistance 100 ]

 

Under that scenario it might be possible for a turtle to get trapped.

 

Note: Opening a model in the Models Library

 

In NetLogo open the Models Library by using the menu Files => Models Library, or the shortcut Cmd-M on MacOS, Ctrl-M on other systems.

Then type your search term into the search bar in the lower left of the window.

For example if you type ‘hill climbing example’ you will get 2 examples. Only one will have the name “Hill Climbing Example”

[ the other example shows the same model with a nice visualization technique]

If you double click on the item Hill Climbing Example the model should open.

 

Aaron

 

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/c88aa1c0-12cf-42a3-9d95-6c35871c5989n%40googlegroups.com.

wade.s...@gmail.com

unread,
Feb 19, 2021, 2:48:21 PM2/19/21
to netlogo-users
I posted a solution to this problem in the modeling commons

It avoids stepping on prior patches by always moving towards the forest.
Enjoy!

Wade
Reply all
Reply to author
Forward
0 new messages