Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trial = 0;
- total_days = 0;
- n_trials = 100;
- while (trial<n_trials)
- {
- trial++;
- random_set_seed(current_time);
- for (i=0;i<100;i++) prisoner[i] = false;
- lightOn = false;
- counter = 0;
- days = 0;
- // First prisoner to enter is the light master
- counter++;
- prisoner[0] = true;
- lightOn = true;
- while(counter<100)
- {
- days++;
- i = irandom(99);
- if (!prisoner[i] and lightOn)
- {
- prisoner[i] = true;
- lightOn = false;
- }
- if (i==0 and !lightOn)
- {
- lightOn = true;
- counter++;
- }
- }
- total_days += days;
- }
- show_message("Average assertion time: "
- +string(total_days/n_trials/365)
- +" years after "+string(n_trials)+" trials.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement