Created
November 6, 2016 16:38
-
-
Save canadianveggie/0652b2b0dc3bcbb912fed82aaa301082 to your computer and use it in GitHub Desktop.
Hearthstone Legendary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
n_runs = 100000 | |
stars_needed_from_25_to_legendary = 10+15+20+25+25 | |
stars_above_which_no_bonus_is_awarded = stars_needed_from_25_to_legendary-25 | |
max_games = 20000 | |
def stars_to_rank(stars): | |
ranks_gained = 0 | |
if stars <= 10: | |
ranks_gained = stars / 2 | |
elif stars <= 25: | |
ranks_gained = 5 + (stars-10) / 3 | |
elif stars <= 45: | |
ranks_gained = 10 + (stars-25) / 4 | |
else: | |
ranks_gained = 15 + (stars-45) / 5 | |
return 25 - ranks_gained | |
for win_rate in range(100,49,-1): | |
win_rate = win_rate / 100.0 | |
n_legendary_runs = 0 | |
n_total_games = 0 | |
n_total_max_stars = 0 | |
for runs in range(n_runs): | |
legendary = False | |
games_played = 0 | |
won_last_game = False | |
won_second_last_game = False | |
stars = 0 | |
max_stars = 0 | |
while not legendary and games_played < max_games: | |
win = random.random() < win_rate | |
if win: | |
if won_last_game and won_second_last_game and stars < stars_above_which_no_bonus_is_awarded: | |
stars += 2 | |
else: | |
stars += 1 | |
else: | |
stars = max(0, stars - 1) | |
max_stars = max(stars, max_stars) | |
legendary = stars >= stars_needed_from_25_to_legendary | |
won_second_last_game = won_last_game | |
won_last_game = win | |
games_played += 1 | |
# print ("Win rate: {}, Games played: {}, stars: {}".format(win_rate, games_played, stars)) | |
n_legendary_runs += legendary | |
n_total_games += games_played | |
n_total_max_stars += max_stars | |
print ("Win rate: {:.0%}, Most Stars: {}, Higest Rank: {}, Legendary chance: {}, Games played: {}".format(win_rate, n_total_max_stars / n_runs, stars_to_rank(n_total_max_stars / n_runs), float(n_legendary_runs) / n_runs, n_total_games / n_runs)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Win rate: 100%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 61 | |
Win rate: 99%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 62 | |
Win rate: 98%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 63 | |
Win rate: 97%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 65 | |
Win rate: 96%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 66 | |
Win rate: 95%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 68 | |
Win rate: 94%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 70 | |
Win rate: 93%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 71 | |
Win rate: 92%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 73 | |
Win rate: 91%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 75 | |
Win rate: 90%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 77 | |
Win rate: 89%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 79 | |
Win rate: 88%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 82 | |
Win rate: 87%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 84 | |
Win rate: 86%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 87 | |
Win rate: 85%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 89 | |
Win rate: 84%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 92 | |
Win rate: 83%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 95 | |
Win rate: 82%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 98 | |
Win rate: 81%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 101 | |
Win rate: 80%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 105 | |
Win rate: 79%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 108 | |
Win rate: 78%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 112 | |
Win rate: 77%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 117 | |
Win rate: 76%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 121 | |
Win rate: 75%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 126 | |
Win rate: 74%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 131 | |
Win rate: 73%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 137 | |
Win rate: 72%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 142 | |
Win rate: 71%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 149 | |
Win rate: 70%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 156 | |
Win rate: 69%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 164 | |
Win rate: 68%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 172 | |
Win rate: 67%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 182 | |
Win rate: 66%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 192 | |
Win rate: 65%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 203 | |
Win rate: 64%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 216 | |
Win rate: 63%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 231 | |
Win rate: 62%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 247 | |
Win rate: 61%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 266 | |
Win rate: 60%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 287 | |
Win rate: 59%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 313 | |
Win rate: 58%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 344 | |
Win rate: 57%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 379 | |
Win rate: 56%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 426 | |
Win rate: 55%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 483 | |
Win rate: 54%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 560 | |
Win rate: 53%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 663 | |
Win rate: 52%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 813 | |
Win rate: 51%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 1048 | |
Win rate: 50%, Most Stars: 95, Higest Rank: 0, Legendary chance: 1.0, Games played: 1440 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment