我相信你可以修改我的例子,以配合您的問題,在總結我第一個文件讀入到一個全局列表,在每個刻度提取劑的藥劑分配屬性的數量,並運行模擬:
extensions [csv]
Breed [Drivers Driver]
turtles-own[
Name
List-Of-Actions
]
globals [li]
to setup
ca
set li []
file-open "Time.csv"
load-Files-And-Set-The-List
CreateDrivers
Set-Agents-List-Of-Actions
reset-ticks
end
to load-Files-And-Set-The-List
if file-at-end? [ stop file-close ] ;; protect against end of file
while [not file-at-end? ]
[
let _line (csv:from-row file-read-line ",")
set li lput _line li
]
end
to Set-Agents-List-Of-Actions
let t []
foreach li
[
if position ? li > 0
[
ask turtles with [Name = (item 0 ?)]
[
set hidden? false
set List-Of-Actions lput (list (item 1 ?) (item 2 ?) (item 3 ?)) List-Of-Actions
]
]
]
end
to go
ask Drivers
[
foreach List-Of-Actions
[
if ticks = (item 0 ?)
[
move-to patch (item 1 ?) (item 2 ?)
set List-Of-Actions remove ? List-Of-Actions
]
]
]
tick
end
to-report Driver-Names
let DriverNames []
foreach li
[
if position ? li > 0
[
set DriverNames lput (item 0 ?) DriverNames
]
]
set DriverNames remove-duplicates DriverNames
report DriverNames
end
to CreateDrivers
resize-world 0 500 0 3
set-patch-size 60
let n length Driver-Names
Foreach Driver-Names
[
create-Drivers 1
[
set Name ?
set shape "car"
set size 1
set hidden? true
set List-Of-Actions []
]
]
end