Reputation: 137
im just trying to count the patches that have a certain color and add that count number to a variable. Then, if the number of neighbors crosses a threshold the patch changes color but im getting a Set expected 2 inputs. I think this is a basic question but after reading i dont get the result i need.
patches-own
[reforestar
;deforestar
;temperatura
;humedad
;dosel
]
to setup
clear-all
set-default-shape turtles "frog top"
ask patches with [
pxcor <= 30 and
pxcor >= min-pxcor and
pycor <= 60 and
pycor >= min-pycor ] [
set pcolor 35 ;
]
;potrero
ask patches with [
pxcor <= 60 and
pxcor >= 30 and
pycor <= 60 and
pycor >= min-pycor ] [
set pcolor 44 ;
]
;borde
ask patches with [
pxcor <= 90 and
pxcor >= 60 and
pycor <= 60 and
pycor >= min-pycor ] [
set pcolor 66 ;
]
end
to go
ask patches [ deforestacion ]
end
to potrerizar
if pcolor = 44 [
ask patches [ set potrerizado count neighbors with [pcolor = 35] ]]
end
to deforestacion
if potrerizado >= 3 [if random 100 <= tasa-deforestacion
[set pcolor = 35]]
Thanks in advance
Upvotes: 0
Views: 267
Reputation: 2926
Regarding set
, it's indeed because set
expects two inputs: the variable to set and its new value, without any other sign between these two inputs - see here. You had also used it correctly in to setup
.
In NetLogo, =
is instead used to evaluate conditions (i.e. it expects two inputs, one on the right and one on the left, and it returns either true
or false
). Therefore, writing
set pcolor = 35
is the same as writing
set true ; if the patch has pcolor = 35, or
set false ; if the patch has pcolor != 35.
none of which makes sense in NetLogo.
As for the rest: at the moment, what your code does entirely depends on the value of potrerizado
that is set in the interface:
set pcolor 35
). Which means that, sooner or later, they will all be brown.In the code, at the moment, to potrerizar
is never used.
Anyway, I can see that to potrerizar
asks patches to change potrerizado
, which is a global
variable.
Probably what you want is to have potrerizado
as patches-own
and not as global
, but this is just my guess based on what I can see here.
Less important, you have some superflous conditions: every patch will always have pxcor >= min-pxcor
(and similar conditions that you have in to setup
).
Upvotes: 1