答えが簡単かもしれないことを前もってお詫びします。私はnetlogoに非常に慣れていて、非常に深いところです。グローバル変数のリストを数値と比較する
ファイルから水温を読み取ろうとしているため、温度に応じて私のカメが死んでしまいます。私は最後にファイルを読み込み、水温をグローバル変数に設定しましたが、今は比較部分に固執しています。私は変数がリストであると思うので、変数を数値と比較させません。次のエラーメッセージが表示されます。
The > operator can only be used on two numbers, two strings, or two agents of the same type, but not on a list and a number.
error while turtle 7 running >
called by procedure REPRODUCE
called by procedure GO
called by Button 'go'
コードは以下のとおりです。
globals [ year
month
water-temperature ]
extensions [ csv ]
to setup
ca
load-data
create-turtles 50
[ set size 1
set color red
setxy random-xcor random-ycor ]
reset-ticks
end
to go
ask turtles [ move
reproduce ]
run-temperature
end
to load-data
file-close-all
file-open "C:\\Users\\Hannah\\Documents\\Summer research project\\test3.csv"
end
to run-temperature
file-close-all
file-open "C:\\Users\\Hannah\\Documents\\Summer research project\\test3.csv"
while [ not file-at-end? ] [
set water-temperature csv:from-row file-read-line
tick ]
file-close
end
to move
rt random 50
lt random 50
fd 1
end
to reproduce
if water-temperature > 35 [ die ]
if water-temperature > 30 and water-temperature < 34 [ hatch 1 rt random-float 360 fd 1 ]
if water-temperature > 25 and water-temperature < 29 [ hatch 2 rt random-float 360 fd 1 ]
if water-temperature > 20 and water-temperature < 24 [ hatch 3 rt random-float 360 fd 1 ]
end
ご協力いただきありがとうございます。
感謝:)
ハンナ