Advertisement
Guest User

Python 3 script for figuring out the best Ignite Mage deck. By Lt.Labcoat

a guest
Nov 19th, 2021
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.77 KB | None | 0 0
  1. # Python 3 script for figuring out the best Ignite Mage deck
  2. # by Lt.Labcoat
  3.  
  4.  
  5. import random
  6.  
  7. start_hand = []
  8.  
  9. # unused card names:
  10. # biscuit-maker  2manadraw1 3manadraw2  heropower 3manaspellsearch arugal 2manaspellsearch
  11. # ice-search-2mana firesale sapience wonder-deck spicebaker
  12.  
  13.  
  14. # win at adjusted turn: 5.61
  15. deck_base_online = ["ice-search", "evoc",
  16.         "tradeable", "tradeable",
  17.         "sorc", "ele", "tradeable", "tradeable",
  18.         "ice", "3manaspellsearch",
  19.         ]*2
  20.  
  21. deck_base_online += ["sorc-search", "firstflame", "firstflame"]
  22. deck_base_online += ["hotstreak", "sorc-search", "ele-search"]
  23. deck_base_online += ["ele-search", "ignite", "reflection", "hotstreak"]
  24.  
  25.  
  26. # win at adjusted turn: 5.356
  27. deck_base = ["ice-search", "evoc",
  28.         "tradeable", "tradeable",
  29.         "sorc", "ele", "tradeable", "tradeable",
  30.         "ice", "tradeable",
  31.         ]*2
  32.  
  33. deck_base += ["varden", "firstflame", "firstflame"]
  34. deck_base += ["acolyte", "sorc-search", "ele-search"]
  35. deck_base += ["loatheb", "ignite", "reflection", "hotstreak"]
  36.  
  37. #deck_base = deck_base_online
  38.  
  39. if deck_base.count("tradeable") < 10:
  40.     print(f'Tradeables: {deck_base.count("tradeable")}')
  41.  
  42. spells = ["hotstreak", "evoc", "biscuit-maker", "firstflame", "ignite", "ice", "reflection", "heropower", "firesale", "springwater"]
  43. spells_chandler = ["hotstreak", "firstflame", "firstflame", "heropower"]
  44. spells_nonchandler = ["ice", "biscuit-maker", "firesale", "springwater"]
  45. spells_chandler_expensive = ["ignite", "reflection"]
  46.  
  47. hand_skips = ["tradeable", "firesale", "3manadraw2", "firstflame", "hotstreak", "ele-search", "sorc-search", "ignite", "reflection", "2manadraw1"]
  48.  
  49. print(f"Deck size: {len(deck_base)}")
  50.  
  51.  
  52. wonder_counter = 0
  53. turns_taken = []
  54.  
  55. for i in range(0, 50000):
  56.     deck = deck_base.copy()
  57.     random.shuffle(deck)
  58.     hand = list()
  59.     enemy_is_spells = (i%100>=50)
  60.    
  61.     if start_hand:
  62.         going_second = len(start_hand) % 4 == 0
  63.         hand.extend(start_hand)
  64.     else:
  65.         going_second = (i%2==1)
  66.         hand.append(deck.pop())
  67.         hand.append(deck.pop())
  68.         hand.append(deck.pop())
  69.         if going_second:
  70.             hand.append(deck.pop())
  71.        
  72.     # mulligan
  73.     for c in range(0, len(hand)):
  74.         hand_c = hand[c]
  75.         if hand_c in hand_skips or (enemy_is_spells and hand_c == "varden") or (not enemy_is_spells and hand_c == "loatheb"):
  76.             hand[c] = deck.pop(0)
  77.             deck.append(hand_c)
  78.     random.shuffle(deck)
  79.    
  80.     iced_turns = 0
  81.     success = False
  82.     sapience = False
  83.    
  84.     for turn in range(1, 20):
  85.         if success:
  86.             break
  87.            
  88.         mana = turn
  89.         newcard = deck.pop()
  90.         if sapience and (newcard in hand_skips or
  91.                          (newcard == "sorc" and "sorc" in hand) or (newcard == "ele" and "ele" in hand)):
  92.             deck.append(newcard)
  93.             newcard = deck.pop(0)
  94.             random.shuffle(deck)
  95.         hand.append(newcard)
  96.         iced = False
  97.         reloop = True
  98.         arugal = False
  99.        
  100.         while reloop:
  101.             #print(f"{turn} - {mana} -- {hand}")
  102.             reloop = False
  103.            
  104.             # check for victory
  105.             if "ele" in hand and "sorc" in hand:
  106.                 temp_mana = mana + hand.count("biscuit")*2 + hand.count("evoc")*2
  107.                 if going_second:
  108.                     temp_mana += 1
  109.                 if temp_mana >= 7:
  110.                     temp_mana += hand.count("biscuit-maker")*1
  111.                    
  112.                     if (temp_mana >= 9 and hand.count("sorc") == 2) or \
  113.                             (temp_mana >= 8 and "hotstreak" in hand and "reflection" in hand) or \
  114.                             (temp_mana >= 10 and "reflection" in hand):
  115.                         fire_in_hand_count = sum([hand.count(x) for x in spells_chandler])
  116.                         fire_in_hand_count += sum([hand.count(x) for x in spells_chandler_expensive])
  117.                         fire_in_hand_count -= sum([deck.count(x) for x in spells_nonchandler])
  118.                         if (temp_mana <= 9 and "hotstreak" not in hand) or (temp_mana <= 11):
  119.                             fire_in_hand_count -= 1  # reflection too expensive
  120.                         if fire_in_hand_count >= 1:
  121.                             turns_taken.append(turn - iced_turns)
  122.                             success = True
  123.                             break
  124.  
  125.                     if temp_mana >= 8:
  126.                         # try with/find hotstreak
  127.                         fire_in_hand_count = sum([hand.count(x) for x in spells_chandler])
  128.                         fire_in_hand_count -= sum([deck.count(x) for x in spells_chandler_expensive])
  129.                         fire_in_hand_count -= sum([deck.count(x) for x in spells_nonchandler])
  130.                         fire_in_hand_count += hand.count("hotstreak")  # yes this works
  131.                         if temp_mana >= 9:  # ignite is playable
  132.                             fire_in_hand_count += 1
  133.                         if temp_mana >= 11:  # ignite and reflection is playable too
  134.                             fire_in_hand_count += 1
  135.                         if fire_in_hand_count >= 1:
  136.                             turns_taken.append(turn - iced_turns)
  137.                             success = True
  138.                             break
  139.                            
  140.  
  141.             # auto-draw cards
  142.             if "wonder-card" in hand:
  143.                 hand.remove("wonder-card")
  144.                 hand.append(deck.pop())
  145.                 wonder_counter += 1
  146.                 reloop = True
  147.  
  148.             # search cards
  149.             if not iced and "ice-search" in hand and mana >= 3 and "ice" in deck:
  150.                 hand.remove("ice-search")
  151.                 deck.remove("ice")
  152.                 hand.append("ice")
  153.                 random.shuffle(deck)
  154.             if not iced and "ice-search-2mana" in hand and mana >= 2 and "ice" in deck:
  155.                 hand.remove("ice-search-2mana")
  156.                 mana += 1
  157.                 deck.remove("ice")
  158.                 hand.append("ice")
  159.                 random.shuffle(deck)
  160.             if not iced and "ice" in hand and mana >= 3:
  161.                 hand.remove("ice")
  162.                 mana -= 3
  163.                 iced = True
  164.                 iced_turns += 0.75
  165.             if (not enemy_is_spells) and "varden" in hand and mana >= 4:
  166.                 hand.remove("varden")
  167.                 mana -= 4
  168.                 iced_turns += 1
  169.             if (not enemy_is_spells) and "firesale" in hand and mana >= 4:
  170.                 hand.remove("firesale")
  171.                 mana -= 4
  172.                 turns_taken.append(turn - iced_turns)
  173.                 success = True
  174.                 break
  175.             if enemy_is_spells and "loatheb" in hand and mana >= 5:
  176.                 hand.remove("loatheb")
  177.                 mana -= 5
  178.                 iced_turns += 1
  179.             if "springwater" in hand and mana >= 5:
  180.                 hand.remove("springwater")
  181.                 mana -= 4
  182.                 newcard = deck.pop()
  183.                 hand.append(newcard)
  184.                 if newcard in spells:
  185.                     mana += 2
  186.                 newcard = deck.pop()
  187.                 hand.append(newcard)
  188.                 if newcard in spells:
  189.                     mana += 2
  190.                 random.shuffle(deck)
  191.                 reloop = True
  192.             if "ele-search" in hand and mana >= 4 and "ele" not in hand:
  193.                 hand.remove("ele-search")
  194.                 mana -= 4
  195.                 deck.remove("ele")
  196.                 hand.append("ele")
  197.                 random.shuffle(deck)
  198.             if "sorc-search" in hand and mana >= 4 and "sorc" in deck:
  199.                 hand.remove("sorc-search")
  200.                 mana -= 4
  201.                 deck.remove("sorc")
  202.                 hand.append("sorc")
  203.                 random.shuffle(deck)
  204.             if "biscuit-maker" in hand and mana >= 2:
  205.                 hand.remove("biscuit-maker")
  206.                 mana -= 2
  207.                 hand.append("biscuit")
  208.             if "2manadraw1" in hand and mana >= 2:
  209.                 hand.remove("2manadraw1")
  210.                 mana -= 2
  211.                 hand.append(deck.pop())
  212.                 random.shuffle(deck)
  213.                 reloop = True
  214.             if "3manadraw2" in hand and mana >= 3:
  215.                 hand.remove("3manadraw2")
  216.                 mana -= 3
  217.                 hand.append(deck.pop())
  218.                 hand.append(deck.pop())
  219.                 random.shuffle(deck)
  220.                 iced_turns -= 0.25
  221.             if "acolyte" in hand and mana >= 3:
  222.                 hand.remove("acolyte")
  223.                 mana -= 3
  224.                 hand.append(deck.pop())
  225.                 if random.random() > 0.8:
  226.                     hand.append(deck.pop())
  227.                 else:
  228.                     iced_turns += 0.125
  229.                 random.shuffle(deck)
  230.             if "spicebaker" in hand and mana >= 4:
  231.                 hand.remove("spicebaker")
  232.                 mana -= 4
  233.                 iced_turns += 0.5
  234.                 random.shuffle(deck)
  235.             if "6manadraw6" in hand and mana >= 6:
  236.                 hand.remove("6manadraw6")
  237.                 mana -= 6
  238.                 hand.append(deck.pop())
  239.                 hand.append(deck.pop())
  240.                 hand.append(deck.pop())
  241.                 hand.append(deck.pop())
  242.                 hand.append(deck.pop())
  243.                 hand.append(deck.pop())
  244.                 random.shuffle(deck)
  245.             if "3manaspellsearch" in hand and mana >= 3:
  246.                 hand.remove("3manaspellsearch")
  247.                 mana -= 3
  248.                 newcard = deck.pop(0)
  249.                 tries = 0
  250.                 while newcard not in spells:
  251.                     tries += 1
  252.                     deck.append(newcard)
  253.                     if tries > 80:
  254.                         break
  255.                     newcard = deck.pop(0)
  256.                 hand.append(newcard)
  257.                 random.shuffle(deck)
  258.                 if newcard == "ice":
  259.                     iced_turns += 0.5
  260.                 reloop = True
  261.             if "2manaspellsearch" in hand and mana >= 2:
  262.                 hand.remove("2manaspellsearch")
  263.                 mana -= 2
  264.                 newcard = deck.pop(0)
  265.                 tries = 0
  266.                 while newcard not in spells:
  267.                     tries += 1
  268.                     deck.append(newcard)
  269.                     if tries > 80:
  270.                         break
  271.                     newcard = deck.pop(0)
  272.                 if newcard in spells:
  273.                     hand.append(newcard)
  274.                 random.shuffle(deck)
  275.                 reloop = True
  276.             if "4manaspellsearch" in hand and mana >= 4:
  277.                 hand.remove("4manaspellsearch")
  278.                 mana -= 4
  279.                 newcard = deck.pop(0)
  280.                 tries = 0
  281.                 while newcard not in spells:
  282.                     tries += 1
  283.                     deck.append(newcard)
  284.                     if tries > 50:
  285.                         break
  286.                     newcard = deck.pop(0)
  287.                 if newcard in spells:
  288.                     hand.append(newcard)
  289.                 random.shuffle(deck)
  290.             if "3manadraw2" in hand and mana >= 3:
  291.                 hand.remove("3manadraw2")
  292.                 mana -= 3
  293.                 newcard = deck.pop(0)
  294.                 hand.append(newcard)
  295.                 random.shuffle(deck)
  296.                 reloop = True
  297.             if "sapience" in hand and mana >= 1:
  298.                 hand.remove("sapience")
  299.                 mana -= 1
  300.                 sapience = True
  301.             if "wonder-deck" in hand and mana >= 5:
  302.                 hand.remove("wonder-deck")
  303.                 mana -= 5
  304.                 deck.append("wonder-card")
  305.                 deck.append("wonder-card")
  306.                 deck.append("wonder-card")
  307.                 deck.append("wonder-card")
  308.                 deck.append("wonder-card")
  309.                 random.shuffle(deck)
  310.             if "sorc-search" in hand and mana >= 4 and "sorc" not in deck:
  311.                 hand.remove("sorc-search")
  312.                 mana -= 4
  313.                 deck.remove("tradeable")
  314.                 hand.append("tradeable")
  315.                 random.shuffle(deck)
  316.             if "ele-search" in hand and mana >= 4 and "ele" in deck:
  317.                 # second search
  318.                 hand.remove("ele-search")
  319.                 mana -= 4
  320.                 deck.remove("ele")
  321.                 hand.append("ele")
  322.                 random.shuffle(deck)
  323.  
  324.             if "arugal" in hand and mana >= 4:
  325.                 hand.remove("arugal")
  326.                 mana -= 2
  327.                 arugal = True
  328.  
  329.  
  330.             if "tradeable" in hand and mana > 0:
  331.                 hand.remove("tradeable")
  332.                 mana -= 1
  333.                 newcard = deck.pop(0)
  334.                 if arugal:
  335.                     if newcard not in spells:
  336.                         hand.append(newcard)
  337.                     #while newcard == "tradeable":
  338.                     #    deck.append("tradeable")
  339.                     #    newcard = deck.pop(0)
  340.                 hand.append(newcard)
  341.                 deck.append("tradeable")
  342.                 random.shuffle(deck)
  343.                 reloop = True
  344.  
  345.             if "firesale" in hand and mana > 0:
  346.                 hand.remove("firesale")
  347.                 mana -= 1
  348.                 newcard = deck.pop(0)
  349.                 if arugal:
  350.                     if newcard not in spells:
  351.                         hand.append(newcard)
  352.                     #while newcard == "tradeable":
  353.                     #    deck.append("tradeable")
  354.                     #    newcard = deck.pop(0)
  355.                 hand.append(newcard)
  356.                 deck.append("firesale")
  357.                 random.shuffle(deck)
  358.                 reloop = True
  359.                
  360. print(sum(turns_taken) / len(turns_taken))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement