patch - NetLogo 使品种在某些补丁中生成

标签 patch netlogo

我对 NetLogo 很陌生,我希望这是一个足够简单的问题。我创建了两个品种[redteam redsoldier][blueteam bluesoldier]我想做的是让不同的品种在特定的补丁中生成。因此,红队只能在窗口的一半(红色区域)之一随机生成,蓝队随机在另一半(蓝色区域)生成,但是在尝试多个 if 和 while 语句以及其他操作后,海龟只能在窗口的一半(红色区域)中生成。屏幕中央。

有什么想法吗?

globals [
red-patches
blue-patches 
]

;; note patches could not be set to only green as this partly clashed with soldiers     uniform

breed [ redteam redsoldier]
breed [ blueteam bluesoldier]

to setup
clear-all
setup-turtles
setup-patches
reset-ticks
end

to setup-turtles
create-redteam 10
 [
   set shape "person soldier" ;;need to import person soldier shape!
   setxy random-pxcor random-pycor
   set size 1.5
 ]

create-blueteam 10
 [
   set shape "person soldier" 
   setxy random-pxcor random-pycor
   set size 1.5
 ]
 end

to setup-patches
;; create red territory
set red-patches patches with [pycor < 0]
ask red-patches [ set pcolor green - 3 ]

;; create blue territory
set blue-patches patches with [pycor > 0]
ask blue-patches [ set pcolor green - 2 ]  
end

最佳答案

执行此操作的一个简单方法是使用 sprout .

这是一个新版本的setup-turtles(需要在setup-patches之后调用):

to setup-turtles
  ask n-of 10 red-patches [
    sprout-redteam 1 [
      set shape "person soldier"
      set size 1.5
    ]
  ]
  ask n-of 10 blue-patches [
    sprout-blueteam 1 [
      set shape "person soldier"
      set size 1.5
    ]
  ]
end

关于patch - NetLogo 使品种在某些补丁中生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22276571/

相关文章:

social-networking - NetLogo:向链接邻居询问滴答计数器值

netlogo - 从列表中选取元素

wait - 让海龟等待 x 刻度数

c - 通过修补源将自定义参数添加到 imagemagick

c# HttpClient 带有正文的补丁请求?

linux - 无效命令名称 "Agent/rtProto/OSPF"

NetLogo - 如何显示海龟的当前坐标

file - 为什么我无法从网络 Logo 的 txt 文件中读取字符串?

linux - 如何处理这个补丁问题

没有/a/b 的 Git diff 补丁?