I'm having some difficulty exporting a result in .csv from NetLogo.
I would like to extract information from the path taken by various turtles in the world. That is, extract its coordinates (as if it were the path that is marked with the pen-down command) but it is the coordinates that I throw in another program and reproduce the path made by each turtle. The idea is to have all the coordinates of the path taken by each turtle. I'm doing the following code below, but, the following error keeps appearing: this code cannot be executed by a patch, only a turtle error while patch -16 16 running FILE-PRINT called by (anonymous command: [ t -> ask t [ file-print word self ": pxcor: " pxcor " pycor: " pycor " turtle-id: " who ] ]) called by procedure OUTPUT called by procedure GO called by 'go' button
Is it possible for me to extract to a .csv file all the coordinates of a path made by every turtle in the world?
Thanks in advance
to setup
ca
reset-ticks
crt 10
ask turtles [
setxy random-xcor random-ycor
pen-down
]
let pcolors [ ]
set pcolors [ 1 10 ]
ask patches [ set pcolor item (random 2) pcolors ]
end
to go
move
let n count turtles
if n = 0 and output? = true [output] ;; ouput? is an switch on interface
if n = 0 [ stop ]
tick
end
to move
ask turtles [
rt random 360
fd 1
if ticks >= 5
[ die ]
]
end
to output
file-open "test.csv"
file-print ( word "---------- Tick Number: " ticks "-----------" )
foreach sort patches
[
t ->
ask t
[
file-print ( word self ": pxcor: " pxcor " pycor: " pycor " turtle-id: " who )
]
]
file-print "" ;; blank line
file-close
end
--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/CAHs8kB9VQ3KuqDQQ-23L1zfweM1%2Bay0jzdfCidDwsRBGTx5q9g%40mail.gmail.com.