user2359494
user2359494

Reputation: 733

Sprouting turtles in NetLogo based on patch value

I have loaded an ASCII file in NetLogo with values (ranging from 0 - 4.6) that represent the mean number (of a Poisson process) of turtles inhabiting the patch. I'd like to setup the model to sprout turtles on each patch using random-poisson with the mean value derived from the ASCII file. I know how to ask n-of patches to sprout a certain number of turtles but I don't know how to ask the sprout command to act on all patches. Any help would be great!

Upvotes: 1

Views: 1053

Answers (1)

Marzy
Marzy

Reputation: 1894

If your problem is asking all patches you can use following:

to setup 
  clear-all
  resize-world 0 10 0 10
  set-patch-size 40
  let ASCII-file-Values   n-values 121 [ random-poisson mean n-values 121[random-float 4.6]]
  let patches_list sort patches


  let i 0 
  foreach patches_list [
    ask ? [

      sprout item i ASCII-file-Values  
      set plabel count turtles-here
    ]
    set i i + 1
  ]

  reset-ticks      
end

The only section which answers your question is the foreach patches_list [] If you need values assigned to the patches to be used later, another way could be adding a varible to each patch and set this value in the foreach loop, then you can ask patches [ sprout my-value]

enter image description here

Upvotes: 3

Related Questions