NetLogo: creation of lattice/grid resources world without using turtles?

主宰稳场 提交于 2019-12-06 11:33:10

I am not exactly sure what you need, first you mentioned you don't want to use turtles and in your own answer you have problem with the patch without a turtle.

There might be another way to approach this question:

to setup
  clear-all
  ask patches with [pxcor mod Grid = 0 and pycor mod Grid = 0] [set pcolor red]
end

And these are examples with different Grid size:

After more detailed search I found my answer here: http://netlogo-users.18673.x6.nabble.com/Setting-up-agents-in-a-grid-formation-td4864083.html

They consider to distribute turtles, not patches and then attribute patches turtles' qualities.

Here is the code:

to setup
  clear-all
  create-turtles 1
  [ let $n 0  ; actual number of turtles on this patch
    let $s 0  ; current number of turtles on a side of square pattern - 1
    set heading 0
    ask patch-here [set pcolor red]
    repeat 16   ; number of needed turtles
    [ hatch 1 jump Grid ; make one turtle and move
      set $n $n + 1 ; increment count of curent side
      ask patch-here [set pcolor red]
      if $n > $s  ; if side finished...
      [ 
        right 90 set $n 0 ; turn and reset count
        ask patch-here [set pcolor red]
        ; if headed up or down, increment side count
        if heading mod 180 = 0 [ set $s $s + 1 
          ]
      ]
    ]
   die
  ]
end

which produce:

I still don't know how to deal with 1 patch without turtle (bottom right corner), but this exemple helped me a lot ! :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!