In a Netlogo network, how can turtles "see" properties of other turtles? -


i trying build model in turtles decide change colour depending on environment in network.

the approach "check" colour of surrounding turtles , set if statement turtle in question switch colour (there 2 colours).

specifically know how can turtle "see" or check other turtles' colour (or other properties).

if possible create slider "how many links away" can turtles see neighbouring turtles' (or neighbours of neighbours, etc) colour.

i new both netlogo , stackoverflow, please let me know if should make modifications model and/or question.

thanks!

carlos

welcome stack overflow! typically you'll want stick single question per post, both simplicity , benefit of future users similar questions. well, in cases applicable should try include code show you've tried far, setup necessary- want make minimal, complete, , verifiable example. in case, think you're okay since questions clear , explained, if have more complex questions in future more useful answers following guidelines.

for first question, looks want of primitive- check out dictionary entry details. of can used in few ways, including allowing agents check value of variable (such color) of agent. check out example code:

to setup   ca   reset-ticks   crt 10 [     setxy random 30 - 15 random 30 - 15     create-link-with one-of other turtles   ] end  go   ask turtles [     set color [color] of one-of link-neighbors   ] end 

every time go procedure called, 1 of turtles changes color color of 1 of link-neighbors. if run long enough, connected turtles should end same color.

for second question, suggest check out nw extension, extension built deal more netlogo networks. specifically, have @ nw:turtles-in-radius, should work slider approach. working, include extension using

extensions [ nw ]

at start of code. then, assuming same setup above, can play around like

to network-radius   ask one-of turtles [     set color red     ask other nw:turtles-in-radius 2 [       set color white     ]   ] end 

when call network-radius procedure above, should see 1 turtle turn red, , turtles within 2 links of turtle turn white. switch slider, swap "2" out slider variable. hope helps!


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -