netlogo - 使用 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]]
解决方案
我找到了你的解决方案,谢谢,所以
ask patches with [pcolor = blue ] [ ask turtles-here[die] ]
火灾的树木解决方案
if any? patches with [count turtles-here >= 2 and pcolor = blue] [ stop ]
推荐阅读
- linux - 如何在网络驱动器上安装 conda?
- c# - 当我处于 ReceiveAndDelete 模式时,是否需要调用 CompleteMessageAsync?
- keycloak - Keycloak 运算符:如何添加自定义主题?
- r - 按组查找非零值的分数
- c# - 在 Windows 服务中从事件处理程序启动计时器
- reactjs - 用户选择一个选项并在 ReactJS 中按下提交后重新呈现选择选项
- flutter - 发生异常。PlatformException (PlatformException(失败, 失败, null, null))
- python - 请求编码文本和内容之间的区别
- google-chrome - Chrome 90 中的自动播放策略
- reactjs - 如何使用 Redux 添加排序?