--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/1ed074de-8102-471f-a0cd-5dbe81493335n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/CANOZKcgmW35YCzMtHf5niw6_mJVCpG2O_znS62_XxrbZ3zfD7w%40mail.gmail.com.
Hello Michèle,Following is a sample code that assigns turtles to five age groups:turtles-own [age]
to setup
ca
reset-ticks
create-turtles 100
[
set xcor random-xcor
set ycor random-ycor
set age -1 ;set an initial value for age. This can also be '0'
]
let i 0
let prop (list 0.1 0.2 0.3 0.2 0.2) ;create list of age group proportions in the same order as groups are listed in the 'age-group' list below
let age-group (list "group1" "group2" "group3" "group4" "group5") ;create list of age groups
repeat 5 ; 5 as there are five age groups
[
let m turtles with [age = -1] ;create set of turtles with age = -1. This set will progressively grow smaller after each iteration
ask n-of (100 * item i prop) m ;select specific number of turtles from m. It will start with 100*0.1 in first iteration, 100*0.2 in second iteration and so on. 100 because there are 100 turtles.
[
set age item i age-group ;update age
]
set i i + 1 ;increment i
]
endBest,Pradeesh