【问题标题】:Calculate number of turtles in time Netlogo及时计算海龟数量 Netlogo
【发布时间】:2015-02-19 23:02:28
【问题描述】:

您好,我正在尝试编写一个代码,每次经过新的刻度时,我都可以知道海龟组成的差异。明确地说,我需要在第一次或第 1 次不同颜色的乌龟种群中计算蓝色的乌龟,然后在下一次或第 2 次再次计数,并计算蓝色乌龟之间的差异时间步长并且需要将该值用于其他目的,那么我可以使用哪种原语?

    let current-population-count map [count turtles with [color = ?]] colors 
    let new-population-count (map[?1 * (savage ?2)] current-population-count colors)
    set new-population-count map [num-turtles * ? / sum new-population-count] new-population-count

尝试使用此代码,但这不适用于我的目的。有什么建议吗?

【问题讨论】:

    标签: time netlogo agent ticker


    【解决方案1】:

    如果您只需要前一个时间步,那么最简单的方法是将其存储在全局变量中。如果您需要保留所有时间步长的完整历史记录,则需要使用列表。这是一个时间步代码,只有一种颜色(未测试)。

    globals [lastblue]
    
    to go
      ...
      let thisblue count turtles with [color = blue]
      if ticks > 1 [do whatever you want with thisblue and lastblue]
      set lastblue thisblue
      tick
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-12
      • 1970-01-01
      • 2018-04-11
      • 2020-08-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多