runle
runle

Reputation: 149

File Output Netlogo

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

Upvotes: 0

Views: 711

Answers (2)

Mars
Mars

Reputation: 8854

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

Note the file-close in the last line.

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)

Upvotes: 1

Bryan Head
Bryan Head

Reputation: 12580

I believe you want something like file-print (word tick ", " decision ", " payoff_seller " and " payoff_buyer)

Upvotes: 1

Related Questions