Wednesday 15 January 2014

NetLogo- randomness in the list to identify turtles in the neighbohood -



NetLogo- randomness in the list to identify turtles in the neighbohood -

i sum of specific weights in patches turtles nowadays in respective moore neighborhood. approach develop sum of products between list of weight , list of binary variables. created list of weights in neighborhood each patch

let weight_list [ 1 2 3 4 5 6 7 8]; weights of moore neighborhood specific patch

then, created list binary variable (1 if turtle nowadays in neighbour patch, 0 otherwise),

ask patches [ any? turtles-here ] [let turtle_present 1 ] inquire patches [ not any? turtles-here] [let turtle_present 0 ] inquire patches[ set binary_list [ turtle_present ] of neighbors ]

i tried multiply binary_list respective weights , sum, e.g. sum (binary_list * weight_list)

my problem binary_list sorted in random order. e.g. if have 2 turtles in neighborhood list can show [01100000] or [01000100]. randomness not allow me multiply respective weights. may dumb question relative new user of netlogo. appreciate help,

definitely not stupid question. working sorted lists of agents requires little bit of workaround, , it's not particularly intuitive.

if sort patches, come out sorted top left corner, filling out rows left right. take business relationship weight-list. since can't inquire lists things can agentsets, need iterate on list map, asking each patch study neighbors.

there bunch of different ways of doing that, suggestion write reporter along lines of this:

to-report neighbor-list study map [[ifelse-value any? turtles-here [1][0]] of ?] sort neighbors end

at point can inquire patch (or turtle, since have direct access 'their' patch's variables) neighbor-list, , send list of 1s , 0s in consistent order.

netlogo

No comments:

Post a Comment