netlogo - Two turtles running 'similar' code at the same time -


ive got strange issue code going on.

in model have female (set female true) , males (set male true).

upon particular trigger each 'become' disperser (set disperser true).

dispersers , non dispersers have different behaviour.

i have tried solving different breeds representing 2 classes has not worked.

the problem 1 of turtles e.g. male, operate accordingly , set disperser 'false' upon meeting opposite turtle. other not, , continue disperser set 'true'

im sure because once 1 of turtles operates code, no longer 'disperser' , therefore no longer applys search criteria of later turtle every work around ive tried has resulted in same problem or nobody errors.

to search-for partner     if male = true [ set potential-mates other turtles [female = true     , disperser = true]     if female = true [ set potential-mates other turtles [male = true     , disperser = true]      let chosen-mate min-one-of potential-mates [distance myself]      if any? potential-mates [         set heading towards chosen-mate]      if male = true [ if any? other turtles-here [female = true ,         disperser = true] [set disperser false]      if female = true [ if any? other turtles-here [male = true ,         disperser = true] [set disperser false] end 

i'm not entirely convinced know want do, think asking set disperser false both turtles. in case want code looks (not tested):

if male [ let my-partner one-of other turtles-here [female , disperser ]   if my-partner != nobody   [ set disperser false     ask partner [ set disperser false ]   ] ] 

you should consider separating 'search partner' code 'found partner' code. also, may better off having them check if have partner, search partner setting heading closest , moving forward. @ moment around don't go anywhere.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -