文件输出Netlogo [英] File Output Netlogo
问题描述
我已经设置了generateOutput
进程,并且在每个滴答声中,该进程都必须将座席的decision
和payoff
保存在txt
文件中.
我这样编码:
I have so set generateOutput
process and in every tick this process has to save the decision
and payoff
of the agents in the txt
file.
I code it so:
to generateOutput
file-open "Sellers-Buyers.txt"
file-print "tick step, decision, payoff_seller and payoff_buyer"
end
但是我认为必须添加一些内容.我是否要添加一些新代码? 最好的问候
But I think there have to be some additions. Have i to add some new codes or? best regards
推荐答案
如果decision
,payoff_seller
和payoff_buyer
是变量,那么如果希望每个值位于文件的不同行上,则可以执行以下操作:
If decision
, payoff_seller
, and payoff_buyer
are variables, you can do this if you want each value on a different line in the file:
file-open "Sellers-Buyers.txt"
file-print decision
file-print payoff_seller
file-print payoff_buyer
file-close
请注意最后一行中的file-close
.
或者,如果您希望将所有信息都放在一行中,且之间用逗号隔开,则可以将上面的文件打印行替换为:
Or if you want all of the information on one line, with commas in between, you can replace the file-print lines above with:
file-type decision
file-type ", "
file-type payoff_seller
file-type ", "
file-type payoff_buyer
file-type "\n"
或者您可以像这样在一行中做同样的事情:
Or you could do the same thing in one line like this:
file-print (word decision ", " payoff_seller ", " payoff_buyer)
这篇关于文件输出Netlogo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!