Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Python 3 script for figuring out the best Ignite Mage deck
- # by Lt.Labcoat
- import random
- import sys
- start_hand = []
- # unused card names:
- # biscuit-maker 2manadraw1 3manadraw2 heropower 3manaspellsearch jaxon 2manaspellsearch
- # ice-search-2mana firesale sapience wonder-deck spicebaker
- # Tradeables: 6
- # Deck size: 30
- # Chance to win if survived to turn 5: 0.65528 - Average turns: 5.26672625
- # TODO: Sivara odds should be higher. Just treated as an ice block right now.
- # TODO: ETC calculations. Currently treated as a dead card.
- deck_base = ["evoc",
- "tradeable", "firstflame",
- "ele", "tradeable", "tradeable",
- "ice",
- ] * 2
- deck_base += ["sorc", "sorc"]
- deck_base += ["volume", "sivara", "rewind", "rewind", "ETC", "rommath"]
- deck_base += ["volume", "ignite", "reflection", "hotstreak", "magister", "2manadraw1"]
- deck_base += ["ice-search-2mana-spell", "sapience"]
- print(f'Tradeables: {deck_base.count("tradeable")}')
- spells = ["hotstreak", "evoc", "biscuit-maker", "firstflame", "ignite", "ice", "reflection", "heropower", "firesale",
- "springwater", "volume", "rewind"]
- spells_chandler = ["hotstreak", "firstflame", "firstflame", "generic-fire"]
- spells_nonchandler = ["ice", "biscuit-maker", "firesale", "springwater", "ice-used-chandblock", "volume", "ice-search-2mana-spell"]
- spells_chandler_expensive = ["ignite", "reflection"]
- hand_skips = ["jaxon", "reflection", "tradeable", "ele-search", "magister", "firesale", "3manadraw2", "firstflame", "hotstreak", "sorc-search", "ignite",
- "2manadraw1"]
- print(f"Deck size: {len(deck_base)}")
- if len(deck_base) != 30:
- sys.exit()
- wonder_counter = 0
- turns_taken = []
- for i in range(0, 50000):
- deck = deck_base.copy()
- random.shuffle(deck)
- hand = list()
- enemy_is_rattable = False # (i%100 >= 95)
- enemy_is_spells = False # (i % 1000 <= 1000*(1-(15/43)))
- enemy_ignores_secrets = False # random.random() <= 15/45
- enemy_is_reno = False # random.random() <= 10/45
- enemy_destroys_secrets = False # enemy_is_reno or random.random() <= 5/45
- if start_hand:
- going_second = len(start_hand) % 4 == 0
- hand.extend(start_hand)
- else:
- going_second = (i % 2 == 1)
- hand.append(deck.pop())
- hand.append(deck.pop())
- hand.append(deck.pop())
- if going_second:
- hand.append(deck.pop())
- # mulligan
- for c in range(0, len(hand)):
- hand_c = hand[c]
- if hand_c in hand_skips or \
- (enemy_is_spells and hand_c == "varden") or (not enemy_is_spells and hand_c == "loatheb") or \
- (hand_c == "ele-search" and "ele" in hand) or (hand_c == "sorc-search" and "sorc" in hand) or \
- (hand_c == "ele" and hand.count("ele") > 1) or (hand_c == "sorc" and hand.count("sorc") > 1) or \
- (hand_c == "ice" and ("ice-search" in hand or "ice-search-2mana" in hand or hand.count("ice") > 1)) or \
- (hand_c == "ice-search" and ("ice-search-2mana" in hand or hand.count("ice-search") > 1)) or \
- (hand_c == "ice-search-2mana" and hand.count("ice-search-2mana") > 1) or \
- (hand_c == "ice-search-2mana-spell" and hand.count("ice-search-2mana-spell") > 1) or \
- (not (enemy_is_rattable or enemy_destroys_secrets) and hand_c == "rat") or \
- (not enemy_is_reno and hand_c == "albatross"):
- hand[c] = deck.pop(0)
- deck.append(hand_c)
- random.shuffle(deck)
- iced_turns = 0
- iceblock_used = 0
- success = False
- sapience = False
- jaxon = False
- volume_used = False
- acolyte_hp = 0
- for turn in range(1, 20):
- mana = turn
- newcard = deck.pop()
- if sapience:
- jaxon_discover = [newcard]
- if "ele" in jaxon_discover and "ele" not in hand:
- newcard = "ele"
- elif "sorc" in jaxon_discover and "sorc" not in hand:
- newcard = "sorc"
- elif "volume" in jaxon_discover and "volume" not in hand:
- newcard = "volume"
- elif iced_turns == 0 and "ice-search-2mana" in jaxon_discover and "ice" in deck and "ice-search" not in hand:
- newcard = "ice-search-2mana"
- elif iced_turns == 0 and "ice-search" in jaxon_discover and "ice" in deck and "ice-search" not in hand:
- newcard = "ice-search"
- elif iced_turns == 0 and "ice-search-2mana-spell" in jaxon_discover and "ice" in deck and "ice-search" not in hand:
- newcard = "ice-search-2mana-spell"
- elif iced_turns == 0 and "ice" in jaxon_discover and "ice-search" not in hand:
- newcard = "ice"
- elif newcard in ["evoc", "hotstreak", "reflection"]:
- newcard = newcard
- else:
- deck.append(newcard)
- newcard = deck.pop(0)
- random.shuffle(deck)
- hand.append(newcard)
- iced = False
- reloop = True
- if jaxon:
- jaxon = False
- if turn <= 3:
- if random.random() < 0.3:
- jaxon = True
- elif turn - iced_turns >= 5:
- jaxon = True
- if not jaxon:
- iced_turns += 0.0625 * random.choice([3,3,3,4])
- if acolyte_hp > 0:
- r = random.random()
- if r <= 0.1 or turn > 5: # doesnt sink damage
- hand.append(deck.pop())
- if acolyte_hp > 3:
- hand.append(deck.pop())
- acolyte_hp -= random.randint(1, 3)
- acolyte_hp -= random.randint(1, 3)
- else:
- hand.append(deck.pop())
- prev_hp = acolyte_hp
- if acolyte_hp > 2:
- acolyte_hp -= random.choice([1, 2, 3, 3, 3, 4])
- if acolyte_hp > 1 or prev_hp > 3:
- hand.append(deck.pop())
- acolyte_hp -= random.choice([1, 1, 2, 2, 2, 3])
- if acolyte_hp > 1:
- hand.append(deck.pop())
- acolyte_hp -= random.choice([1, 2, 2, 3, 3, 1])
- if not enemy_is_spells:
- iced_turns += 0.0625 * (prev_hp - acolyte_hp)
- if acolyte_hp < 0:
- acolyte_hp = 0
- while reloop:
- # print(f"{turn} - {mana} -- {hand}")
- reloop = False
- # check for victory
- if "ele" in hand and "sorc" in hand:
- temp_mana = mana + hand.count("biscuit") * 2 + min(hand.count("evoc") * 2, 5) + hand.count("reflection-discounted")
- temp_mana -= 2 # nerf
- temp_mana += hand.count("shivering-played")
- if going_second:
- temp_mana += 1
- if temp_mana >= 7:
- temp_mana += hand.count("biscuit-maker") * 1
- if (temp_mana >= 11 and hand.count("sorc") == 2) or \
- (temp_mana >= 8 and "hotstreak" in hand and "reflection" in hand) or \
- (temp_mana >= 10 and "reflection" in hand) or \
- (temp_mana >= 10 and "sorc_copy" in hand):
- fire_in_hand_count = sum([hand.count(x) for x in spells_chandler])
- fire_in_hand_count += sum([hand.count(x) for x in spells_chandler_expensive])
- fire_in_hand_count -= sum([deck.count(x) for x in spells_nonchandler])
- if (temp_mana <= 9 and "hotstreak" not in hand) or (temp_mana <= 11):
- fire_in_hand_count -= 1 # reflection too expensive
- if fire_in_hand_count >= 1:
- success = True
- break
- if temp_mana >= 8:
- # try with/find hotstreak
- fire_in_hand_count = sum([hand.count(x) for x in spells_chandler])
- fire_in_hand_count -= sum([deck.count(x) for x in spells_chandler_expensive])
- fire_in_hand_count -= sum([deck.count(x) for x in spells_nonchandler])
- fire_in_hand_count += hand.count("hotstreak") # yes this works
- if temp_mana >= 9: # ignite is playable
- fire_in_hand_count += 1
- if temp_mana >= 11: # ignite and reflection is playable too
- fire_in_hand_count += 1
- if fire_in_hand_count >= 1:
- success = True
- break
- # auto-draw cards
- if "wonder-card" in hand:
- hand.remove("wonder-card")
- hand.append(deck.pop())
- wonder_counter += 1
- reloop = True
- if True:
- if "rommath" in hand and mana >= 9:
- if "ETC" in hand:
- iced_turns += 1
- success = True
- break
- mana -= 6
- hand.append("ice")
- reloop = True
- if not (iceblock_used and enemy_ignores_secrets) and not iced and "ice" in hand and mana >= 3:
- hand.remove("ice")
- mana -= 3
- iced = True
- iceblock_used += 1
- if not enemy_ignores_secrets:
- iced_turns += 1
- reloop = True
- if (iceblock_used == 0 or ("firstflame" in hand and turn >= 4)) and "ice-search-2mana" in hand and mana >= 2 and "ice" in deck:
- hand.remove("ice-search-2mana")
- num_tradeables = hand.count("tradeable") + 1
- if num_tradeables > mana - 2+1:
- num_tradeables = mana-2+1
- if deck.count("ice") > 1 or random.random() > num_tradeables/len(deck):
- deck.remove("ice")
- hand.append("ice")
- iceblock_used -= 1
- mana += 1
- else:
- mana -= 2
- if turn <= 2 and not enemy_is_spells:
- iced_turns += 0.125
- random.shuffle(deck)
- reloop = True
- continue
- elif (iceblock_used == 0 or ("firstflame" in hand and turn >= 4)) and "ice-search-2mana-spell" in hand and mana >= 2 and "ice" in deck:
- hand.remove("ice-search-2mana-spell")
- deck.remove("ice")
- hand.append("ice")
- mana += 1
- random.shuffle(deck)
- reloop = True
- continue
- elif (iceblock_used == 0 or turn >= 4) and not (iceblock_used and enemy_ignores_secrets) and not iced and "ice-search" in hand and mana >= 3 and "ice" in deck:
- hand.remove("ice-search")
- deck.remove("ice")
- if iceblock_used:
- deck.append("ice-used")
- hand.append("ice")
- iceblock_used -= 1
- random.shuffle(deck)
- reloop = True
- continue
- if not iced and "ice-discount" in hand and mana >= 2 and "ice" in hand:
- hand.remove("ice-discount")
- mana += 1
- reloop = True
- continue
- if enemy_destroys_secrets and "rat" in hand:
- enemy_destroys_secrets = random.random() > 1/5
- hand.remove("rat")
- if enemy_is_reno and "albatross" in hand:
- enemy_is_reno = random.random() > 4/5
- hand.remove("albatross")
- enemy_destroys_secrets = enemy_is_reno and enemy_destroys_secrets
- # search cards
- if "volume" in hand and mana >= 4:
- hand.remove("volume")
- mana -= 4
- volume_used = True
- dupecard = None
- for x in range(3):
- for c in deck:
- if c in spells:
- hand.append(c)
- deck.remove(c)
- if c == "evoc":
- dupecard = "evoc"
- if c == "ice" and not dupecard:
- dupecard = "ice"
- break
- if dupecard:
- hand.append(dupecard)
- if "shivering" in hand and mana >= 1 and (turn <= 2):
- hand.remove("shivering")
- hand.append("shivering-played")
- mana -= 1
- if turn <= 2 and not enemy_is_spells:
- iced_turns += 0.25
- if turn == 1 and not enemy_is_spells:
- iced_turns += 0.25
- if enemy_is_rattable and "rat" in hand and mana >= 2:
- success = True
- break
- if "magister" in hand and iced_turns >= 0.5 and (mana >= 7 or ("biscuit" in hand and mana >= 5)):
- hand.remove("magister")
- mana -= 4
- if "biscuit" in hand:
- mana += 2
- elif "biscuit-maker" in hand:
- hand.remove("biscuit-maker")
- hand.append("biscuit")
- hand.append("generic-fire")
- hand.append("ice")
- if volume_used:
- hand.append("volume")
- mana += 4
- reloop = True
- continue
- if "magister" in hand and iced_turns >= 0.5 and (mana >= 7 or ("biscuit" in hand and mana >= 5)):
- hand.remove("sivara")
- mana -= 4
- hand.append("ice")
- reloop = True
- continue
- if (not enemy_is_spells) and "varden" in hand and mana >= 4:
- hand.remove("varden")
- mana -= 4
- iced_turns += 1
- if (not enemy_is_spells) and "firesale" in hand and mana >= 4:
- hand.remove("firesale")
- mana -= 4
- success = True
- break
- if enemy_is_spells and "loatheb" in hand and mana >= 5:
- hand.remove("loatheb")
- mana -= 5
- if random.random() > 0.2:
- iced_turns += 1
- if "springwater" in hand and mana >= 5:
- hand.remove("springwater")
- mana -= 4
- newcard = deck.pop()
- hand.append(newcard)
- if newcard in spells:
- mana += 2
- newcard = deck.pop()
- hand.append(newcard)
- if newcard in spells:
- mana += 2
- random.shuffle(deck)
- reloop = True
- if "ele-search" in hand and mana >= 4 and "ele" not in hand:
- hand.remove("ele-search")
- mana -= 4
- deck.remove("ele")
- hand.append("ele")
- random.shuffle(deck)
- if "sorc-search" in hand and mana >= 4 and "sorc" not in hand:
- hand.remove("sorc-search")
- mana -= 4
- deck.remove("sorc")
- hand.append("sorc")
- random.shuffle(deck)
- if "2manadraw1" in hand and mana >= 2:
- hand.remove("2manadraw1")
- mana -= 2
- hand.append(deck.pop())
- random.shuffle(deck)
- reloop = True
- if "3manadraw2" in hand and mana >= 3:
- hand.remove("3manadraw2")
- mana -= 3
- hand.append(deck.pop())
- hand.append(deck.pop())
- random.shuffle(deck)
- if "acolyte" in hand and mana >= 3:
- hand.remove("acolyte")
- mana -= 3
- acolyte_hp += 3
- random.shuffle(deck)
- if "spicebaker" in hand and mana >= 4:
- hand.remove("spicebaker")
- mana -= 4
- iced_turns += 0.5
- random.shuffle(deck)
- if "6manadraw6" in hand and mana >= 6:
- hand.remove("6manadraw6")
- mana -= 6
- hand.append(deck.pop())
- hand.append(deck.pop())
- hand.append(deck.pop())
- hand.append(deck.pop())
- hand.append(deck.pop())
- hand.append(deck.pop())
- random.shuffle(deck)
- if "3manaspellsearch" in hand and mana >= 3:
- hand.remove("3manaspellsearch")
- mana -= 3
- newcard = deck.pop(0)
- tries = 0
- while newcard not in spells:
- tries += 1
- deck.append(newcard)
- if tries > 80:
- break
- newcard = deck.pop(0)
- hand.append(newcard)
- random.shuffle(deck)
- if newcard == "ice":
- iced_turns += 0.5
- reloop = True
- if "2manaspellsearch" in hand and mana >= 2:
- hand.remove("2manaspellsearch")
- mana -= 2
- newcard = deck.pop(0)
- tries = 0
- while newcard not in spells:
- tries += 1
- deck.append(newcard)
- if tries > 80:
- break
- newcard = deck.pop(0)
- if newcard in spells:
- hand.append(newcard)
- random.shuffle(deck)
- reloop = True
- if "4manaspellsearch" in hand and mana >= 4:
- hand.remove("4manaspellsearch")
- mana -= 4
- newcard = deck.pop(0)
- tries = 0
- while newcard not in spells:
- tries += 1
- deck.append(newcard)
- if tries > 50:
- break
- newcard = deck.pop(0)
- if newcard in spells:
- hand.append(newcard)
- random.shuffle(deck)
- if "3manadraw2" in hand and mana >= 3:
- hand.remove("3manadraw2")
- mana -= 3
- newcard = deck.pop(0)
- hand.append(newcard)
- random.shuffle(deck)
- reloop = True
- if "sapience" in hand and mana >= 1:
- hand.remove("sapience")
- mana -= 1
- sapience = True
- if "biscuit-maker" in hand and mana >= 2:
- hand.remove("biscuit-maker")
- mana -= 2
- hand.append("biscuit")
- if "wonder-deck" in hand and mana >= 5:
- hand.remove("wonder-deck")
- mana -= 5
- deck.append("wonder-card")
- deck.append("wonder-card")
- deck.append("wonder-card")
- deck.append("wonder-card")
- deck.append("wonder-card")
- random.shuffle(deck)
- if "jaxon" in hand and mana >= 3 and hand.count("tradeable") >= 1:
- hand.remove("jaxon")
- mana -= 2
- jaxon = True
- if "tradeable" in hand and mana > 0:
- hand.remove("tradeable")
- mana -= 1
- if jaxon:
- jaxon_discover = [deck[0], deck[1], deck[2]]
- if "ele" in jaxon_discover and "ele" not in hand:
- newcard = "ele"
- elif "sorc" in jaxon_discover and "sorc" not in hand:
- newcard = "sorc"
- elif "ice-search" in jaxon_discover and "ice" in deck and "ice-search" not in hand:
- newcard = "ice-search"
- elif "ice" in jaxon_discover and "ice-search" not in hand:
- newcard = "ice"
- elif "evoc" in jaxon_discover:
- newcard = "evoc"
- elif "tradeable" in jaxon_discover and mana >= 1:
- newcard = "tradeable"
- else:
- newcard = jaxon_discover[0]
- deck.remove(newcard)
- else:
- newcard = deck.pop(0)
- hand.append(newcard)
- deck.append("tradeable")
- random.shuffle(deck)
- reloop = True
- if "firesale" in hand and mana > 0:
- hand.remove("firesale")
- mana -= 1
- newcard = deck.pop(0)
- hand.append(newcard)
- deck.append("firesale")
- random.shuffle(deck)
- reloop = True
- if reloop is False:
- if acolyte_hp > 0 and mana >= 2:
- acolyte_hp -= 1
- hand.append(deck.pop())
- if "shivering" in hand and mana >= 1 and ("reflection" in hand or "ignite" in hand):
- hand.remove("shivering")
- if "reflection" in hand:
- hand.append("reflection-discount")
- elif "ice" in hand:
- hand.append("ice-discount")
- elif "ignite" in hand:
- hand.remove("ignite")
- hand.append("generic-fire")
- mana -= 1
- if turn <= 2 and not enemy_is_spells:
- iced_turns += 0.25
- if turn == 1 and not enemy_is_spells:
- iced_turns += 0.25
- if hand.count("ele") > 1 and mana >= 5:
- hand.remove("ele")
- mana -= 5
- if turn <= 6:
- iced_turns += 0.3125
- reloop = True
- if "sorc-search" in hand and mana >= 4 and "sorc" not in deck:
- hand.remove("sorc-search")
- mana -= 4
- deck.remove("tradeable")
- hand.append("tradeable")
- random.shuffle(deck)
- reloop = True
- if "ele-search" in hand and mana >= 4 and "ele" in deck:
- # second search
- hand.remove("ele-search")
- mana -= 4
- deck.remove("ele")
- hand.append("ele")
- random.shuffle(deck)
- reloop = True
- if iceblock_used > 0 and "rewind" in hand and mana >= 2:
- hand.remove("rewind")
- mana -= 2
- hand.append("ice")
- reloop = True
- if success:
- if enemy_destroys_secrets:
- iced_turns = 0
- turns_taken.append(turn - iced_turns)
- break
- win_by_5 = 0
- for t in turns_taken:
- if t <= 5:
- win_by_5 += 1
- print("Chance to win if survived to turn 5: ", win_by_5 / len(turns_taken), " - Average turns: ", sum(turns_taken) / len(turns_taken))
Advertisement
Add Comment
Please, Sign In to add comment