As some of you may know(for example if you remember the itunes random generation scandal) true randomness doesn't really sit well with people because, ironically, it's not quite as "random" as we expect it to be, things repeat quite often.
And after a few tests it seems it doesn't sit well with my game eighter, so I need your help to create some pseudorandomness.
Ok, check the screenshot below.
In event nr. 4 you can see how I currently try to randomize the sprites that appear.
Could you guys please show me how the code would be if I wanted to do the following:
- on first created pick a random member of the family(as I understand it, it does this by default on created since it's a family), then pick a random frame of that member;
- on next created pick a random member of the family except the member that was previously picked, then pick a random frame of that member except the frame number that was previously picked;
- on next created pick a random member of the family except the members that where previously picked, then pick a random frame of that member except the frame numbers that where previously picked;
- after all family members have been picked reset them and the frame numbers(but keep track/remove the frames that where picked in each of them) then start picking family members again respecting the rules above;
- after all combinations of family members and frames have been picked restart the entire process(so here you would reset the family members, the frame numbers and the frames each one has available for picking).
We have this family:
- fam.member1 with frames 0, 1, 2, 3
- fam.member2 with frames 0, 1
- fam.member3 with frames 0, 1, 2, 3, 4, 5
Then we start the process and they are randomly picked(spawned) as follows:
fam.member3 frame 3
fam.member1 frame 1
fam.member2 frame 1 skipped as 1 was already chosen during this phase
fam.member2 frame 0
First batch done, this is what we have left for the next batch:
- fam.member1 with frames 0, 2, 3
- fam.member2 with frames 1
- fam.member3 with frames 0, 1, 2, 4, 5
Start picking again:
fam.member2 frame 0 skipped, while the number 0 is available to be picked in this batch, that family member no longer has that particular frame available
fam.member2 frame 1
fam.member1 frame 3
fam.member3 frame 5
Now we are left with:
- fam.member1 with frames 0, 2
- fam.member3 with frames 0, 1, 2, 4
And so on. Notice how the frame number that gets picked never repeats itself during a pick phase and it resets between phases, but we keep track and remove the frames that where picked of each individual member between phases, we only make these frames available again after the entire process has finished.
A couple of important things/problems to keep in mind:
- I tried both floor(random(8)) and random(0,8) and I didn't notice any difference, so use which ever one you think is best
- the family members don't all have the same number of frames, some have more frames some have less. That's why it's important to keep track the of the frame numbers that where picked for each family member itself.
- I don't know if it matters or not, but in event nr. 3 I show you how I spawn the monsters. I'd like to keep that part if possible.
If you need anymore info let me know.