Hi again, more questions regarding best practices for the Pandemic Simulation BJC U5L2 project, I hope this is helpful for others as well as myself!
So the given implementation in the teacher's guide has the sprite drop N clones, and then hide itself, so N+1 exist. When the message is broadcast to step one iteration, the original, hidden sprite also receives that message and runs the (when I receive) hat-block script (I think).
Because of this, I chose drop N-1 clones, and leave the original unhidden, so everybody is involved.
But now I'm trying to write a custom reporter <stable?>, to go through and see if anybody is still contagious. If I loop through (my clones) or (my other clones), I only go through n-1, the original is exempt.
So I could go back to dropping N clones and hiding the original, but I might need to put checks somewhere to prevent the original from running scripts in response to broadcast messages. How do I test "am I a clone" or "am I myself"?
Or I could leave it like this, in which case, for situations where I need to loop through everybody, I guess the best thing to do is loop through (add (my self) to (my clones)) ?
I know this is kind of a picky question where there's not a definitive right answer, what I'm looking for is the path I can lead my students down that will be least likely to land them in a difficult spot
In the parent sprite (not in a clone), you can add (object [myself]) to (my [clones]) to get a list of all the clones and the original sprite. This will have to only run in the main sprite as it'll not work in a clone.
If you want to run it in a clone, and just use (my [other clones]) you'd just add (object [myself]) to (my [other clones]) to get a list of all the clones. Alternatively, you can just ask (my [parent]) for (my [clones]).
Well first of all you can't actually do
That has no effect.
What I take it you both actually meant is to compute
There's no official best practice about how to get a list of a sprite's entire family. But probably you want the parent sprite to keep a list of its children just once, instead of asking for MY CLONES repeatedly, especially in this simulation, in which nobody dies.
OK thanks. Are you saying if a clone runs (my [self]), it will return the original sprite?
OK, thanks, that's a good idea to make a list once and reuse it.
I will be with my class adding more states, including fatality, but the plan is to keep the sprite/clone around with a black costume, and no motion, and no contagion, so a fixed list will work well.
No. MY SELF returns the sprite itself. It's MY PARENT that reports the original sprite.
P.S. All this applies only to temporary clones. Permanent clones aren't reported by MY CLONES (which, yeah, is misnamed I guess).
Well that's ok I guess, because I never even heard of Permanent clones. Is that if you rmb-clone a sprite in the corral to make a new sprite?
a permanent clone is when you clone it in the sprite coral (different from duplicate), or when you set the temporary? attribute to false in a clone
theres permanent clones??
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.