Thanks Bryan--That's a good solution. Hadn't thought of it. (Seems obvious, now!) I'll probably do that. And I appreciate knowing that uniqueness is deeply embedded in the nature of agentsets.
Roman, you're right--I should have called that what I was proposing an "agentmultiset". On Friday, February 6, 2015 at 10:30:05 AM UTC-6, Bryan Head wrote: > > Hi Marshall, > > Writing you're own ask-procedure that operates on lists could be a pretty > easy workaround. For instance: > > to ask-list [ agent-list commands ] > foreach agent-list [ ask ? [ run commands ] ] > end > > which you then call like: > > ask-list agents-with-repeats task [ do-stuff ] > > Where `agents-with-repeats` is your list of agents. Note the `task` > primitive is unfortunately required. Besides that, this should pretty much > be a drop-in replacement for `ask` after you switch to using a list. `of` > could be similarly transformed: > > to-report of-list [ agent-list reporter ] > report map [ [ runresult reporter ] of ? ] agent-list > end > > Called like: of-list agents-with-repeats task [ turtle-variable ] > > Now `with`: > > to-report with-list [ agent-list predicate ] > report filter [ [ runresult reporter ] of ? ] agent-list > end > > Called like: with-list agents-with-repeats task [ turtle-variable = 5 ] > > Besides reordering arguments and requiring `task`, these should pretty > much be drop-in replacements for their agentset counterparts. As you said, > the uniqueness of agents in agentsets is quite baked in. > > Hope that helps! > Bryan > > On Fri Feb 06 2015 at 10:00:48 AM Marshall <[email protected] > <javascript:>> wrote: > >> A model I'm working on includes a series of functions that implement a >> random choice of turtles that will send messages to another turtle. >> Recently, I decided it might be better to allow the selection of senders to >> be random with repeats. Nicolas Payette's rnd extension >> <https://github.com/NetLogo/Rnd-Extension> provides a convenient >> function that provides this functionality, returning a list that may >> contain repeats: weighted-n-of-with-repeats. (Thanks Nicolas!) >> >> However, converting a list of turtles with repeats into a turtleset loses >> the repeats; agentsets contain only unique elements. So if I want to allow >> repeats in the turtles that send messages, I have to rewrite a small but >> significant bit of code in different functions, replacing ask's with loops, >> etc. >> >> Question: Might it be useful to allow a new kind of agentset that allows >> repeats? It would be useful to me in this situation, but I know that the >> idea violates longstanding assumptions about agentsets, and I suspect that >> it would also require a lot of changes to the NetLogo source to implement. >> >> I thought I'd raise it as a question, anyway, to see what others think. >> >> -- >> 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 [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
