文件输出Netlogo

时间:2014-12-17 14:16:55

标签: file process netlogo

我已经设置了generateOutput进程,并且在每个标记中,此进程必须将decisionpayoff代理保存在txt文件中。  我这样编码:

to generateOutput

  file-open "Sellers-Buyers.txt"
  file-print "tick step, decision, payoff_seller and payoff_buyer"

end

但我认为必须有一些补充。我要添加一些新代码还是? 最好的问候

2 个答案:

答案 0 :(得分:1)

我相信你想要像file-print (word tick ", " decision ", " payoff_seller " and " payoff_buyer)

这样的东西

答案 1 :(得分:1)

如果decisionpayoff_sellerpayoff_buyer是变量,如果您希望文件中不同行上的每个值都可以执行此操作:

file-open "Sellers-Buyers.txt"
file-print decision
file-print payoff_seller
file-print payoff_buyer
file-close

请注意最后一行中的file-close

或者,如果您想要一行上的所有信息(中间有逗号),您可以用以下内容替换上面的文件打印行:

file-type decision
file-type ", "
file-type payoff_seller
file-type ", "
file-type payoff_buyer
file-type "\n"

或者你可以像这样在一行中做同样的事情:

file-print (word decision ", " payoff_seller ", " payoff_buyer)