user3327938
user3327938

Reputation: 55

How to get turtles to search patches in a straight line and have a fixed prob of landing on a 'suitable' patch in netlogo

I am trying to get my turtles to search ahead of themselves in a random direction in a straight line one patch wide for a set length. With-in this line of patches there are suitable and unsuitable patches, I want the turtle to have a 50% chance of landing on any of these patches.

At the minute I have code for moving turtles to the closest suitable patch, but I am not sure how to get them to move to any of the suitable patches within their search area.

Existing code:

set visited-patches (patch-set patch-here visited-patches)
let remaining-patches suitable-patches in-cone 10 1 with [not member? self [visited-patches] of myself]
ifelse any? remaining-patches
[set target min-one-of remaining-patches [distance myself] move-to target]
[set heading random 360 fd search-radius set timeHere 0]]]

There's a global variable suitable-patches that contains the patches the turtles are searching for and turtles have a memory of the patches they've visited.

Thanks

Upvotes: 1

Views: 277

Answers (1)

JenB
JenB

Reputation: 17678

Instead of this line:

[set target min-one-of remaining-patches [distance myself] move-to target ]

try this one (untested):

[ set target ifelse-value random-float 1 < 0.5
    [ one-of remaining-patches ]
    [ one-of ... (wherever to move to the other 50% of the time) ]
  move-to target ]

Upvotes: 1

Related Questions