wireless - Adding obstacle between the turtles -
i new netlogo environment , trying develop model wireless communication. came across 1 problem have block communication between 2 nodes( turtles) in such way if keep obstacle in between 2 nodes ( patch color or that), transmitting node should scan obstacle , reports end procedure. went through line of sight model , obstacle avoidance model in netlogo community of little me. node supposed scan obstacle not in range of 1 patch ahead whole distance between , other node. ideas or primitives suitable problem of great me. hope have made clear , sorry english :)
best regards
that's not efficient solution, assuming have following breeds:
breed [ obstacles obstacle ] breed [ nodes node ]
you can use following reporter:
to-report can-see? [ target ] let result false hatch 1 [ face target fd 0.1 set result ifelse-value (any? turtles-here [ self = target ]) [ true ] [ ifelse-value (any? obstacles-here) [ false ] [ can-see? target ] ] die ] report result end
it works hatch
ing whole series of temporary nodes in direction of target. if node along way encounters obstacle returns false
. if reaches target, returns true
. temporary nodes created recursively until result obtained.
you might want adjust "step size" (fd 0.1
in example): greater step size more miss corner of obstacle, faster.
you want make sure use tick based updates instead of continuous updates, or slow.
here example creates links between nodes can see each other:
to setup ca ask n-of 100 patches [ sprout-obstacles 1 [ set color red set shape "square" ] ] ask n-of 50 patches [ not any? obstacles-here ] [ sprout-nodes 1 [ set color yellow set shape "circle" let targets other nodes create-links-with targets [ can-see? myself ] ] ] end
if want use patches instead of turtles obstacles, can modify easily.
Comments
Post a Comment