~21 people with no token.
~75 people with 1 token.
~3 people with arbitary tokens (2-20).
1 counter
In phase 2 what we aim to do is pair-up all the single tokens, and let the counter collect as well. So after the first cycle you want:
~64 people with no token.
~32 people with 2 tokens.
~3 people with arbitary tokens.
1 counter
Then you want to pair-up all the people with 2 tokens, so half have their tokens removed, and half are now on 4 tokens. You want your algorithim to remember the people with arbitary conts, to convert them to standard counts - and to have the probability to leave no one on on the previous standard count.
That is, when transfering the standard count from 1 to 2, you want no one left with 1 token at the end of it. Simerly when converting 2 to 4 you want no one left with 2 at the end of it. Any left-over people will have to be compleated by phase 3, but we want it so that phase 2 should finish of the counting in most cases.
You also want the arbitary counts to be standardized. That is, while converting the standard count from 1 to 2 you want to convert all odd counts to even. Simerly you want all arbitary counts to be divisible by 4 when conveting the standard count from 2 to 4 and so on...
To do this you need to to impliment stratigic rules. Concider the first cycle:
Rules:
For non-counters:
1. If the light is off and you have an odd number of tokens, then remove one token and turn the light on.
2. If the light is on and you have an odd number of tokens, then add one token and turn the light off.
For the counter:
1. If the light is on then switch it off and add one token to the count.
The last day of the cycle (you don't want this to happen):
1. If the light is on and you have an odd number of tokens, then remove one token and leave the light on.
2. If the light is on, then add one token and turn the light off.
I estimate by the end you should expect to have:
~3 or 4 people on 16 tokens.
~96/95 people on zero tokens.
1 counter. Then let the counter have time to count the max value (16).
Then enter Phase 3 which decreases the ammount the counter counts until it reaches 1 and then stands and runs until the end. Usually it should complete with never entering phase 3.