Advertisement
yojimbos_law

regarding queue considerations on the boning knife

Oct 21st, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. //initial queue state having none of the NCs
  2. > run queue quest simulator.ash
  3.  
  4. with an olfactiony thing adding 6 additional copies
  5. we spend an average of 2.73708 turns, give or take 2.164906451049976 turns
  6. to encounter 1 of a noncombat in a place with 4 noncombats
  7. =================================
  8.  
  9.  
  10. //initial queue state having all of the undesirable NCs
  11. > run queue quest simulator.ash
  12.  
  13. with an olfactiony thing adding 6 additional copies
  14. we spend an average of 2.34463 turns, give or take 1.7646334753744415 turns
  15. to encounter 1 of a noncombat in a place with 4 noncombats
  16. =================================
  17.  
  18.  
  19.  
  20. //assumptions: http://kolspading.com/forums/viewtopic.php?f=2&t=455
  21. //source code:
  22.  
  23. int[int] buffer_queue;
  24. boolean olfacted = false;
  25.  
  26. int nc_select_with_olfaction(int n, int copies, int skippable, boolean rejecting){
  27. int selection = -1;
  28. boolean in_queue;
  29. int rejection_roll = n+copies+1;
  30. while(selection == -1){
  31. if(olfacted){
  32. selection = min( random(n+copies) , n-1 );
  33. if(selection != n-1 || rejecting){
  34. in_queue = false;
  35. for i from 1 to 5{
  36. if(selection == buffer_queue[i]){
  37. in_queue = true;
  38. }
  39. }
  40. if(in_queue){
  41. rejection_roll = random(4);
  42. if(rejection_roll != 1){
  43. selection = -1;
  44. }
  45. }
  46. }
  47. }
  48. else{
  49. selection = random(n);
  50. in_queue = false;
  51. for i from 1 to 5{
  52. if(selection == buffer_queue[i]){
  53. in_queue = true;
  54. }
  55. }
  56. if(in_queue){
  57. rejection_roll = random(4);
  58. if(rejection_roll != 1){
  59. selection = -1;
  60. }
  61. }
  62. }
  63. }
  64. if(selection >= skippable){
  65. for i from 2 to 5 {
  66. buffer_queue[i-1] = buffer_queue[i];
  67. }
  68. buffer_queue[5] = selection;
  69. }
  70. if(selection == n-1){
  71. olfacted = true;
  72. }
  73. return selection;
  74. }
  75.  
  76.  
  77.  
  78. int trials = 100000;
  79. int monster_counter;
  80. int monsters_in_place = 4;
  81. int monsters_to_find = 1;
  82. int banishes_available = 0;
  83. int extra_copies = 6;
  84. boolean rejectiness = true;
  85. int[int] trial_combats;
  86. int[int] trial_banishes;
  87. boolean[int] banishes;
  88. int turns_since_nc;
  89. float average;
  90. float sexually_transmitted_disease;
  91.  
  92. clear(trial_combats);
  93. clear(trial_banishes);
  94. for i from 1 to trials{
  95. trial_combats[i] = 0;
  96. trial_banishes[i] = 0;
  97. monster_counter = 0;
  98.  
  99. buffer_queue[1] = -1;
  100. buffer_queue[2] = 0;
  101. buffer_queue[3] = 1;
  102. buffer_queue[4] = 2;
  103. buffer_queue[5] = -1;
  104. /*
  105. buffer_queue[1] = -1;
  106. buffer_queue[2] = -1;
  107. buffer_queue[3] = -1;
  108. buffer_queue[4] = -1;
  109. buffer_queue[5] = -1;
  110. */
  111. olfacted = true;
  112. turns_since_nc = 0;
  113.  
  114. while( monster_counter < monsters_to_find){
  115. while(random(100) < 100-45 && turns_since_nc < 10){
  116. trial_combats[i]++;
  117. turns_since_nc++;
  118. }
  119. if( nc_select_with_olfaction( monsters_in_place , extra_copies , 6 , rejectiness ) == ( monsters_in_place - 1 ) ){
  120. monster_counter++;
  121. trial_combats[i]++;
  122. }
  123. else{
  124. turns_since_nc = 0;
  125. }
  126. }
  127. }
  128.  
  129. string textiness = "";
  130. if(!rejectiness){
  131. textiness += " and removing rejection";
  132. }
  133. print("with an olfactiony thing adding "+extra_copies+" additional copies"+textiness);
  134. foreach i in trial_combats{
  135. average += trial_combats[i];
  136. }
  137.  
  138. average /= trial_combats.count().to_float();
  139.  
  140. foreach i in trial_combats{
  141. sexually_transmitted_disease += ( trial_combats[i].to_float() - average ) ** 2;
  142. }
  143.  
  144. sexually_transmitted_disease /= trial_combats.count().to_float() - 1.0;
  145. sexually_transmitted_disease = sexually_transmitted_disease ** (0.5);
  146.  
  147. print("we spend an average of "+average+" turns, give or take "+sexually_transmitted_disease+" turns");
  148.  
  149. print("to encounter "+monsters_to_find+" of a noncombat in a place with "+monsters_in_place+" noncombats");
  150. print("=================================");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement