首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的品种不能走路?

为什么我的品种不能走路?
EN

Stack Overflow用户
提问于 2017-04-14 04:42:15
回答 1查看 49关注 0票数 2

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

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

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-14 10:59:19

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

这意味着你需要做一些小的改变来指定品种。如果您在字典中查找,您将看到命令是create-<breed>。如果您有crt num-Xanthomonas,请将其更改为create-Xanthomonas num-Xanthomonas,并类似地将其更改为生成污染物的位置。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43405307

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档