我希望海龟能够从csv文件中读取和采用数据。我写了下面的代码:问题是偶数 - 虽然数据被加载,但我无法让各个海龟接受每个收入值。任何对这种效果的帮助都将不胜感激
extensions [csv]
breed [households household]
households-own [income]
globals [income-data]
to setup
load-income-data
setup-households
end
to load-income-data
set income-data []
file-open "income.csv"
while [ not file-at-end? ]
[ set income-data sentence income-data ( file-read-line)
]
user-message "income data loading complete!"
file-close
end
to setup-households
create-households 700
ask one-of households
[ setxy random-xcor random-ycor
set income income-data
]
end
答案 0 :(得分:1)
查看NetLogo模型库中的文件输入示例(代码示例)。您需要使用foreach循环导入的值/代理。