On Jun 11, 2008, at 12:18 PM, Howard Noble wrote:
Can someone recommend a way for me to set up a <number> of agents in the
View in a grid formation, 3 patches apart horizontally and vertically. ...
Howard,
Here is a method that generates the turtles in a square grid pattern starting from the origin and spiraling out. I put the grid size on a slider too. Enjoy!
Jim Lyons
---
; Interface globals
; Number -- slider, 1 to 150 -- number of turtles to create in setup
; Grid -- slider, 1 to 5 -- turtle spacing in grid
to setup ;by observer -- create Number turtles in square grid pattern
; Note: All turtles are created even if world size is not large enough.
clear-all
create-turtles 1 ; the generator turtle, hatches the others
[ let $n 0 ; number of turtles so far on current side
let $s 0 ; current number of turtles on a side of square pattern - 1
set heading 0
repeat Number
[ hatch 1 jump Grid ; make one and move
set $n $n + 1 ; increment count on current side
if $n > $s ; if side finished...
[ right 90 set $n 0 ; turn and reset count
; if headed up or down, increment side count
if heading mod 180 = 0 [ set $s $s + 1 ]
]
]
die ; So long, and thanks for all the generating.
]
end
.