fork download
  1. # Pocket Camp Complete - Fortune Cookie Simulator
  2.  
  3. import random
  4.  
  5. NUM_OF_SIMULATIONS = 20
  6. NUM_OF_COOKIE_TYPES = 182
  7.  
  8. # These are the rates pulled directly from the app.
  9. # Each row must have all 10 item rates in ascending order.
  10. LIST_OF_ALL_COOKIE_ODDS = [
  11. [2.53, 7.06, 7.06, 7.06, 7.06, 13.85, 13.85, 13.85, 13.85, 13.85],
  12. [3.41, 9.47, 9.47, 9.47, 9.47, 11.74, 11.74, 11.74, 11.74, 11.74],
  13. [3.01, 7.33, 7.33, 7.33, 7.33, 13.53, 13.53, 13.53, 13.53, 13.53],
  14. [3.11, 6.97, 6.97, 6.97, 6.97, 13.80, 13.80, 13.80, 13.80, 13.80],
  15. [3.39, 9.83, 9.83, 9.83, 11.19, 11.19, 11.19, 11.19, 11.19, 11.19],
  16. [3.01, 9.22, 9.22, 9.22, 9.22, 12.02, 12.02, 12.02, 12.02, 12.02],
  17. [2.72, 7.26, 7.26, 7.26, 7.26, 13.65, 13.65, 13.65, 13.65, 13.65],
  18. [2.83, 7.14, 7.14, 7.14, 7.14, 13.73, 13.73, 13.73, 13.73, 13.73],
  19. [2.32, 6.75, 6.75, 6.75, 6.75, 14.14, 14.14, 14.14, 14.14, 14.14],
  20. [2.61, 9.32, 9.32, 9.32, 9.32, 12.02, 12.02, 12.02, 12.02, 12.02],
  21. [2.65, 6.82, 6.82, 6.82, 6.82, 14.01, 14.01, 14.01, 14.01, 14.01],
  22. [3.03, 7.62, 7.62, 7.62, 7.62, 13.29, 13.29, 13.29, 13.29, 13.29],
  23. [3.09, 7.82, 7.82, 7.82, 7.82, 13.13, 13.13, 13.13, 13.13, 13.13],
  24. [2.93, 6.66, 6.66, 6.66, 6.66, 14.08, 14.08, 14.08, 14.08, 14.08],
  25. [3.13, 9.03, 9.03, 9.03, 9.03, 12.15, 12.15, 12.15, 12.15, 12.15],
  26. [2.75, 6.26, 6.26, 6.26, 6.26, 14.44, 14.44, 14.44, 14.44, 14.44]
  27. ]
  28.  
  29. # This is the number of times each cookie rate was seen in February and March
  30. OCCURANCE_OF_COOKIE_ODDS = [3, 3, 2, 2, 7, 1, 1, 3, 2, 1, 1, 1, 1, 2, 1, 1]
  31.  
  32. def cookie_simulation_all_items_with_stamps(balk_num):
  33. item_indexes = [i for i in range(10)]
  34. pull_stats = [0] * NUM_OF_COOKIE_TYPES
  35. stamp_count = 0
  36.  
  37. for c in range(NUM_OF_COOKIE_TYPES):
  38. pull_count = 0
  39. owned_items = [False] * 10
  40.  
  41. # Get a random set of cookie odds
  42. cookie_odds = random.choices(population=LIST_OF_ALL_COOKIE_ODDS, weights=OCCURANCE_OF_COOKIE_ODDS, k=1)[0]
  43.  
  44. while not all(owned_items):
  45. # Pull five cookies at a time
  46. pulled_cookies = random.choices(population=item_indexes, weights=cookie_odds, k=5)
  47. pull_count += 5
  48. stamp_count += 6
  49.  
  50. # Mark which items were given
  51. for p in pulled_cookies:
  52. owned_items[p] = True
  53.  
  54. # If we've eaten a lot of cookies and still haven't gotten the item,
  55. # try to buy it with stamps.
  56. if not all(owned_items) and pull_count >= balk_num:
  57. # Because this walks the array from forward to back, it tries to buy the 5-star
  58. # item first. This is intentional. If you run out of stamps and still need
  59. # to buy cookies, then you'll have better odds pulling the 3 or 4-star items.
  60. for i in range(10):
  61. if not owned_items[i]:
  62. # 5-star item
  63. if cookie_odds[i] < 4.0:
  64. if stamp_count >= 100:
  65. owned_items[i] = True
  66. stamp_count -= 100
  67. # 4-star item
  68. elif cookie_odds[i] < 10.0:
  69. if stamp_count >= 50:
  70. owned_items[i] = True
  71. stamp_count -= 50
  72. # 3-star item
  73. else:
  74. if stamp_count >= 10:
  75. owned_items[i] = True
  76. stamp_count -= 10
  77.  
  78. pull_stats[c] = pull_count
  79.  
  80. return sum(pull_stats)
  81.  
  82.  
  83. max_box_pull_balk_point = 12
  84. results = [[0] * NUM_OF_SIMULATIONS for _ in range(max_box_pull_balk_point)]
  85.  
  86. for i in range(NUM_OF_SIMULATIONS):
  87. for b in range(max_box_pull_balk_point):
  88. results[b][i] = cookie_simulation_all_items_with_stamps(balk_num=(b+1)*5)
  89.  
  90. for b in range(max_box_pull_balk_point):
  91. results[b] = sorted(results[b])
  92. bottom_five_index = max(1, int(NUM_OF_SIMULATIONS * 0.05))
  93. top_five_index = NUM_OF_SIMULATIONS - bottom_five_index - 1
  94. median_index = int(NUM_OF_SIMULATIONS / 2)
  95.  
  96. print(f'Cumulative cookies purchased to complete {NUM_OF_COOKIE_TYPES} collections. Simulated {NUM_OF_SIMULATIONS} times.')
  97. print('| Use stamps after X pulls | Best | 5% | Median | 95% | Worst | Average |')
  98. for b in range(max_box_pull_balk_point):
  99. print(f'| {(b+1)*5:02d} | {results[b][0]} | {results[b][bottom_five_index]} | {results[b][median_index]} | {results[b][top_five_index]} | {results[b][-1]} | {round(sum(results[b]) / NUM_OF_SIMULATIONS)} |')
  100.  
Success #stdin #stdout 1.46s 14344KB
stdin
Standard input is empty
stdout
Cumulative cookies purchased to complete 182 collections. Simulated 20 times.
| Use stamps after X pulls |  Best  |   5%   | Median |   95%  |  Worst | Average |
|            05            |  6775  |  6865  |  7325  |  7695  |  7705  |  7318   |
|            10            |  6620  |  6835  |  7185  |  7325  |  7795  |  7113   |
|            15            |  6320  |  6420  |  6885  |  7150  |  7220  |  6845   |
|            20            |  6005  |  6145  |  6360  |  7000  |  7100  |  6457   |
|            25            |  5930  |  5975  |  6320  |  6720  |  6810  |  6310   |
|            30            |  5790  |  5840  |  6160  |  6600  |  6730  |  6180   |
|            35            |  5840  |  5845  |  6180  |  6490  |  6575  |  6126   |
|            40            |  6065  |  6090  |  6270  |  6530  |  6535  |  6289   |
|            45            |  6375  |  6380  |  6640  |  6760  |  6805  |  6618   |
|            50            |  6520  |  6675  |  6870  |  7095  |  7185  |  6871   |
|            55            |  6740  |  6805  |  7195  |  7395  |  7425  |  7141   |
|            60            |  6880  |  6890  |  7295  |  7675  |  7675  |  7278   |