【发布时间】:2016-06-07 12:17:21
【问题描述】:
我需要将我的模拟数据保存在 netlogo 的 csv 输出文件中 每 10 个刻度我想保存几个代理的数据 但我想每次都将数据写入新列 每次他继续写新的原料的问题 有没有命令或方法可以做到这一点? 谢谢你 这是写入文件的功能 我在每个滴答声中调用它
to write-to-file [set-breed]
let n 0
let str ""
set str set-breed
file-print (word "---------- Tick Number: " ticks "-----------")
foreach my-agent-list [
ifelse ? != nobody[
ask ? [
file-print (word ": (x:y)," "(" pxcor ":" pycor"),")
file-type (word ": age," age ",")
file-print ""
set n n + 1
]][
file-type (word set-breed n ":," "dead")
set n n + 1
file-print ""
]]
file-print "" ;; blank line
file-flush
end
我得到如下结果
---------- Tick Number: 0-----------
pxcor: -70 pycor: -45 age: 0
pxcor: -61 pycor: 42 age: 0
pxcor: -91 pycor: -16 age: 0
---------- Tick Number: 1-----------
pxcor: -70 pycor: -45 age: 1
pxcor: -61 pycor: 42 age: 1
想要的应该是这样的:
---------- Tick Number: 0--------- ---------- Tick Number: 1---
pxcor: -70 pycor: -45 age: 0 pxcor: -70 pycor: -45 age: 1
pxcor: -61 pycor: 42 age: 0 pxcor: -61 pycor: 42 age: 1
pxcor: -91 pycor: -16 age: 0 pxcor: -91 pycor: -16 age: 0
【问题讨论】:
-
你试过了吗?
-
向您的问题添加任何补充代码,而不是 cmets。
-
在这种情况下您想要的输出是什么样的?