Reputation: 51
I am trying to program the simulation with 3 sets of agents - A,B,C. The point is that the agents from the set A can choose to DO the action or NOT. If they decide to NOT do the action, the simulation stops. When they decide to DO the action, simulation continues to the next step, where the agents from the set B can also decide to DO the action or not. The same is here. And the agents from the set C, can also decide to DO the action or NOT, but here, the simulation in both cases stops. Here is my code:
ask turttles [
if breed = set A [ ifeslse do?= false [ set lazy]
stop]
[ if breed = set B [ ifelse do1?= false [ set lazy]
stop]
[ask other turtles [ if breed = set C [ ifelse do 2? = false [ set lazy
stop] ]
[set done
stop] ]
]
]
]
The code does not work very good,I need somehing to link these three step, because when I export-world, I got data only from the first step
Upvotes: 2
Views: 402
Reputation: 30508
If you do stop
inside of an ask
, it won't cause the whole simulation to stop. It will only stop the current turtle from executing the rest of the ask
.
I think you want something more like:
globals [done?]
to setup
...
set done? false
...
end
to go
if done? [ stop ]
ifelse ...
[ ask A [ do-action ] ]
[ set done? true ]
ifelse ...
[ ask B [ do-action ] ]
[ set done? true ]
ifelse ...
[ ask C [ do-action ] ]
[ set done? true ]
...
end
But I'm guessing somewhat, since it's difficult to tell from your description what your actual intentions are. (Especially since you haven't included your real code — the coede in your question wouldn't get past the compiler.)
Upvotes: 1