Rdb
Rdb

Reputation: 21

Set variable value on basis of distance to patches with a certain value in Netlogo

In my model I want to give patches with a distance smaller than 10 to roads a lower attractiveness

What I want is that patches with land use 1 that already have a attractiveness of for example 1.7 to get a lower attractiveness if they are close to a road (land-use 5). I think this part of code should work, however, the "patches with [ Land-use = 5 ]" part is not recognized by net logo. Can anyone help?

  Ask patches with [ Land-use = 1 ][
if (distance patches with [ Land-use = 5 ]  ) < 10 [
  set Attractiveness (Attractiveness + -0.5 )]]

Upvotes: 0

Views: 60

Answers (1)

adkane
adkane

Reputation: 1441

Would something like the following work for you where I use in-radius?

patches-own [Land-use Attractiveness]
to setup
  clear-all
  ask patches [set Land-use random 6]
  ask patches with[land-use = 1] [set pcolor red]

Ask patches with [ Land-use = 1 ][
if any? patches in-radius 10 with [ Land-use  = 5 ]   [
  set Attractiveness (Attractiveness + -0.5 )]]

reset-ticks
end 

Then for your the additional requirement you mention in your comment all you need to do is modify the statement with [Land-use = 5] to [ Land-use = 4 or Land-use = 5 or Land-use = 6]

Upvotes: 1

Related Questions