I would like to generate an output that has three columns. A column of the turtle's profile code (code_profile). Another column saying the initial amount of turtle for that profile (no). Another column telling the final turtle quantity for that profile (nf) and finally the total amount of ticks (total_ticks). For example:
But, I'm not able to generate these columns with this information. Only columns with information about the turtle's code, the turtle's quantity and the ticks. can anybody help me?
Thanks in advance!
globals [ edge-size listProfiles ValidHabs balance ]
patches-own [ resources turtle-count ]
turtles-own [ metabolism resource-turtle code turtle-profiles turtle-code ]
to setup
ca
random-seed 1
set ValidHabs [ [1] [2] [3] [4] [5] ]
set edge-size 90
set-patch-size 12
ask patches [ set resources random 100 ]
set listProfiles [ ]
setup-patches
reset-ticks
prepare1
prepare1.2
end
to setup-patches
let list1 ( list 4 8 )
(
foreach ValidHabs [
this-profile ->
foreach list1
[
this-metabolism ->
ask n-of 1 patches
[
sprout 1
[
set turtle-profiles this-profile
set metabolism this-metabolism
setup-turtles who
]
set turtle-count count turtles-here
]
]
]
)
end
to setup-turtles [which?]
ask turtle who [
if metabolism = 4 [ set code "M1" ]
if metabolism = 8 [ set code "M2" ]
set turtle-code ( word turtle-profiles code )
print ( word "turtle-codes: " turtle-code )
]
set resource-turtle [ resources ] of patch-here
end
to go
listProfiles-turtles
ask turtles [
right random 360
fd 1
turtle-eat
reproduction
if resource-turtle >= 30 [ die ]
output
]
if ticks >= 8 [ stop ]
tick
end
to listProfiles-turtles
ask turtles [
set listProfiles lput turtle-code listProfiles
set listProfiles remove-duplicates listProfiles
]
end
to turtle-eat
set resource-turtle (resources - metabolism )
end
to reproduction
if ( resource-turtle > 30 ) [
hatch 1
set resource-turtle 0
]
end
to prepare1
carefully
[ file-delete ( word "output.csv" ) ]
[ ]
file-open ( word "output.csv" )
file-print ( word "code_profile,quantity_turtle_per_profile,tick" )
let list-profiles [ ]
ask turtles [
set list-profiles lput turtle-code list-profiles
]
set list-profiles remove-duplicates list-profiles
foreach list-profiles
[
x ->
let n count turtles with [ turtle-code = x ]
file-print ( word x "," n "," ticks".initial" )
]
file-close
end
to prepare1.2
file-open ( word "output.csv" )
let list-profiles [ ]
ask turtles [
set list-profiles lput turtle-code list-profiles
]
set list-profiles remove-duplicates list-profiles
foreach list-profiles
[
x ->
let n count turtles with [ turtle-code = x ]
file-print ( word x "," n "," ticks )
]
end
to output
file-open ( word "output.csv" )
foreach listProfiles
[
x ->
let n count turtles with [ turtle-code = x ]
; print ( word "code_profile:" x "," "quantity_turtle_per_profile:" n "," "tick: " ticks )
file-print ( word x "," n "," ticks )
]
end

