Re: [netlogo-users] avoid duplicate turtle visits

42 views
Skip to first unread message

Wade Schuette

unread,
Jan 6, 2022, 3:31:21 PM1/6/22
to netlogo-users
You probably want to have the bizs own some variable like "visited",  which you can initialize to zero . ( or trust the system to do that but I prefer to be sure it gets done. ). 

Then instead of visiting a "biz" you want to only visit "bizs with [visited = 0]"

By the way, your code"  [move-to one-of [neighbors] of one-of bizs]"  moves prts to "neighbors" which the dictionary says are patches,  so you are asking your prt to move to a patch which is adjacent to the patch  that some biz is on,  not to a biz.

One solution might be to make your biz's patches, since they don't ever move, and recode your logic.
If you use patches, you don't need to invent a new variable, you could use pcolor to flag whether a patch has been visited or not,
which handles both the logical tracking and makes a visual display that is more informative.


 






On Thu, Jan 6, 2022 at 1:20 PM rbsoc...@gmail.com <rbsoc...@gmail.com> wrote:

I have two groups of turtles, prts (n=2) and bizs (n=10).  The mobile prts visit the immobile bizs.  My command to do this is:

ask one-of prts [move-to one-of [neighbors] of one-of bizs]

My question is how do I get the prts to only visit unvisited bizs?  More specifically, if prt1 visits bz1, I want neither prt1 nor prt2 to visit biz1 again.

Thanks, RB

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/a6ac18fa-019a-462a-a645-b6eb7d451825n%40googlegroups.com.

rbsoc...@gmail.com

unread,
Jan 7, 2022, 9:07:52 AM1/7/22
to netlogo-users
Thanks for suggestions to address problems, one I identified and one not.  On the turtle vs. patch problem, have been trying to change turtle color but makes sense to change patch color.
Best, RB
Reply all
Reply to author
Forward
0 new messages