首页 > 解决方案 > 使用 NetLogo 停止在特定补丁的限制上移动海龟

问题描述

我是 NetLogo 的新手。在我的模拟练习中,我想阻止火灾和树木出现在代表城市的某些斑块中。

这是我的一些代码。

to setup
    ca
    forest-fire
    city
end
to forest-fire
  create-forest trees[
    set color green
    set shape "square"
    set size 0.5
    setxy random-xcor random-ycor]
  create-fires pt-fire [
    set color red
    set shape "square"
    setxy random-xcor random-ycor]
end
to city  
  set a one-of (range -10 10)
  ask patches with [pxcor <= a and pxcor > a - 3 and pycor < a and pycor >= -2]
  [ set pcolor 6 ]
end
  ask forest-fire [
    ask neighbors with [pcolor = 6] [die]]

标签: netlogo

解决方案


我找到了你的解决方案,谢谢,所以 ask patches with [pcolor = blue ] [ ask turtles-here[die] ] 火灾的树木解决方案
if any? patches with [count turtles-here >= 2 and pcolor = blue] [ stop ]


推荐阅读