0
我無法完成這個模型。這個概念是爲了向一系列海龜提出問題。每隻龜代表一個知識領域,每個問題應該包含多個隨機知識領域。要求其ID與問題中的一個域匹配的海龜被要求回答。然後根據烏龜的能力和專業知識對他們的答案進行評分。麻煩寫入文件
我希望我有代碼的骨頭在一起,但我無法驗證,直到我可以得到一些輸出到Excel。任何人都可以通過我的「書寫」說明告訴我哪裏出錯了嗎?當我運行模型時,沒有文件被更新或創建。你能發現代碼中的其他缺陷嗎?
感謝, 約翰
globals
[question
answer]
turtles-own
[abilities
expertise
expert
]
to setup
clear-all
file-open "/Users/johnhayes/ProjectFile.csv"
create-turtles 500
set question []
set answer []
reset-ticks
end
to go
ask turtles [initialise-turtles]
create-question
set answer []
ask turtles [give-an-answer]
evaluate
show (list "relevance quality" answer)
stop
tick
if ticks >= 1000 [file-close stop]
print-answers
end
to initialise-turtles ; turtle proc 1
set abilities (random 10) ; abilities assigned randomly to each turtle.
set expertise (random 10) ; expertise assigned randomly to each turtle.
set expert (FALSE)
end
to create-question
set question n-of 500 turtles
end
to give-an-answer ; turtle proc 2
if member? self question
[ set expert TRUE ] ; mark as expert
end
to evaluate ; turtle proc 3
let expert-group no-turtles
set expert-group (turtles with [expert = TRUE])
show (list ([abilities] of expert-group))
show (list ([expertise] of expert-group))
set answer lput (sum [abilities] of expert-group) answer set answer lput (sum[expertise] of expert-group) answer
end
to print-answers
file-open "/Users/johnhayes/ProjectFile.csv"
file-print answer
file-close
end
謝謝。我已經更新,但我仍然沒有得到一個打印的文件。我剛剛意識到,當我運行模型時,ticks count並沒有更新,但我正在命令中心獲取輸出。 – 2014-11-04 17:08:22
我想通了。您的解決方案解決了我的打印文件問題,但在寫入文件之前,有一個命令'停止'該過程。我的部分愚蠢的錯誤! – 2014-11-04 17:27:00
玩得開心netlogo是蜜蜂的跪姿 – 2014-11-04 17:31:13