List Info

Thread: Setting up agents in a grid formation




Setting up agents in a grid formation
country flaguser name
United Kingdom
2008-06-11 11:18:00

Hello,

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.

e.g. something like this:

ask patches with [pxcor mod 3 = 0 and pycor mod 3 = 0] [ sprout 1 ]

but where I can only set up the number of turtles that I want (as set in
UI by slider called number).

There might be a way to do it by asking agents to go to a location in
the grid direct, rather than using sprout?

(I'll be setting up a fairly large view with small patch size to fit a
lot of agents ~ upto 1000.)

Thanks, Howard

__._,_.___
.

__,_._,___
Re: Setting up agents in a grid formation
country flaguser name
United States
2008-06-12 07:46:27

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

__._,_.___
.

__,_._,___
Re: Setting up agents in a grid formation
country flaguser name
United States
2008-06-13 12:46:18

On my site, turtlezero.com, in the model library, are several models
for distributing turtles in various ways.

http://www.turtlezero.com/models/models.php?model=distribute-turtles-grid&mode=framed

The above is a demo of arranging turtles in a grid. There are also
demos of hexagonal (dense packed) and randomized arrangements. The
random arrangement includes a method of making the turtles jostle to
find an "optimal" spread.

I also have an unpublished method to distribute turtles in somewhat
"densly packed&quot; concentric rings, should anyone need it.

~~James

On Wed, Jun 11, 2008 at 12:18 PM, Howard Noble
&lt; howard.noble%40oucs.ox.ac.uk">howard.nobleoucs.ox.ac.uk> wrote:
&gt; Hello,
&gt;
> 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.
>
> e.g. something like this:
&gt;
> ask patches with [pxcor mod 3 = 0 and pycor mod 3 = 0] [ sprout 1 ]
>
> but where I can only set up the number of turtles that I want (as set in
> UI by slider called number).
>
>; There might be a way to do it by asking agents to go to a location in
> the grid direct, rather than using sprout?
>
> (I'll be setting up a fairly large view with small patch size to fit a
> lot of agents ~ upto 1000.)
&gt;
> Thanks, Howard

__._,_.___
.

__,_._,___
[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )