How to print matrix data of patches from Netlogo in a excel file? -
i particularly working "flocking" model of netlogo. want select agent , if other agent there next 3 patches of selected agent.i want check around agent matrix form of data , save in excel/cvs file.
unfortunately don't have definitive answer you, i'd imagine you'll want of sort:
globals [ output_matrix] patches-own [occupied?] setup clear-all reset-ticks create-turtles 50 set output_matrix [] end go move tick end move ask turtles [set heading random-float 361 forward random-float 2 ] ask patches [count turtles-here > 0] [set occupied? 1] ask patches [count turtles-here = 0] [set occupied? 0] check_surroundings end check_surroundings ask turtles [ ifelse any? turtles-on patch-ahead 1 [set output_matrix lput 1 output_matrix] [set output_matrix lput 0 output_matrix]] ask turtles [ ifelse any? turtles-on patch-ahead 2 [set output_matrix lput 1 output_matrix] [set output_matrix lput 0 output_matrix]] ask turtles [ ifelse any? turtles-on patch-ahead 3 [set output_matrix lput 1 output_matrix] [set output_matrix lput 0 output_matrix]] end that give 2 options. 1 use behavior space output full patch list every tick in file (which you'd specify in behavior space) simple 0 or 1 each patch represent whether it's occupied or not. second option use output_matrix list creates (not sure end game is). give series of 3 0's , 1's each turtle @ every tick (if want estimate how aggregation forms on time might more useful).
you may want in output-print , file-open/file-close primitives
i'm sure if generate sample code, community able further.
Comments
Post a Comment