Hi Ken,
I started this discussion as I rewrote the segregation model.
I made many changes to code, info window and view. But I was mulling over many 
different alternatives for find-new-spot.  A top goal of mine is to make it 
easily accessible to novice programmers as it is one of the first models people 
see. So, while your solution is elegant for more advanced coders, I wouldn’t 
want to use it for the library version of segregation. 
And, to solve the loop forever problem, we can set the slider to max out at 
99%, and put a note in the info window about the possibility of looping forever.

—Uri

Uri Wilensky






On Dec 30, 2014, at 1:18 PM, Ken Kahn <toont...@gmail.com> wrote:

> I too like find-new-spot but I once used a similar procedure and all was well 
> until it was used in a context in which every patch was occupied. 
> find-new-spot looped forever. At least move-to one-of patches with [not any? 
> turtles-here] reports a helpful error if there are no unoccupied patches.
> 
> On the other hand while performance isn't an issue for the Segregation Model 
> that may not always be the case when move-to-unoccupied-patch is called in 
> other models. Note that move-to-unoccupied-patch should on average be faster 
> than find-new-spot when nearly all patches are occupied. 
> 
> Another issue with find-new-spot is how to make a generic version where 
> turtles-here is not always appropriate. E.g. households-here might be needed 
> if there are other breeds of turtles on patches.
> 
> How about this?
> 
>  to find-new-spot [satisfying-condition]
>     move-to one-of neighbors4
>     if not run satisfying-condition
>       [ find-new-spot]
>  end
> 
>  to find-new-spot-without-any-turtles-here
>    find-new-spot task [not any? other turtles-here]
>  end
> 

-- 
You received this message because you are subscribed to the Google Groups 
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to netlogo-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to