如何在netlogo中设置日期

如何在netlogo中设置日期,netlogo,Netlogo,我编写了一个模型,该模型使海龟的日常生活和我分配的每一个特定的滴答声,该模型将再次重置滴答声为0,我在全局中设置了have day,每次我的模型重置时,每个循环中的天数为+1。然而,我想让它像周一,周二,…,周日,然后又回到周一 有人对代码有什么建议吗?时间延长就是为了这个。这里有一个旧版本: (单击“克隆或下载”,然后单击“下载压缩文件”。) 您可以将一个勾号设置为等于一天、一周等,然后按日期标记结果 此扩展应该准备与NetLogo的未来版本打包。如果您不需要知道实际日期,因为您只是在模拟时间

我编写了一个模型,该模型使海龟的日常生活和我分配的每一个特定的滴答声,该模型将再次重置
滴答声
为0,我在
全局中设置了have day,每次我的模型重置时,每个循环中的天数为+1。然而,我想让它像周一,周二,…,周日,然后又回到周一


有人对代码有什么建议吗?

时间延长就是为了这个。这里有一个旧版本: (单击“克隆或下载”,然后单击“下载压缩文件”。) 您可以将一个勾号设置为等于一天、一周等,然后按日期标记结果


此扩展应该准备与NetLogo的未来版本打包。

如果您不需要知道实际日期,因为您只是在模拟时间,您可以使用上面JenB在评论中提到的“mod”函数

下面是一个示例,它打印出每周循环的“day”值。该示例还提供了一个偏移量,以防您不希望在“星期一”开始,并显示了如何同时获得当天的名称(例如“星期一”)

享受吧

;; IMPORTANT NOTE  -- This doesn't look at the real world calendar, 
;;                    You have to tell it what day is day zero.
;;
;;  ticks start and zero and simply increment. You don't need to reset-ticks each week.
;;  use the variable "day" for a value that starts at "offset" and increases by one each
;;  day but also wraps back to zero automatically after it reaches 6 

globals [ 
  day         ;; a numeric value from 0 to 6 representing day of the week
  day-names   ;; a list of names of the days you'd like to use
  day-name    ;; name of the current day based on the day-names list
  offset ]

to setup
  clear-all 
  set day-names ["Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"]
  print day-names
  set offset 0 ;;   0 starts the week on Sunday, offset 1 starts on Monday, etc. 
  reset-ticks
end

to go
  if (ticks > 11 ) [stop]  ;;   don't consume the computer for this example

  set day (offset + ticks) mod 7    ;; sets day from 0 to 6
  set day-name item day day-names   ;; picks up the name for that day if you want that

  ;; and let's print them out and confirm this is what we want
  type "For offset " type offset
  type ",Tick # " type ticks type " -> day # " type day type " which is " print day-name

  tick
end

您的问题是滴答声重置而您不希望它重置,还是您希望它重置但它不重置?如果您想让它循环,请查看
mod
功能。非常感谢!实际上,我正在寻找这种代码。