Ale
Ale

Reputation: 107

NeLogo: Use rnd extension with inverse weight reporter

I am trying to use the rnd extension in NetLogo and could use some help. I need my turtles to preferentially move to patches with low elevation; I am using the following code:

ask turtles 
  [
    face rnd:weighted-one-of patches with [distance myself < 10] [ elevation ]
    fd 1
  ]

I do not want to use a defined probability or threshold (e.g. set a value for q) but instead want patches with lower elevation to simply be selected more frequently than patches with increasing elevation (like the lottery model where larger turtles win more). However, my code currently has it so that higher elevation is selected more than lower elevations. How can I invert the weights so it's the other way around? Any help is much appreciated.

Upvotes: 0

Views: 79

Answers (1)

JenB
JenB

Reputation: 17678

Try reversing the values by subtracting from the maximum (or similar transformation). That would get you:

let max-elevation max [elevation] of patches
ask turtles 
  [ face rnd:weighted-one-of patches with [distance myself < 10]
     [ max-elevation - elevation ]
    fd 1
  ]

Upvotes: 3

Related Questions