Netlogo 为什么赢了';我的狗不会走路吗?

Netlogo 为什么赢了';我的狗不会走路吗?,netlogo,Netlogo,我正在一个生物反应器内建立一个模型种群,建立在一个告诉我如何进食、繁殖和死亡等的基本教程的基础上。在修修补补时,我的海龟停止了行走。我怀疑这与如何要求不同的品种做事情有关 编辑:出于某种原因,我的污染物也不是“轮子” 海龟拥有[能量] 自己的[营养] 品种[黄单胞菌黄单胞菌] 繁殖[污染物] 全球的 [黄原胶生物量] 设置 清除所有 安装补丁 设置默认形状Xanthomonas“bug” 设置“轮子”的默认形状 黄单胞菌 [设置颜色为黄色 设置能量10 setxy随机xcor随机ycor ] 犯

我正在一个生物反应器内建立一个模型种群,建立在一个告诉我如何进食、繁殖和死亡等的基本教程的基础上。在修修补补时,我的海龟停止了行走。我怀疑这与如何要求不同的品种做事情有关

编辑:出于某种原因,我的污染物也不是“轮子”

海龟拥有[能量]
自己的[营养]
品种[黄单胞菌黄单胞菌]
繁殖[污染物]
全球的
[黄原胶生物量]
设置
清除所有
安装补丁
设置默认形状Xanthomonas“bug”
设置“轮子”的默认形状
黄单胞菌
[设置颜色为黄色
设置能量10
setxy随机xcor随机ycor
]
犯规
测定生物量
重置滴答声
;; 开始定义名为“setup”的过程
;; 将世界重置为初始的空状态
;; 创造了100只海龟,它们从原点0,0开始
;; 设置默认形状,这样我就不必每次都告诉它
;; 海龟的颜色变量在指定之前是随机的
;; 具有下两个数字作为输入的setxy命令
;; 为允许的x和y坐标选择随机报告器
终点
设置修补程序
询问补丁
[将颜色设置为绿色
设定营养50
]
;; 每个补丁都以50种营养开始,颜色为我们指明了方向
结束
犯规
设置“轮子”的默认形状
如果污染?
[crt-num污染物
[设置颜色为红色
setxy随机xcor随机ycor
]
竞争]
结束
外带
如果滴答声>=2000[停止]
如果海龟计数>2000[停止]
如果计数海龟=0[停止]
喂养
搬海龟
问海龟
[吃葡萄糖]
问黄单胞菌
[复制]
制止死亡
打上钩
结束
测定生物量
还有什么污染?
[设置黄单胞菌数量+污染物数量
]
[设置黄单胞菌数量]
结束
搬海龟
;; 每个海龟都应该运行括号中的命令
;; random不包括您作为可能结果给出的数字
;; 使用一个报告器,每只海龟选择一个0到359之间的随机整数
;; 让乌龟向前走一步
;;指定您定义的每一步将损失1能量
问黄单胞菌
[右随机360
转发1
设置能量-1]
结束
喂
如果连续进给?
[询问补丁]
[如果随机100<3
[将颜色设置为绿色
设置营养+50
] ] ]
结束
吃葡萄糖
问黄单胞菌
[如果pcolor=绿色
[设置能量+10
设置营养-50
设置颜色为灰色
设置生物量+1
] ]
如果其他人表现出活力?
[设置标签能量]
[设置标签“”]
;;在“如果”之前询问海龟
;;如果为true,则只有在该情况下,海龟才会运行括号内的命令(否则它将跳过这些命令)
;;正确/错误的问题,如果为真,将使用第一组括号
;;false表示turtle在第二组括号中运行命令
;;能量(元素)将默认为零
结束
复制
问黄单胞菌
[如果能量>50
[设置能量-50
设置黄原胶黄原胶+1
孵化黄单胞菌1
[设定生物量+1
rt随机浮点360 fd 1
] ] ]
结束
制止死亡
问黄单胞菌
[如果能量<0
[死亡]
]
结束
重新记录
询问补丁[
如果随机100<10
[将颜色设置为绿色
]
]
结束
污染
crt-num污染物
[设置颜色为红色
setxy随机xcor随机ycor
]
结束
竞争
询问污染物
[如果能量>50
[设置能量-50
设置黄原胶黄原胶+1
舱口污染物1
[设置颜色为红色
设置生物量+1
rt随机浮点360 fd 1
] ] ]
结束

好的,您的基本问题是
crt
命令。这是创建海龟的缩写。你们这里有两个品种,你们已经定义了它们。然而,当你创造海龟时,你并没有告诉NetLogo要创造哪个品种

这意味着你需要做一些小的改变来指定品种。如果查看字典,您将看到命令是
create-
。如果您有
crt num Xanthomonas
,请将其更改为
create Xanthomonas num Xanthomonas
,同样,也可以将其更改为创建污染物的位置

turtles-own [ energy ]  
patches-own [ nutrition ]
breed [ Xanthomonas Xanthomona ]
breed [ contaminants contaminant ]

globals 
[ xanthan biomass ]

to setup
  clear-all
  setup-patches
  set-default-shape Xanthomonas "bug"
  set-default-shape contaminants "wheel"
  crt num-Xanthomonas
  [set color yellow
    set energy 10 
    setxy random-xcor random-ycor
  ]
  foul
  determine-biomass
   reset-ticks
    ;; begins defining a procedure named "setup"
    ;; resets the world to an initial, empty state
    ;; creates 100 turtles, they start out standing at the origin 0,0
    ;; set default shape so I don't have to tell it every time
    ;; A turtle's color variable is random until specified
    ;; setxy command with next two numbers as inputs
    ;; chooses random reporters for allowable x and y coordinates
End

to setup-patches 
  ask patches
  [ set pcolor green
    set nutrition 50
  ]
  ;; every patch starts with 50 nutrition, the color indicates it for us
end

to foul
  set-default-shape contaminants "wheel"
  if Contamination?
  [ crt num-contaminants
    [ set color red
        setxy random-xcor random-ycor
  ]
  compete ]
end

to go
  if ticks >= 2000 [ stop ]
  if count turtles > 2000 [stop]
  if count turtles = 0 [stop]
    feed
  move-turtles
  ask turtles 
  [eat-glucose]
  ask Xanthomonas
  [reproduce]
  check-death
    tick
end

to determine-biomass
  ifelse Contamination?
    [set biomass num-Xanthomonas + num-contaminants
    ]
        [set biomass num-Xanthomonas ]
end 

to move-turtles   
  ;; says that each turtle should run the commands in the brackets
  ;; random doesn't include the number you give it as a possible result
  ;; uses a reporter, each turtle picks a random whole number between 0 and 359
  ;; makes the turtle move forward one step
  ;;specify what you're defining will lose 1 energy per step
 ask Xanthomonas
 [ right random 360
   forward 1
   set energy energy - 1 ]
end

to Feed
  if Continuous-feed?
    [ ask patches
      [if random 100 < 3
      [set pcolor green
    set nutrition nutrition + 50
      ] ] ]
end

to eat-glucose
  ask Xanthomonas
   [ if pcolor = green 
    [ set energy energy + 10
      set nutrition nutrition - 50
      set pcolor gray
      set biomass biomass + 1
    ] ]
  ifelse show-energy?
    [ set label energy ]
    [ set label "" ]
  ;;ask turtles before "if"
  ;;if when true, and only then will the turtle run the commands inside the brackets (otherwise it skips them)
  ;;true/false questions, if true, will do first set of brackets
  ;;false means turtle runs commands in second set of bracket
  ;;energy (elements) will default to zero
end

to reproduce
  ask Xanthomonas
  [ if energy > 50
    [set energy energy - 50
      set xanthan xanthan + 1
      hatch-Xanthomonas 1
      [set biomass biomass + 1
        rt random-float 360 fd 1
      ] ] ]
  end

  to check-death
    ask Xanthomonas
    [ if energy < 0 
      [ die ]
    ]
 end

to reinoculate
    ask patches [
      if random 100 < 10 
      [ set pcolor green 
      ]
    ]
end

to Contaminate
  crt num-contaminants
  [ set color red
    setxy random-xcor random-ycor
  ]
end

to compete
  ask contaminants
  [ if energy > 50
    [set energy energy - 50
      set xanthan xanthan + 1
      hatch-contaminants 1
      [ set color red 
        set biomass biomass + 1
        rt random-float 360 fd 1
      ] ] ]
end