Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //here's the script:
- int[int] buffer_queue;
- boolean olfacted = false;
- int select(int n){
- int selection = -1;
- boolean in_queue;
- int rejection_roll = 4;
- while(selection == -1){
- selection = random(n);
- in_queue = false;
- for i from 1 to 5{
- if(selection == buffer_queue[i]){
- in_queue = true;
- }
- }
- if(in_queue){
- rejection_roll = random(4);
- if(rejection_roll == 1){
- selection = -1;
- }
- }
- }
- for i from 2 to 5 {
- buffer_queue[i-1] = buffer_queue[i];
- }
- buffer_queue[5] = selection;
- return selection;
- }
- int select_with_olfaction(int n, int copies, boolean rejecting){
- int selection = -1;
- boolean in_queue;
- int rejection_roll = n+copies+1;
- while(selection == -1){
- if(olfacted){
- selection = min( random(n+copies) , n-1 );
- if(selection != n-1 || rejecting){
- in_queue = false;
- for i from 1 to 5{
- if(selection == buffer_queue[i]){
- in_queue = true;
- }
- }
- if(in_queue){
- rejection_roll = random(4);
- if(rejection_roll == 1){
- selection = -1;
- }
- }
- }
- }
- else{
- selection = random(n);
- in_queue = false;
- for i from 1 to 5{
- if(selection == buffer_queue[i]){
- in_queue = true;
- }
- }
- if(in_queue){
- rejection_roll = random(4);
- if(rejection_roll == 1){
- selection = -1;
- }
- }
- }
- }
- for i from 2 to 5 {
- buffer_queue[i-1] = buffer_queue[i];
- }
- buffer_queue[5] = selection;
- if(selection == n-1){
- olfacted = true;
- }
- return selection;
- }
- int trials = 10000;
- int monster_counter;
- int monsters_in_place = 10;
- int monsters_to_find = 1;
- int banishes_available = 2;
- int extra_copies = 0;
- boolean rejectiness = true;
- int[int] trial_combats;
- int[int] trial_banishes;
- boolean[int] banishes;
- float average;
- float sexually_transmitted_disease;
- for a from 2 to 10{
- for b from 0 to min(2,a){
- monsters_in_place = a;
- banishes_available = b;
- average = 0.0;
- sexually_transmitted_disease = 0.0;
- clear(trial_combats);
- clear(trial_banishes);
- for i from 1 to trials{
- for j from 1 to monsters_in_place{
- banishes[i] = false;
- }
- trial_banishes[i] = 0;
- monster_counter = 0;
- for j from 1 to 5{
- buffer_queue[j] = -1;
- }
- olfacted = false;
- while( monster_counter < monsters_to_find){
- if(monsters_in_place - trial_banishes[i] == 1){
- monster_counter++;
- }
- else{
- if( select_with_olfaction( monsters_in_place - trial_banishes[i] , extra_copies , rejectiness) == ( monsters_in_place - trial_banishes[i] ) - 1 ){
- monster_counter++;
- }
- else{
- if(trial_banishes[i] < banishes_available){
- trial_banishes[i]++;
- }
- }
- }
- trial_combats[i]++;
- }
- }
- string textiness = "";
- if(!rejectiness){
- textiness += " and removing rejection";
- }
- print("with "+banishes_available+" banishes available, and an olfactiony thing adding "+extra_copies+" additional copies"+textiness);
- foreach i in trial_combats{
- average += trial_combats[i];
- }
- average /= trial_combats.count().to_float();
- foreach i in trial_combats{
- sexually_transmitted_disease += ( trial_combats[i].to_float() - average ) ** 2;
- }
- sexually_transmitted_disease /= trial_combats.count().to_float() - 1.0;
- sexually_transmitted_disease = sexually_transmitted_disease ** (0.5);
- print("we fight an average of "+average+" monsters, give or take "+sexually_transmitted_disease+" monsters");
- average = 0.0;
- sexually_transmitted_disease = 0.0;
- foreach i in trial_banishes{
- average += trial_banishes[i];
- }
- average /= trial_banishes.count().to_float();
- foreach i in trial_banishes{
- sexually_transmitted_disease += ( trial_banishes[i].to_float() - average ) ** 2;
- }
- sexually_transmitted_disease /= trial_banishes.count().to_float() - 1.0;
- sexually_transmitted_disease = sexually_transmitted_disease ** (0.5);
- print("with an average of "+average+" banishes, give or take "+sexually_transmitted_disease+" banishes");
- print("to encounter "+monsters_to_find+" of a monster in a place with "+monsters_in_place+" monsters");
- print("=================================");
- }
- }
- =======================================================================================================================
- //here's the output:
- > run queue quest simulator.ash
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 1.886 monsters, give or take 1.2143111031138625 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 2 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 1.5016 monsters, give or take 0.5000224417405889 monsters
- with an average of 0.5016 banishes, give or take 0.5000224417405889 banishes
- to encounter 1 of a monster in a place with 2 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 1.4958 monsters, give or take 0.5000073606819214 monsters
- with an average of 0.4958 banishes, give or take 0.5000073606819214 banishes
- to encounter 1 of a monster in a place with 2 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 2.7791 monsters, give or take 2.0476138459792232 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 3 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 2.3095 monsters, give or take 1.4117043036359178 monsters
- with an average of 0.6669 banishes, give or take 0.47134552788868295 banishes
- to encounter 1 of a monster in a place with 3 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 1.9961 monsters, give or take 0.8202146458132532 monsters
- with an average of 0.9961 banishes, give or take 0.8202146458132532 banishes
- to encounter 1 of a monster in a place with 3 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 3.6378 monsters, give or take 2.8845871878528153 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 4 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 3.1157 monsters, give or take 2.265000338334012 monsters
- with an average of 0.7388 banishes, give or take 0.43931066386553763 banishes
- to encounter 1 of a monster in a place with 4 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 2.7364 monsters, give or take 1.6025516706758145 monsters
- with an average of 1.2441 banishes, give or take 0.8366511749342944 banishes
- to encounter 1 of a monster in a place with 4 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 4.506 monsters, give or take 3.7518757518293757 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 5 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 3.9599 monsters, give or take 3.010448184212248 monsters
- with an average of 0.7965 banishes, give or take 0.4026213610776342 banishes
- to encounter 1 of a monster in a place with 5 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 3.4825 monsters, give or take 2.3299434786409177 monsters
- with an average of 1.3989 banishes, give or take 0.7992763441184667 banishes
- to encounter 1 of a monster in a place with 5 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 5.4749 monsters, give or take 4.709138731101486 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 6 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 4.7957 monsters, give or take 3.896957805521442 monsters
- with an average of 0.8339 banishes, give or take 0.3721889875644576 banishes
- to encounter 1 of a monster in a place with 6 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 4.3247 monsters, give or take 3.1749138441525386 monsters
- with an average of 1.4921 banishes, give or take 0.7673307433218705 banishes
- to encounter 1 of a monster in a place with 6 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 6.3065 monsters, give or take 5.527369440456562 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 7 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 5.7137 monsters, give or take 4.745417179597643 monsters
- with an average of 0.8612 banishes, give or take 0.34575499222929945 banishes
- to encounter 1 of a monster in a place with 7 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 5.1557 monsters, give or take 3.963032686315772 monsters
- with an average of 1.5776 banishes, give or take 0.7227935272595675 banishes
- to encounter 1 of a monster in a place with 7 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 7.3707 monsters, give or take 6.50160815497713 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 8 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 6.4322 monsters, give or take 5.463770533143205 monsters
- with an average of 0.872 banishes, give or take 0.33410651402851016 banishes
- to encounter 1 of a monster in a place with 8 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 5.9248 monsters, give or take 4.787362201012619 monsters
- with an average of 1.6201 banishes, give or take 0.7000178515575809 banishes
- to encounter 1 of a monster in a place with 8 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 8.2587 monsters, give or take 7.441808406646514 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 9 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 7.5795 monsters, give or take 6.652405970813946 monsters
- with an average of 0.8881 banishes, give or take 0.3152591455182519 banishes
- to encounter 1 of a monster in a place with 9 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 6.8332 monsters, give or take 5.806767570254704 monsters
- with an average of 1.6589 banishes, give or take 0.6764588307169813 banishes
- to encounter 1 of a monster in a place with 9 monsters
- =================================
- with 0 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 9.2137 monsters, give or take 8.480767928228246 monsters
- with an average of 0.0 banishes, give or take 0.0 banishes
- to encounter 1 of a monster in a place with 10 monsters
- =================================
- with 1 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 8.501 monsters, give or take 7.681946382917871 monsters
- with an average of 0.8993 banishes, give or take 0.30094611952424577 banishes
- to encounter 1 of a monster in a place with 10 monsters
- =================================
- with 2 banishes available, and an olfactiony thing adding 0 additional copies
- we fight an average of 7.6424 monsters, give or take 6.556067452524079 monsters
- with an average of 1.6953 banishes, give or take 0.6424166715753709 banishes
- to encounter 1 of a monster in a place with 10 monsters
- =================================
Advertisement
Add Comment
Please, Sign In to add comment