Advertisement
Guest User

Timelord/Trains probability script

a guest
Nov 27th, 2018
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 15.02 KB | None | 0 0
  1. import random
  2.  
  3.  
  4. def mainmethod(deckname, default_hand_size, michions_in_deck, sandaions_in_deck, maids_in_deck, other_timelords_in_deck, cts_in_deck,
  5.                switchyards_in_deck, pegasii_in_deck, bullets_in_deck, cranes_in_deck, railcars_in_deck, boosters_in_deck, other_earth_machines_in_deck, knights_in_deck, schedules_in_deck,
  6.                jizukiru_in_deck, burial_in_deck, reborn_in_deck, pots_desires_in_deck, goblin_in_deck, pinpoints_in_deck,
  7.                added_card=None, removed_card=None, extra_cards_in_deck=0):
  8.  
  9.     trains_in_deck = bullets_in_deck + cranes_in_deck
  10.     pots_indulgences_in_deck = 0
  11.  
  12.     print("-----Deck: " + deckname)
  13.     if added_card:
  14.         print("-----Added Card: %s" % added_card)
  15.     if removed_card:
  16.         print("-----Removed Card: %s" % removed_card)
  17.  
  18.     deck = []
  19.     if extra_cards_in_deck:
  20.         for i in range(0, extra_cards_in_deck):
  21.             deck.append('ExtraCard')
  22.  
  23.     for i in range(0, michions_in_deck):
  24.         deck.append('TimelordMich')
  25.     for i in range(0, maids_in_deck):
  26.         deck.append('TimelordMaid')
  27.     for i in range(0, sandaions_in_deck):
  28.         deck.append('TimelordSand')
  29.     for i in range(0, other_timelords_in_deck):
  30.         deck.append('TimelordGeneric')
  31.     for i in range(0, cts_in_deck):
  32.         deck.append('CT')
  33.  
  34.     for i in range(0, schedules_in_deck):
  35.         deck.append('Schedule')
  36.     for i in range(0, pegasii_in_deck):
  37.         deck.append('Pegasus')
  38.     for i in range(0, railcars_in_deck):
  39.         deck.append('Railcar')
  40.     for i in range(0, boosters_in_deck):
  41.         deck.append('Booster')
  42.     for i in range(0, other_earth_machines_in_deck):
  43.         deck.append('OtherEarthMachine')
  44.     if bullets_in_deck:
  45.         for i in range(0, cranes_in_deck):
  46.             deck.append('Lv10Crane')
  47.         for i in range(0, bullets_in_deck):
  48.             deck.append('Lv10Train')
  49.     for i in range(0, knights_in_deck):
  50.         deck.append('KnightTrain')
  51.     for i in range(0, switchyards_in_deck):
  52.         deck.append('Switchyard')
  53.  
  54.     for i in range(0, pinpoints_in_deck):
  55.         deck.append('Pinpoint')
  56.  
  57.     if jizukiru_in_deck:
  58.         deck.append('Slumber')
  59.         deck.append('Kaiju1')
  60.         deck.append('Kaiju2')
  61.         for i in range(jizukiru_in_deck):
  62.             deck.append('KaijuJizukiru')
  63.  
  64.     for i in range(0, pots_indulgences_in_deck):
  65.         deck.append('PotOfIndulgence')
  66.     for i in range(0, pots_desires_in_deck):
  67.         deck.append('PotOfDesires')
  68.  
  69.     if burial_in_deck:
  70.         deck.append('FoolishBurial')
  71.     if reborn_in_deck:
  72.         deck.append('MonsterReborn')
  73.  
  74.     if added_card:
  75.         deck.append(added_card)
  76.     if removed_card:
  77.         deck.remove(removed_card)
  78.  
  79.     print("Misc cards in deck: %s" % (40 - len(deck) - goblin_in_deck))
  80.     if len(deck) < 40:
  81.         for i in range(0, 40 - len(deck)):
  82.             deck.append('MiscCard')
  83.     for i in range(goblin_in_deck):
  84.         deck.remove('MiscCard')
  85.  
  86.     wincount = 0
  87.     bls_win_count = 0
  88.     totalcount = 1000000
  89.     timelord_otk_count = 0
  90.     bonus_cards_count = 0
  91.  
  92.     for iteration in range(0, totalcount):
  93.         if default_hand_size:
  94.             hand_size = default_hand_size
  95.         else:
  96.             hand_size = 5 + iteration % 2
  97.         turn_one = hand_size == 5
  98.         extra_deck_broke = False
  99.         hand = random.sample(deck, hand_size)
  100.         if "Pinpoint" in hand or "PotOfDesires" in hand:
  101.             special_deck = deck.copy()
  102.             goblin_drawn = False
  103.             if "Pinpoint" in hand:
  104.                 special_deck.remove("Pinpoint")
  105.                 hand = random.sample(special_deck, hand_size)
  106.                 goblin_drawn = True
  107.             if "PotOfDesires" in hand:
  108.                 special_deck.remove("PotOfDesires")
  109.                 removed_cards = random.sample(special_deck, hand_size + 11)
  110.                 hand = removed_cards[10:]
  111.                 if "Schedule" in hand[-2:]:
  112.                     if removed_cards.count("Pegasus") == pegasii_in_deck or\
  113.                             removed_cards.count("Lv10Train") + removed_cards.count("Lv10Crane") == bullets_in_deck + cranes_in_deck:
  114.                         hand.remove("Schedule")
  115.                 if "Switchyard" in hand[-2:]:
  116.                     if removed_cards.count("Lv10Train") + removed_cards.count("Lv10Crane") == bullets_in_deck + cranes_in_deck:
  117.                         hand.remove("Switchyard")   # Not fully accurate, missing knight trains
  118.  
  119.                 if "Pinpoint" in hand[-2:] and not goblin_drawn:
  120.                     special_deck.remove("Pinpoint")
  121.                     hand = random.sample(removed_cards, hand_size + 1)
  122.         elif "PotOfIndulgence" in hand:  # simulate using a pot
  123.             special_deck = deck.copy()
  124.             special_deck.remove("PotOfIndulgence")
  125.             hand = random.sample(special_deck, hand_size + 1)
  126.             if random.random() < 0.0442:
  127.                 # extra deck broke
  128.                 extra_deck_broke = True
  129.         timelords = 0
  130.         cts = 0
  131.         schedules = 0
  132.         pegasii = 0
  133.         lv10_trains = 0
  134.         bullets = 0
  135.         cranes = 0
  136.         railcars = 0
  137.         boosters = 0
  138.         lv4s = 0
  139.         knight_trains = 0
  140.         winner = False
  141.         bls_winner = False
  142.  
  143.         jizukirus = 0
  144.         kaijus = 0
  145.         kaiju1 = False
  146.         kaiju2 = False
  147.         slumber = False
  148.         misc_cards = 0
  149.         pot_indulgences = 0
  150.         pot_desires = 0
  151.         switchyards = 0
  152.         burials = 0
  153.         reborns = 0
  154.         extra_cards = 0
  155.         timelord_sand_count = 0
  156.         timelord_mich_maid_count = 0
  157.         timelord_maid_count = 0
  158.         timelord_winner = False
  159.  
  160.         for h in hand:
  161.             if h.startswith("Time"):
  162.                 timelords += 1
  163.                 if h == "TimelordMich":
  164.                     timelord_mich_maid_count += 1
  165.                 if h == "TimelordMaid":
  166.                     timelord_mich_maid_count += 1
  167.                     timelord_maid_count += 1
  168.                 elif h == "TimelordSand":
  169.                     timelord_sand_count += 1
  170.             elif h == "CT":
  171.                 cts += 1
  172.             elif h == "Schedule":
  173.                 schedules += 1
  174.             elif h == "Pegasus":
  175.                 pegasii += 1
  176.             elif h == "Lv10Train":
  177.                 lv10_trains += 1
  178.                 bullets += 1
  179.             elif h == "Lv10Crane":
  180.                 lv10_trains += 1
  181.                 cranes += 1
  182.             elif h == "Railcar":
  183.                 railcars += 1
  184.                 lv4s += 1
  185.             elif h == "Booster":
  186.                 boosters += 1
  187.                 lv4s += 1
  188.             elif h == "OtherEarthMachine":
  189.                 railcars += 1
  190.                 lv4s += 1
  191.             elif h == "KnightTrain":
  192.                 knight_trains += 1
  193.             elif h.startswith("Slumber"):
  194.                 slumber = True
  195.             elif h.startswith("Kaiju"):
  196.                 kaijus += 1
  197.                 if h == "KaijuJizukiru":
  198.                     jizukirus += 1
  199.                 elif h == "Kaiju1":
  200.                     kaiju1 = True
  201.                 elif h == "Kaiju2":
  202.                     kaiju2 = True
  203.             elif h == "MiscCard":
  204.                 misc_cards += 1
  205.             elif h == "PotOfIndulgence":
  206.                 pot_indulgences += 1
  207.             elif h == "PotOfDesires":
  208.                 pot_desires += 1
  209.             elif h == "Switchyard":
  210.                 switchyards += 1
  211.             elif h == 'FoolishBurial':
  212.                 burials += 1
  213.             elif h == 'MonsterReborn':
  214.                 reborns += 1
  215.             elif h == "ExtraCard":
  216.                 extra_cards += 1
  217.  
  218.         if extra_cards_in_deck and extra_cards == 0:
  219.             totalcount -= 1
  220.             continue
  221.  
  222.         # Common combos
  223.         burial_reborn_combo = burials and reborns
  224.         switchyard_reborn_combo = switchyards and reborns
  225.         jizukiru_summoned = False
  226.         slumber_played = False
  227.         schedule_played = False
  228.  
  229.         # Remove T1 options
  230.         if turn_one:
  231.             jizukirus = 0
  232.             kaijus = 0
  233.             slumber = 0
  234.             schedules = 0
  235.  
  236.         if jizukirus >= 1 and kaijus >= 2:
  237.             jizukiru_summoned = True
  238.         elif slumber and not (kaiju1 and kaiju2):
  239.             jizukiru_summoned = True
  240.             slumber_played = True
  241.  
  242.         if schedules and (lv10_trains < trains_in_deck):
  243.             schedule_played = True
  244.  
  245.         # Normal Summon Timelord
  246.         if timelords:
  247.             if timelord_mich_maid_count >= 2 or (timelord_mich_maid_count and timelord_sand_count):
  248.                 if cts or switchyard_reborn_combo:
  249.                     timelord_winner = True
  250.             if (timelord_mich_maid_count or timelord_sand_count) and burial_reborn_combo:
  251.                 timelord_winner = True
  252.  
  253.             # if timelords >= 1:
  254.             if burial_reborn_combo:
  255.                 winner = True
  256.                 if lv10_trains:
  257.                     bls_winner = True
  258.             if jizukiru_summoned:
  259.                 winner = True
  260.             if jizukiru_summoned and burial_reborn_combo:
  261.                 bls_winner = True
  262.             if schedule_played:
  263.                 bls_winner = True
  264.             # ignoring jizukiru_and_schedule_played
  265.  
  266.             if timelords >= 2:
  267.                 if cts:
  268.                     winner = True
  269.                 if switchyard_reborn_combo:
  270.                     winner = True
  271.  
  272.         # Normal Summon Knight/Pegasus
  273.         if knight_trains or pegasii or lv4s or switchyards or burial_reborn_combo:
  274.             if bullets and cranes:
  275.                 bls_winner = True
  276.             if schedule_played:
  277.                 bls_winner = True
  278.             if switchyard_reborn_combo and knight_trains >= 2:  # Remember, Switchyard gets a card
  279.                 bls_winner = True
  280.             if switchyards and (pegasii or burial_reborn_combo) and (knight_trains or lv10_trains):
  281.                 bls_winner = True
  282.  
  283.             if burial_reborn_combo and pegasii:
  284.                 bls_winner = True
  285.  
  286.             extra_summons = 0
  287.             if pegasii and burials and not burial_reborn_combo:
  288.                 extra_summons += 1
  289.             if bullets and not slumber_played:
  290.                 extra_summons += 1
  291.             if cranes:
  292.                 extra_summons += 1
  293.             if switchyards and (knight_trains or pegasii or lv4s or burial_reborn_combo):
  294.                 # Make sure the switchyard wasn't used getting us here
  295.                 extra_summons += 1
  296.             if timelord_maid_count and not slumber_played and not (timelords == 1 and cts):
  297.                 if not lv10_trains:
  298.                     extra_summons += 1
  299.             if timelords and cts:
  300.                 extra_summons += 1
  301.                 if timelords >= 2 and cts >= 2:
  302.                     bls_winner = True
  303.             if jizukiru_summoned:
  304.                 extra_summons += 1
  305.             if burial_reborn_combo and (switchyards or knight_trains):
  306.                 extra_summons += 1
  307.  
  308.             if switchyards and burial_reborn_combo and not (knight_trains or pegasii or lv4s):
  309.                 extra_summons -= 1  # Switchyard and burial_reborn don't make a BLS
  310.             if extra_summons:
  311.                 if knight_trains or pegasii or switchyards or burial_reborn_combo:
  312.                     # Railcars alone can't win
  313.                     winner = True
  314.                     if boosters:
  315.                         bls_winner = True
  316.                 if extra_summons >= 2:
  317.                     bls_winner = True
  318.  
  319.  
  320.         # No Normal Summon
  321.         if schedule_played:
  322.             if jizukiru_summoned and not slumber_played:
  323.                 bls_winner = True
  324.             if lv10_trains:
  325.                 bls_winner = True
  326.  
  327.         # Last chance Kaiju summoning
  328.         if winner and not jizukiru_summoned and kaijus >= 2:
  329.             bls_win_count += 1
  330.  
  331.         #######
  332.         # Set winner tags/count
  333.         if not extra_deck_broke:
  334.             if timelord_winner:
  335.                 timelord_otk_count += 1
  336.                 winner = True
  337.             if bls_winner:
  338.                 bls_win_count += 1
  339.                 winner = True
  340.             if winner:
  341.                 wincount += 1
  342.  
  343.         if winner and lv10_trains:
  344.             bonus_cards_count += 1
  345.         if bls_winner and railcars:
  346.             bonus_cards_count += 1
  347.  
  348.     print("XYZ Summon Chance: %s%%" % (wincount * 100 / totalcount))
  349.     print("Knuckle+XYZ Summon Chance: %s%%" % (bls_win_count * 100 / totalcount))
  350.     if timelord_otk_count:
  351.         print("Timelords OTK Chance: %s%%" % (timelord_otk_count * 100 / totalcount))
  352.     print("Bonus cards: %s%%" % (bonus_cards_count / totalcount))
  353.  
  354. #for card in [None, 'TimelordGeneric', 'TimelordSand', 'Schedule', 'Switchyard', 'PotOfDesires', 'Pegasus', 'Lv10Train', 'KnightTrain', 'KaijuJizukiru', 'Reborn', 'CTS']:
  355.  
  356.  
  357. default_hand_size = 0
  358.  
  359.  
  360. mainmethod("Pure Trains", default_hand_size=default_hand_size, michions_in_deck=0, sandaions_in_deck=0, maids_in_deck=0, other_timelords_in_deck=0, cts_in_deck=0,
  361.            switchyards_in_deck=5, pegasii_in_deck=3, bullets_in_deck=3, cranes_in_deck=3, railcars_in_deck=3, boosters_in_deck=3, other_earth_machines_in_deck=3, knights_in_deck=3, schedules_in_deck=3,
  362.            jizukiru_in_deck=0, burial_in_deck=1, reborn_in_deck=1, pots_desires_in_deck=3, goblin_in_deck=1, pinpoints_in_deck=2,
  363.            added_card=None, removed_card=None)
  364.  
  365. mainmethod("Trainlords", default_hand_size=default_hand_size, michions_in_deck=3, sandaions_in_deck=4, maids_in_deck=3, other_timelords_in_deck=1, cts_in_deck=3,
  366.            switchyards_in_deck=5, pegasii_in_deck=3, bullets_in_deck=3, cranes_in_deck=3, railcars_in_deck=0, boosters_in_deck=0, other_earth_machines_in_deck=0, knights_in_deck=3, schedules_in_deck=3,
  367.            jizukiru_in_deck=0, burial_in_deck=0, reborn_in_deck=1, pots_desires_in_deck=3, goblin_in_deck=0, pinpoints_in_deck=0,
  368.            added_card=None, removed_card=None)
  369.  
  370. mainmethod("Full Timelords", default_hand_size=default_hand_size, michions_in_deck=3, sandaions_in_deck=4, maids_in_deck=3, other_timelords_in_deck=2, cts_in_deck=3,
  371.            switchyards_in_deck=5, pegasii_in_deck=3, bullets_in_deck=1, cranes_in_deck=1, railcars_in_deck=0, boosters_in_deck=0, other_earth_machines_in_deck=0, knights_in_deck=1, schedules_in_deck=3,
  372.            jizukiru_in_deck=3, burial_in_deck=1, reborn_in_deck=1, pots_desires_in_deck=3, goblin_in_deck=0, pinpoints_in_deck=0,
  373.            added_card=None, removed_card=None)
  374.  
  375. mainmethod("Kaiju Trains", default_hand_size=default_hand_size, michions_in_deck=0, sandaions_in_deck=0, maids_in_deck=0, other_timelords_in_deck=0, cts_in_deck=0,
  376.            switchyards_in_deck=5, pegasii_in_deck=3, bullets_in_deck=3, cranes_in_deck=3, railcars_in_deck=3, boosters_in_deck=0, other_earth_machines_in_deck=0, knights_in_deck=3, schedules_in_deck=3,
  377.            jizukiru_in_deck=3, burial_in_deck=1, reborn_in_deck=1, pots_desires_in_deck=3, goblin_in_deck=1, pinpoints_in_deck=0,
  378.            added_card=None, removed_card=None)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement