在 Netlogo 中,为什么蓝色补丁没有超过橙色补丁?为什么它在跳动?

In Netlogo, why are the blue patches not overtaking the orange patches? why is it pulsing?

我在之前的帖子中解决了这个问题,但我遇到了一个新问题。我正在尝试放弃恢复过程。一开始橙色和蓝色流动很快,但是一旦它们相互作用就无法获胜并且只是在它们之间一遍又一遍地变化。在代码中,我确定如果一个补丁是橙色的并且它看到至少 3 个蓝色它应该变成蓝色,而且我没有确定如果一个蓝色补丁被橙色包围它会改变,但是它发生了。这个想法是,在设置时我有 3 种颜色,并且有一些滑块(如果 reforestado >= 3 [如果随机 100 <= SLIDER]),补丁会发生变化,最终变成蓝色(75)和一点点绿色 (66) 应该会赢得显示 restauraton

这段代码可以复制粘贴,应该可以,忽略出现的红色补丁。请设置世界的垂直限制。

为什么橙色没有再次失去蓝色?

提前致谢。

 patches-own
[bordear
abandono
reforestado
potrerizado
temperatura
humedad
dosel
]
breed [ potreros potrero ]
breed [ bordes borde ]
breed [ bosques bosque ]

to setup
  resize-world 0 90 0 60
  clear-all

  ask patches with [
    pxcor <= 30 and
    pxcor >= min-pxcor and
    pycor <= 60 and
    pycor >= min-pycor ] [
    set pcolor 35
    set temperatura 26.5
    set dosel 1
   set humedad 90.4
  ]
 ;Potrero
  ask patches with [
    pxcor <= 60 and
    pxcor >= 30 and
    pycor <= 60 and
    pycor >= min-pycor ] [
    set pcolor 44
    set temperatura 29
    set dosel 84.3
   set humedad 79.3;
  ]
  ;Borde
  ask patches with [
    pxcor <= 90 and
    pxcor >= 60 and
    pycor <= 60 and
    pycor >= min-pycor ] [
    set pcolor 66
   set temperatura 26.3
   set dosel 85.2
   set humedad 94 ;
  ]
  ;Bosque

 ;se establece la forma de la rana

 ; Se establecen las condiciones de las ranas, tamaño color y lugar de aparicion. La energia sera igual en todas las ranas en el set up.

   create-potreros 50

  [ set size 3        ;; easier to see
    set color yellow
setxy random xcor random ycor
move-to one-of patches with [pcolor = 35]
    set heading random 45 + 45
    set energia 50
 ]   ;; red = not carrying food

 ;Potrero



    reset-ticks
end

to go
  ask potreros [
    if energia < 50 [descansar-potrero]
    if energia >= 50 and energia <= 80 [move-potrero]
    if energia > 80 [ if ticks mod 50 = 0 [reproducirse]]
    set heading random 270
      fd 1
 set energia energia - 2
  morir]

  ask patches [ restauracion ]
  ask patches [ deforestacion ]
  ask patches [abandonacion]
  ask patches [borderizacion]


if ticks >= 500 [stop]
tick
end

to restauracion
  if pcolor = 44 or pcolor = 25 or pcolor = 35[
     set reforestado count neighbors with [pcolor = 66 or pcolor = 75] ]
  if reforestado >= 3 [if random 100 <= 100 [
    set pcolor 75
    set temperatura 24.4 + random 3
    set humedad 91 + random 9
    set dosel 82 + random 5 ]
  ]


end


to deforestacion
  if pcolor = 44 or pcolor = 25 or pcolor = 75 or pcolor = 66 [
     set potrerizado count neighbors with [pcolor = 35] ]
  if potrerizado >= 3 [if random 100 <= 0 [
    set pcolor 35
    set temperatura 22.7 + random 5
    set humedad 84.5 + random 10
    set dosel 0 + random 10]
  ]
end
to abandonacion
  if pcolor = 35 [
     set abandono count neighbors with [pcolor = 44 or pcolor = 25] ]
  if abandono >= 3 [if random 100 <= 50 [
    set pcolor 25
    set temperatura 24.6 + random 8
    set humedad 68 + random 14
    set dosel 79 + random 9]
  ]

end

to borderizacion
  if pcolor = 66 [
     set bordear count neighbors with [pcolor = 44] ]
  if bordear >= 3 [if random 100 <= 50 [
    set temperatura 24 + random 6
    set humedad 80 + random 20
    set dosel 80 + random 5]
]

end

to move-potrero
  ask neighbors in-radius 2
     [if temperatura >= 28.6 or temperatura <= 22.6 or dosel >= 5 or humedad <= 84
      [ set pcolor red
       ;facexy random 30 random 60
      ;fd 5
      ;set energia energia - 10]]
    ;[ask potreros [descansar-potrero]]
  ]]



end

to descansar-potrero
  ifelse pcolor = 35 [
    set energia energia + 6]
  [set energia energia + 1]

end

to reproducirse
  if energia > 80 [ if random 100 > 60 [set energia energia - 70
      hatch 1 [ rt random-float 360 fd 2
      set energia energia / 3]]]
end
  to morir
  if energia <= 1 [die]

end ```

现在,一旦你的补丁将 abandono 设置为 to abandonacion 中的某个值,它们就不会重置它,除非它们的 pcolor 返回到 35。所以,你有 all 个评估 if abandono >=3... 代码的补丁。要快速修复以了解我的意思,请将 to abandonacion 块更改为:

to abandonacion
  set abandono 0
  if pcolor = 35 [
    set abandono count neighbors with [pcolor = 44 or pcolor = 25] ]
  if abandono >= 3 [if random 100 <= 50 [
    set pcolor 25
    set temperatura 24.6 + random 8
    set humedad 68 + random 14
    set dosel 79 + random 9]
  ]
  
end

上面只是在评估 abandano 计数之前将 abandono 重置为 0,以确保所有补丁都“新鲜”地开始。还有其他方法可以解决这个问题,但您实际如何处理可能取决于您是否跟踪每个滴答的 abandono 补丁数量。