netlogo - Perspective based ranking? -
i have program each peer has own ranking system of other peers, best way implement netlogo?
normally, solve 2d list:
[[turtle 1, score], [turtle 2, score], ...]
but seems troubling in netlogo. code creating , modifying 2d list:
to test clear-all crt 10 ;create list of turtles let agents-list [self] of turtles ;create empty list, top level of twod list let twod-list [] ;populate twod-list: [[turtle 0, 0], [turtle 1, 0], ...] foreach agents-list [ set twod-list (lput (list ? 0) twod-list) ] show twod-list repeat 5 [ ;change value in twod-list let rand-index random (length twod-list) ;select random index ;the next line makes huge headache, have select list @ top level replace, , select list @ lower level replace it. ;this entire line of code adding 1 element set twod-list (replace-item rand-index twod-list (replace-item 1 (item rand-index twod-list) (item 1 (item rand-index twod-list) + 1))) show twod-list ] end
what else can do? or there better way implement method?
if want model relations between agents, netlogo has perfect thing that: links!
having each turtle assign score other turtles can quite naturally expressed as:
directed-link-breed [ rankings ranking ] rankings-own [ score ] setup clear-all create-turtles 10 ask turtles [ create-rankings-to other turtles ] ; increment 5 random rankings one: ask n-of 5 rankings [ set score score + 1 ] ; display rankings of each turtle: ask turtles [ show [ (word end2 " " score) ] of my-out-rankings ] end
if don't want links show in view, can hide them with:
ask links [ set hidden? true ]
Comments
Post a Comment