的NetLogo行为空间并不指望我的品种之一

时间:2019-02-02 16:04:06

标签: netlogo

我正在研究一个模型来模拟荷兰的tick叮咬。我的代码完成了,现在我想使用行为空间来生成输出文件。我在我的模型有两个品种,“居民”和“游客-2D”。无论从品种,我想看看有多少海龟有蜱叮咬。居民品种在工作,而游客品种则没有。任何人可以帮助我如何解决这一问题?我认为这是因为我的游客品种来自清单,但我不知道如何解决。即使我只是简单地使用“ count Visitor-2d”,“行为空间”的输出也为0。

globals [ month month-day week week-day tourist-2d-list ]
breed [ residents resident ]
breed [ tourists-2d tourist-2d ]

to setup
  ca
  file-close-all
  reset-ticks

; ---------- Creating tourist-lists -----------
  set tourist-2d-list (list 1 1 2 4 8 17 38 85 188 420 935 2086 4651 10371 18750 18750 10371 4651 2086 935 420 188 85 38 17 8 4 2 1 1)
end

to go
  set month ceiling(ticks / 30)
  set month-day (ticks mod 30)
  set week ceiling(ticks / 7)
  set week-day (ticks mod 7)

; ---------- Set tick dynamics per month ----------

  if month = 13 and month-day = 1 [reset-ticks]

; ---------- Set 2-day tourist dynamics per week ----------

 initialize-tourists-2d

  tick

 remove-tourists
end


to initialize-tourists-2d
    if week-day = 6 [
    if week > 14 and week < 45 [
      create-tourists-2d item (week - 15) tourist-2d-list [set color pink set shape "person" setxy -14 -7 set stay-period 2 set day-counter 0 ]
    ]
  ]
end

to remove-tourists
  ask tourists-2d [set day-counter (day-counter + 1)
    if day-counter = stay-period [die]
  ]
end

我代码中的其他信息,旅行者2d列表是全球性的,而旅行者2d则是一个品种。如果有人可以帮助我,那就太好了!

1 个答案:

答案 0 :(得分:1)

请针对此类问题发布一个最小的工作示例。如下所示:

globals [tourist-2d-list week-day week]
breed [tourists-2d tourist-2d]

to setup
  set tourist-2d-list (list 1 1 2 4 8 17 38 85 188 420 935 2086 4651 10371 18750 18750 
                            10371 4651 2086 935 420 188 85 38 17 8 4 2 1 1)
  reset-ticks
end

to go
  if (ticks > (45 * 7)) [stop]
  set week-day ticks mod 7
  set week (int ticks / 7)
  add-tourists
  tick
end

to add-tourists
if week-day = 6 and week > 14 and week < 45 [
  create-tourists-2d item (week - 15) tourist-2d-list [init-tourist]
  print (count tourists-2d) ;print to debug
]
end

to init-tourist
  ; put initializations here
end

如您所见,计数不为零。