I'm having a hard time removing duplicates from two lists. I have code that the turtles walk through and export the coordinates of the patch they passed. I would like to remove the duplicated lines that are followed. For example: on one tick the turtle went through the patch (0 0) in sequence it just turned and continued in the patch (0 0) then went to the patch (0 1) and then back to the patch (0 0). Then I would like to know if there is a way to remove the repeated data in sequence.
In the example the .csv file would be:
patch 0 0
patch 0 0
patch 0 1
patch 0 0
I would like the .csv file:
patch 0 0
patch 0 1
patch 0 0
It is possible? If yes, how can I do it?
extensions [ csv ]
globals [Outputlist outifle]
turtles-own [ pxcor-list pycor-list mytimer ]
to setup
clear-all
set Outputlist [ [ "id" "pxcor" "pycor" "mytimer" ] ]
crt 10
[
setxy random-xcor random-ycor
set size 0.5
set pxcor-list (list pxcor)
set pycor-list (list pycor)
set mytimer [0]
pen-down
]
let pcolors [ ]
set pcolors [ 1 10 ]
ask patches [ set pcolor item (random 2) pcolors ]
reset-ticks
end
to go
if ticks = 4 [
ask turtles [ output ]
stop
]
move
tick
end
to move
ask turtles [
rt random 360
fd 1
register-coordinates
]
end
to register-coordinates
set pxcor-list lput pxcor pxcor-list
set pycor-list lput pycor pycor-list
set mytimer lput ticks mytimer
end
To output
let cur-who-list n-values ( length pxcor-list ) [ who ]
; print cur-who-list
( foreach cur-who-list pxcor-list pycor-list mytimer
[
[ a b c d ] ->
let to-append ( list a b c d )
set Outputlist lput to-append Outputlist
]
)
; Export the list to csv
csv:to-file (word outifle ".csv") Outputlist
end
Thanks in advance