Blazephlozard

Pokemon TCG TAS Testing

Jan 29th, 2020
332
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local nome = {"Grass_Energy","Fire_Energy","Water_Energy",
  2. "Lightning_Energy","Fighting_Energy","Psychic_Energy","Double_Colorless_Energy",
  3. "Bulbasaur_LV13","Ivysaur_LV20","Venusaur_LV64(CP!_Promo)","Venusaur_LV67",
  4. "Caterpie_LV13","Metapod_LV21","Butterfree_LV28","Weedle_LV12","Kakuna_LV23",
  5. "Beedrill_LV32","Ekans_LV10","Arbok_LV27","Nidoran_Female_LV13","Nidorina_LV24",
  6. "Nidoqueen_LV43","Nidoran_Male_LV20","Nidorino_LV25","Nidoking_LV48","Zubat_LV10",
  7. "Golbat_LV29","Oddish_LV8","Gloom_LV22","Vileplume_LV35","Paras_LV8",
  8. "Parasect_LV28","Venonat_LV12","Venomoth_LV28","Bellsprout_LV11","Weepinbell_LV28",
  9. "Victreebell_LV42","Grimer_LV17","Muk_LV34","Exeggcute_LV14","Exeggutor_LV35",
  10. "Koffing_LV13","Weezing_LV27","Tangela_LV8_(GB)","Tangela_LV12","Scyther_LV25",
  11. "Pinsir_LV24","Charmander_LV10","CharmelEon_LV32","Charizard_LV76","Vulpix_LV11",
  12. "Ninetails_LV32","Ninetails_LV35_(GB)","Growlithe_LV18","Arcanine_LV34_(Promo)",
  13. "Arcanine_LV45","Ponyta_LV10","Rapidash_LV33","Magmar_LV24","Magmar_LV31_(Fossil)",
  14. "Flareon_LV22_(GB)","Flareon_LV28_(Jungle)","Moltres_LV35",
  15. "Legendary_Moltres_LV37","Squirtle_LV8","Wartortle_LV22","Blastoise_LV52",
  16. "Psyduck_LV15","Golduck_LV27","Poliwag_LV13","Poliwhirl_LV28","Poliwrath_LV48",
  17. "Tentacool_LV10","Tentacruel_LV21","Seel_LV12","Dewgong_LV42","Shellder_LV8",
  18. "Cloyster_LV25","Krabby_LV20","Kingler_LV27","Horsea_LV19","Seadra_LV23",
  19. "Goldeen_LV12","Seaking_LV28","Staryu_LV15","Starmie_LV28","Magikarp_LV8",
  20. "Gyarados_LV41","Lapras_LV31","Vaporeon_LV29_(GB)","Vaporeon_LV42_(Jungle)",
  21. "Omanyte_LV19","Omastar_LV32","Articuno_LV35","Legendary_Articuno_LV37",
  22. "Pikachu_LV12","Pikachu_LV14_(Jungle)","Pikachu_LV16_(promo)",
  23. "Pikachu_LV16_(promo2)","Flying_Pikachu_LV12","Surfing_Pikachu_LV13",
  24. "Surfing_Pikachu_LV13_(2)","Raichu_LV40","Raichu_LV45_(Fossil)","Magnemite_LV13",
  25. "Magnemite_LV15_(GB)","Magneton_LV28","Magneton_LV35_(Fossil)","Voltorb_LV10",
  26. "Electrode_LV35_(GB)","Electrode_LV42_(Jungle)","Electabuzz_LV20_(Promo)",
  27. "Electabuzz_LV35","Jolteon_LV24_(GB)","Jolteon_LV29","Zapdos_LV40",
  28. "Zapdos_LV64_(Fossil)","Legendary_Zapdos_LV68","Sandshrew_LV12","Sandslash_LV33",
  29. "Diglett_LV8","Dugtrio_LV36","Mankey_LV7","Primeape_LV35","Machop_LV20",
  30. "Machoke_LV40","Machamp_LV67","Geodude_LV16","Graveler_LV29","Golem_LV36",
  31. "Onix_LV12","Cubone_LV13","Marowak_LV26_(Jungle)","Marowak_LV32_(GB)",
  32. "Hitmonlee_LV30","Hitmonchan_LV33","Rhyhorn_LV18","Rhydon_LV48","Kabuto_LV9",
  33. "Kabutops_LV30","Aerodactlyl_LV28","Abra_LV10","Kadabra_LV38","Alakazam_LV42",
  34. "Slowpoke_LV9_(Promo)","Slowpoke_LV18_(Fossil)","Slowbro_LV26","Gastly_LV8",
  35. "Gastly_LV17_(Fossil)","Haunter_LV17_(Fossil)","Haunter_LV22","Gengar_LV38",
  36. "Drowzee_LV12","Hypno_LV36","Mr.Mime_LV28","Jynx_LV23","Mewtwo_LV53",
  37. "Mewtwo_LV60_(Promo)","Mewtwo_LV60_(Promo_2)","Mew_LV8_(Promo)",
  38. "Mew_LV15_(CP!_Promo)","Mew_LV23","Pidgey_LV8","Pidgeotto_LV36",
  39. "Pidgeot_LV38_(GB)","Pidgeot_LV40_(Jungle)","Rattata_LV9","Raticate_LV41",
  40. "Spearow_LV13","Fearow_LV27","Clefairy_LV14","Clefable_LV34",
  41. "Jigglypuff_LV12_(Promo)","Jigglypuff_LV13_(GB)","Jigglypuff_LV14_(Jungle)",
  42. "Wigglytuff_LV36","Meowth_LV14_(GB)","Meowth_LV15_(Jungle)","Persian_LV25",
  43. "Farfetch'd_LV20","Doduo_LV10","Dodrio_LV28","Lickitung_LV26","Chansey_LV55",
  44. "Kangaskhan_LV40","Tauros_LV32","Ditto_LV19","Eevee_LV12","Porygon_LV12",
  45. "Snorlax_LV20","Dratini_LV10","Dragonair_LV33","Legendary_Dragonite_LV41",
  46. "Dragonite_LV45","Professor_Oak","Imposter_Professor_Oak","Bill","Mr.Fuji",
  47. "Lass","Imakuni?","Pokemon_Trader","Pokemon_Breeder","Clefairy_Doll",
  48. "Mysterious_Fossil","Energy_Retrieval","Super_Energy_Retrieval","Energy_Search",
  49. "Energy_Removal","Super_Energy_Removal","Switch","Pokemon_Center","Pokeball",
  50. "Scoop_Up","Computer_Search","Pokedex","Pluspower","Defender","Item_Finder",
  51. "Gust_of_Wind","Devolution_Spray","Potion","Super_Potion","Full_Heal","Revive",
  52. "Maintenance","Pokemon_Flute","Gambler","Recycle","","","","","","","","","","",
  53. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  54. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  55. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  56. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  57. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  58. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  59. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  60. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  61. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  62. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  63. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  64. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  65. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  66. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  67. "","","","","","","","","","","","","","","","","","","","","","","","","","","",
  68. "","","","","","","","","","","","","","","","","",}
  69.  
  70. local isBasic =     { false, false, false, false, false, false, false, true, false, false, false, true, false, false, true, false, false, true, false, true, false, false, true, false, false, true, false, true, false, false, true, false, true, false, true, false, false, true, false, true, false, true, false, true, true, true, true, true, false, false, true, false, false, true, false, false, true, false, true, true, false, false, true, true, true, false, false, true, false, true, false, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false, false, false, false, true, true, true, true, true, true, true, true, true, false, false, true, true, false, false, true, false, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, true, false, false, true, true, false, false, true, true, true, false, false, false, false, true, false, false, true, true, false, true, true, false, false, false, true, false, true, true, true, true, true, true, true, true, true, false, false, false, true, false, true, false, true, false, true, true, true, false, true, true, false, true, true, false, true, true, true, true, true, true, true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false }
  71.  
  72. local decks = {}
  73. --1 = lightning & fire, 2 = water & fighting, 3 = grass & psychic
  74. decks[1] = {[0]=2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 7, 7, 48, 48, 49, 50, 54, 54, 56, 57, 57, 58, 59, 60, 96, 97, 103, 105, 105, 107, 109, 109, 109, 110, 111, 167, 167, 168, 195, 197, 197, 207, 207, 210, 210, 216, 216, 217, 217, 221}
  75. decks[2] = {[0]=3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 70, 70, 71, 72, 75, 75, 76, 83, 83, 84, 85, 85, 86, 119, 119, 120, 125, 125, 125, 126, 126, 127, 136, 137, 137, 138, 195, 197, 197, 207, 207, 221, 221, 221, 223, 223}
  76. decks[3] = {[0]=1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 15, 15, 16, 17, 20, 20, 21, 31, 31, 32, 40, 40, 41, 47, 142, 142, 142, 143, 143, 153, 153, 153, 154, 154, 156, 180, 186, 197, 197, 207, 207, 219, 219, 221, 221, 223}
  77.  
  78. local currentDeck = 1
  79.  
  80. memory.usememorydomain("System Bus")
  81.  
  82. --note: none of these are actually used anymore but they're good numbers to have around!
  83. local DeckLocBegin=0xC300
  84. local MyDeckLocBegin=0xC200
  85. local DeckIDBegin=0xC480
  86. local MyDeckIDBegin=0xC400
  87. local ShuffledDeckBegin=0xC37E
  88. local MyShuffledDeckBegin=0xC27E
  89.  
  90. local RNG1 = 0
  91. local RNG2 = 0
  92. local RNG3 = 0
  93. local initRNG1 = RNG1
  94. local initRNG2 = RNG2
  95. local initRNG3 = RNG3
  96.  
  97. function aaronRNG()
  98.     --aaron RNG
  99.     RNG1 = 6
  100.     RNG2 = 151
  101.     RNG3 = 200
  102.     initRNG1 = RNG1
  103.     initRNG2 = RNG2
  104.     initRNG3 = RNG3
  105. end
  106.  
  107. function softRNG()
  108.     --soft reset RNG
  109.     RNG1 = 0x9F
  110.     RNG2 = 0x1E
  111.     RNG3 = 0x6B
  112.     initRNG1 = RNG1
  113.     initRNG2 = RNG2
  114.     initRNG3 = RNG3
  115. end
  116.  
  117.  
  118. local myDeck = {}
  119. local oppDeck = {}
  120.  
  121. for i=0,59 do
  122.     myDeck[i] = i
  123.     oppDeck[i] = i
  124. end
  125.  
  126. --failsafes for Jumps in slot 59
  127. myDeck[60] = 12
  128. myDeck[61] = 0
  129. oppDeck[60] = 12
  130. oppDeck[61] = 0
  131.  
  132. local activeCheck = false
  133. local stackPointer = 0xDFCE
  134. local pastTheFFs = false
  135.  
  136. local absorbs = {}
  137. local jrs = {}
  138. for i=0,59 do
  139.     absorbs[i] = 0
  140.     jrs[i] = 0
  141. end
  142. jrs[0x18] = "JR"
  143. jrs[0x20] = "NZ"
  144. jrs[0x28] = "Z"
  145. jrs[0x30] = "NC"
  146. jrs[0x38] = "C"
  147.  
  148. absorbs[0x01] = 2
  149. absorbs[0x08] = 2
  150. absorbs[0x11] = 2
  151. absorbs[0x21] = 2
  152. absorbs[0x31] = 2
  153.  
  154. absorbs[0x06] = 1
  155. absorbs[0x0E] = 1
  156. absorbs[0x16] = 1
  157. absorbs[0x18] = 1
  158. absorbs[0x1E] = 1
  159. absorbs[0x20] = 1
  160. absorbs[0x26] = 1
  161. absorbs[0x28] = 1
  162. absorbs[0x2E] = 1
  163. absorbs[0x30] = 1
  164. absorbs[0x36] = 1
  165. absorbs[0x38] = 1
  166.  
  167. function reset()
  168.     --Go back to the start, but advance RNG once (simulate checking the next frame)
  169.     RNG1 = initRNG1
  170.     RNG2 = initRNG2
  171.     RNG3 = initRNG3
  172.     advanceRNG()
  173.     initRNG1 = RNG1
  174.     initRNG2 = RNG2
  175.     initRNG3 = RNG3
  176.    
  177.     for i=0,59 do
  178.         myDeck[i] = i
  179.         oppDeck[i] = i
  180.     end
  181.    
  182. end
  183.  
  184. --Test a coinflip without permanently advancing the RNG once
  185. function testCoinflip()
  186.     local tempRNG1 = RNG1
  187.     local tempRNG2 = RNG2
  188.     local tempRNG3 = RNG3
  189.     local flipRNG = advanceRNG() % 2
  190.     RNG1 = tempRNG1
  191.     RNG2 = tempRNG2
  192.     RNG3 = tempRNG3
  193.    
  194.     return flipRNG
  195. end
  196.  
  197. function advanceRNG()
  198.     --Recreation of the code that advances RNG
  199.     local temp = RNG2
  200.     temp = bit.rol(temp,2)
  201.     if (bit.check(temp,8)) then temp = bit.set(temp,0) end
  202.     temp = bit.clear(temp,8)
  203.     if (bit.check(temp,9)) then temp = bit.set(temp,1) end
  204.     temp = bit.clear(temp,9)
  205.     temp = bit.bxor(temp,RNG1)
  206.     local carry = bit.check(temp,0)
  207.    
  208.     RNG2 = bit.bxor(RNG2,RNG1)
  209.    
  210.     temp = RNG3
  211.     temp = bit.bxor(temp,RNG1)
  212.     RNG1 = temp
  213.    
  214.     RNG1 = bit.rol(RNG1,1)
  215.     if (carry) then RNG1 = bit.set(RNG1,0) end
  216.     carry = bit.check(RNG1,8)
  217.     RNG1 = bit.clear(RNG1,8)
  218.    
  219.     RNG2 = bit.rol(RNG2,1)
  220.     if (carry) then RNG2 = bit.set(RNG2,0) end
  221.     RNG2 = bit.clear(RNG2,8)
  222.    
  223.     RNG3 = RNG3 + 1
  224.     if (RNG3 == 256) then RNG3 = 0 end
  225.    
  226.     return (bit.bxor(RNG2,RNG1))
  227. end
  228.  
  229. function randomSlot()
  230.     --Get a random deck slot 0-59
  231.     --This is done by multiplying the RNG value by 60, and taking the left 8 bits
  232.     local rng = advanceRNG()
  233.     local temp = rng * 60
  234.     for i=0,7 do
  235.         if (bit.check(temp,i+8)) then temp = bit.set(temp,i) else temp = bit.clear(temp,i) end
  236.         temp = bit.clear(temp,i+8)
  237.     end
  238.     return temp
  239. end
  240.  
  241. function shuffleDeck(deck)
  242.     --Do 60 location swaps
  243.     for curLoc=0,59 do
  244.         local newLoc = randomSlot()
  245.         local temp = deck[curLoc]
  246.         deck[curLoc] = deck[newLoc]
  247.         deck[newLoc] = temp
  248.     end
  249. end
  250.  
  251. --I don't want a player and opponent copy of this code, it should stay the same between the two (or pass a bool into the function if needed)
  252. function goThroughShuffledDeck(theDeck)
  253.     --Go through each shuffled opcode, simulating JRs and opcode absorbtions
  254.     --To minimize chance of false negatives, I assume conditional JRs fail, unless they'd bring us past the bench FFs
  255.     for h = 0,59 do
  256.         --Non-conditional JR
  257.         if (theDeck[h] == 0x18) then
  258.             if (h + theDeck[h+1] + 1 >= 67) then --I THINK 67 is the magic number
  259.                 pastTheFFs = true
  260.             end
  261.             --h = h + theDeck[h+1] + 1
  262.            
  263.         --Conditional JR
  264.         --Note: theoretically a JR could jump to an opcode that gets absorbed otherwise
  265.         --This is a false negative I'm allowing for now
  266.         elseif (jrs[theDeck[h]] ~= 0) then
  267.             if (h + theDeck[h+1] + 1 >= 67) then
  268.                 pastTheFFs = true
  269.                 break
  270.             end
  271.             --h = h + 1
  272.            
  273.         --Uh oh stinky
  274.         --elseif (theDeck[h] == 0x10) then
  275.             --Note: a JR I've ignored could have jumped over this
  276.             --pastTheFFs = false
  277.             --break
  278.            
  279.         --Load stack pointer
  280.         elseif (theDeck[h] == 0x31) then
  281.             stackPointer = theDeck[h+2]
  282.             stackPointer = bit.rol(stackPointer, 2) + theDeck[h+1]
  283.             --h = h + 2
  284.            
  285.         --increment stack pointer
  286.         elseif (theDeck[h] == 0x33) then
  287.             stackPointer = stackPointer + 1
  288.            
  289.         --decrement stack pointer
  290.         elseif (theDeck[h] == 0x3B) then
  291.             stackPointer = stackPointer - 1
  292.            
  293.         else
  294.             --h = h + absorbs[theDeck[h]]
  295.         end
  296.     end
  297. end
  298.  
  299. function checkForTAS(frames, myReshuffles, theirReshuffles)
  300.    
  301.     local num = 0
  302.     pastTheFFs = false
  303.     local good = false --check for capacity to ACE in shuffled deck
  304.     activeCheck = false --check for $10 Active Pokemon prevention
  305.     stackPointer = 0xDFCE
  306.    
  307.     --Finalize opponent's deck
  308.     if (checkForBasics(frames, myReshuffles, theirReshuffles) == 0) then
  309.         return
  310.     end
  311.    
  312.     --Test for heads coin flip
  313.     if (testCoinflip() == 0) then
  314.         --C200-C23B: card locations
  315.         for h=0,6 do
  316.             --active pokemon can be next to hand card or prize card check
  317.             --note: 19 is very generous and allows Oak+Bill usage
  318.             --I'm not 100% sure this code is right, comparing the C200-C23B section to shuffled deck hurts my head
  319.             for i=0,19 do
  320.                 if (h ~= i and math.abs(myDeck[h] - myDeck[i]) <= 2) then
  321.                     activeCheck = true
  322.                     --does our hand contain a JR opcode we can put out as the active
  323.                     if (jrs[myDeck[h]] ~= 0 and (myDeck[h] - myDeck[i] == 1 or myDeck[h] - myDeck[i] == 2)) then
  324.                         pastTheFFs = true
  325.                     end
  326.                 end
  327.             end
  328.            
  329.         end
  330.         --note: prizes and hand entries aren't being checked yet
  331.         --C27E-C2B9: shuffled deck 0-59
  332.         --Go through each shuffled opcode, simulating JRs and opcode absorbtions
  333.         --To minimize chance of false negatives, I assume conditional JRs fail, unless they'd bring us past the bench FFs
  334.         if (activeCheck) then
  335.             --I don't think we even need to use this function anymore, actually, because pastTheFFs isn't needed
  336.             goThroughShuffledDeck(myDeck)
  337.         end
  338.     end
  339.    
  340.     --possible false positive: if we got our stack pointer right but also jumped past the FFs
  341.     --Skip checking opponent's deck, slide into ours and assume success
  342.     if (stackPointer == 0x391A) then
  343.         printFrame(frames,myReshuffles,theirReshuffles)
  344.     --Do the exact same things but for the opponent's deck now
  345.     --Not my best use of code but oh well
  346.     elseif (activeCheck) then
  347.         activeCheck = false
  348.         pastTheFFs = false
  349.         local foundActive = false
  350.         --C300-C33B: card locations
  351.         for h=6,0,-1 do
  352.             --active pokemon can be next to hand card or prize card check
  353.             --for the opponent, this part involves actually checking if the card is really a Basic
  354.             --false positives will result unless we account for their bench AI here
  355.             --local loc = memory.readbyte(DeckIDBegin+oppDeck[h])
  356.             if (foundActive) then break end
  357.             local loc = decks[currentDeck][oppDeck[h]]
  358.             if (isBasic[loc]) then
  359.                 foundActive = true
  360.                 --include prizes
  361.                 for i=0,10 do
  362.                     if (h ~= i and (oppDeck[h] - oppDeck[i] == 1 or oppDeck[h] - oppDeck[i] == 2)) then
  363.                         activeCheck = true
  364.                     end
  365.                 end
  366.             end
  367.         end
  368.         --note: prizes and hand entries aren't being checked
  369.         --C37E-C3B9: shuffled deck 0-59
  370.         --Go through each shuffled opcode, simulating JRs and opcode absorbtions
  371.         --To minimize chance of false negatives, I assume conditional JRs fail, unless they'd bring us past the bench FFs
  372.         if (activeCheck) then
  373.             goThroughShuffledDeck(oppDeck)
  374.         end
  375.     else
  376.         activeCheck = false
  377.         pastTheFFs = false
  378.    
  379.     end
  380.    
  381.     if (stackPointer == 0x391A) then
  382.         printFrame(frames,myReshuffles,theirReshuffles)
  383.     elseif (activeCheck) then
  384.         printFrame(frames,myReshuffles,theirReshuffles)
  385.     end
  386.    
  387.     if (myReshuffles < 1) then
  388.         for i=0,59 do
  389.             myDeck[i] = i
  390.         end
  391.         shuffleDeck(myDeck)
  392.         shuffleDeck(myDeck)
  393.         checkForTAS(frames, myReshuffles+1, theirReshuffles)
  394.     end
  395.    
  396. end
  397.  
  398. --This checks opponent's hand for basics, and recurses checkForTAS if there are none
  399. function checkForBasics(frames, myReshuffles, theirReshuffles)
  400.     local num = 0
  401.     for h=0,6 do
  402.         --local loc = memory.readbyte(DeckIDBegin+oppDeck[h])
  403.         local loc = decks[currentDeck][oppDeck[h]]
  404.         if (isBasic[loc]) then
  405.             num = num + 1
  406.         end
  407.     end
  408.     --No basics found; time to check both splitting possibilities (one where I reshuffle as well; may as well be thorough!)
  409.     if (num == 0) then
  410.         local tempRNG1 = RNG1
  411.         local tempRNG2 = RNG2
  412.         local tempRNG3 = RNG3
  413.         local tempMyDeck = {}
  414.  
  415.         for i=0,59 do
  416.             tempMyDeck[i] = myDeck[i]
  417.             myDeck[i] = i
  418.             oppDeck[i] = i
  419.         end
  420.         shuffleDeck(myDeck)
  421.         shuffleDeck(myDeck)
  422.         shuffleDeck(oppDeck)
  423.         shuffleDeck(oppDeck)
  424.         checkForTAS(frames, myReshuffles+1, theirReshuffles+1)
  425.         RNG1 = tempRNG1
  426.         RNG2 = tempRNG2
  427.         RNG3 = tempRNG3
  428.         for i=0,59 do
  429.              myDeck[i] = tempMyDeck[i]
  430.              oppDeck[i] = i
  431.         end
  432.         shuffleDeck(oppDeck)
  433.         shuffleDeck(oppDeck)
  434.         checkForTAS(frames, myReshuffles, theirReshuffles+1)
  435.     end
  436.     return num
  437. end
  438.  
  439. function printFrame(frames,myReshuffles,theirReshuffles)
  440.     print("Frame " .. tostring(frames) .. ", Deck " .. tostring(currentDeck))
  441.     file = io.open("frames" .. currentDeck .. ".txt","a")
  442.    
  443.     file:write("Frame " .. tostring(frames) .. ", " .. tostring(myReshuffles) .. " player reshuffles, " .. tostring(theirReshuffles) .. " opponent reshuffles, RNG: " .. tostring(initRNG1) .. " " .. tostring(initRNG2) .. " " .. tostring(initRNG3) .. "\r\n")
  444.    
  445.     file:write("Your deck:\r\n")
  446.     printDeck(myDeck)
  447.     file:write("\r\n\r\nOpponent deck (" .. currentDeck .. "):\r\n")
  448.     printDeck(oppDeck)
  449.     file:write("\r\n")
  450.    
  451.     file:write("Their basics: ")
  452.     for i=6,0,-1 do
  453.         --local loc = memory.readbyte(DeckIDBegin+oppDeck[i])
  454.         local loc = decks[currentDeck][oppDeck[i]]
  455.         if (isBasic[loc]) then
  456.             file:write(string.format("%X", oppDeck[i]) .. ": " .. nome[loc] .. ", ")
  457.         end
  458.     end
  459.     file:write("\r\n")
  460.    
  461.     file:write("=====\r\n")
  462.     file:flush()
  463.     file:close()
  464. end
  465.  
  466. function printDeck(theDeck)
  467.     for i=0,59 do
  468.         if (i > 0 and i % 16 == 0) then
  469.             file:write("\r\n")
  470.         end
  471.        
  472.         hexNum = string.format("%02X", theDeck[i])
  473.         opcode1 = "  "
  474.         opcode2 = "  "
  475.        
  476.         if (jrs[theDeck[i]] ~= 0) then
  477.             opcode1 = " >"
  478.             opcode2 = "> "
  479.             --pure jump gets double arrow
  480.             if (jrs[theDeck[i]] == "JR") then
  481.                 opcode1 = ">>"
  482.                 opcode2 = ">>"
  483.             end
  484.             --putting the flag of jump looks bad
  485.             --if (jrs[theDeck[i]] ~= "JR") then opcode = opcode .. jrs[theDeck[i]] end
  486.         elseif (theDeck[i] == 0x10) then
  487.             opcode1 = " !"
  488.             opcode2 = "! "
  489.         elseif (absorbs[theDeck[i]] == 1) then
  490.             opcode1 = " +"
  491.             opcode2 = "+ "
  492.         elseif (absorbs[theDeck[i]] == 2) then
  493.             opcode1 = "++"
  494.             opcode2 = "++"
  495.         end
  496.         file:write(opcode1 .. hexNum .. opcode2)
  497.     end
  498.     file:write("\r\n")
  499.     --copyable version for cheating purposes
  500.     for i=0,59 do
  501.         file:write(theDeck[i] .. ", ")
  502.     end
  503. end
  504.  
  505. --delete contents of frames.txt
  506. file = io.open("frames1.txt","w")
  507. file:close()
  508. file = io.open("frames2.txt","w")
  509. file:close()
  510. file = io.open("frames3.txt","w")
  511. file:close()
  512.  
  513. --print out aaron's deck contents
  514. --[[file = io.open("frames.txt","a")
  515. for i=0,59 do
  516.     file:write(memory.readbyte(MyDeckIDBegin+i) .. ", ")
  517. end
  518. file:flush()
  519. file:close()]]
  520.  
  521. --Run the main program for 240 frames. I'm probably not going to wait 4 seconds for a frame, but eh
  522. --for counter=0,119 do
  523. for deckChoices=1,3 do
  524.     currentDeck = deckChoices
  525.     aaronRNG()
  526.     for counter=0,60 do
  527.         shuffleDeck(myDeck)
  528.         shuffleDeck(myDeck)
  529.         shuffleDeck(oppDeck)
  530.         shuffleDeck(oppDeck)
  531.        
  532.         --Check for Basic Pokemon on their side, do double reshuffle if they don't have any
  533.         --Technically, if they have no Basics, we could influence RNG by reshuffling as well... So check that as well
  534.         --If they have more than 1 Basic, or a "bad" Basic, the frame is skipped
  535.         checkForTAS(counter, 0, 0)
  536.         --checkForBasics(counter, 0, 0)
  537.         reset()
  538.     end
  539. end
  540.    
  541. print("Completed")
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×