frankkarsten

How reliable is Hollow One?

Feb 15th, 2018
825
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package hollowone;
  2.  
  3. import java.util.Arrays.*;
  4. import java.util.Random;
  5.  
  6. public class HollowOne {
  7.  
  8.     public static void main(String[] args) {
  9.        
  10.         Deck deck=new Deck();
  11.            
  12.         //CardType 1 is a Mountain
  13.         //CardType 2 is a Burning Inquiry
  14.         //CardType 3 is a Faithless Looting
  15.         //CardType 4 is a Goblin Lore
  16.         //CardType 5 is a Street Wraith
  17.         //CardType 6 is a Hollow One
  18.         //CardType 7 is another, irrelevant card
  19.        
  20.         deck.SetDeck(18,4,4,4,4,4,22);
  21.         Deck remainingdeck=new Deck();
  22.         double NumberOfGamesWith1HollowTurn1=0;
  23.         double NumberOfGamesWith2HollowTurn1=0;
  24.         double NumberOfGamesWith3HollowTurn1=0;
  25.         double NumberOfGamesWith4HollowTurn1=0;
  26.         double NumberOfGamesWith1HollowTurn2=0;
  27.         double NumberOfGamesWith2HollowTurn2=0;
  28.         double NumberOfGamesWith3HollowTurn2=0;
  29.         double NumberOfGamesWith4HollowTurn2=0;
  30.         double NumberOfGamesFailures=0;
  31.         int NumberOfIterations=10000000;
  32.        
  33.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  34.            
  35.             OpeningHand openinghand=GiveOpeningHandAfterMulls(deck, 7);
  36.             remainingdeck.SetDeck(deck.NumberOfLands-openinghand.NumberOfLands,deck.NumberOfCardType2-openinghand.NumberOfCardType2,deck.NumberOfCardType3-openinghand.NumberOfCardType3,deck.NumberOfCardType4-openinghand.NumberOfCardType4,deck.NumberOfCardType5-openinghand.NumberOfCardType5,deck.NumberOfCardType6-openinghand.NumberOfCardType6,deck.NumberOfSpells-openinghand.NumberOfSpells);
  37.             boolean OnThePlay = false;
  38.             if (IterationCounter % 2 ==0) {OnThePlay=true;}
  39.             int Outcome=SimulateGame(remainingdeck,openinghand,OnThePlay);
  40.            
  41.             if (Outcome==0) {NumberOfGamesFailures++;}
  42.             if (Outcome==1) {NumberOfGamesWith1HollowTurn1++;}
  43.             if (Outcome==2) {NumberOfGamesWith2HollowTurn1++;}
  44.             if (Outcome==3) {NumberOfGamesWith3HollowTurn1++;}
  45.             if (Outcome==4) {NumberOfGamesWith4HollowTurn1++;}
  46.             if (Outcome==11) {NumberOfGamesWith1HollowTurn2++;}
  47.             if (Outcome==12) {NumberOfGamesWith2HollowTurn2++;}
  48.             if (Outcome==13) {NumberOfGamesWith3HollowTurn2++;}
  49.             if (Outcome==14) {NumberOfGamesWith4HollowTurn2++;}
  50.            
  51.         }
  52.  
  53.         System.out.println(Math.round((NumberOfGamesWith1HollowTurn1/NumberOfIterations)*10000)/100.0);
  54.         System.out.println(Math.round((NumberOfGamesWith2HollowTurn1/NumberOfIterations)*10000)/100.0);
  55.         System.out.println(Math.round((NumberOfGamesWith3HollowTurn1/NumberOfIterations)*10000)/100.0);
  56.         System.out.println(Math.round((NumberOfGamesWith4HollowTurn1/NumberOfIterations)*10000)/100.0);
  57.         System.out.println(Math.round((NumberOfGamesWith1HollowTurn2/NumberOfIterations)*10000)/100.0);
  58.         System.out.println(Math.round((NumberOfGamesWith2HollowTurn2/NumberOfIterations)*10000)/100.0);
  59.         System.out.println(Math.round((NumberOfGamesWith3HollowTurn2/NumberOfIterations)*10000)/100.0);
  60.         System.out.println(Math.round((NumberOfGamesWith4HollowTurn2/NumberOfIterations)*10000)/100.0);
  61.         System.out.println(Math.round((NumberOfGamesFailures/NumberOfIterations)*10000)/100.0);
  62.        
  63.     }//end of main
  64.  
  65.    
  66.     static OpeningHand GiveOpeningHandAfterMulls (Deck deck, int StartingCards) {
  67.        
  68.         Deck remainingdeck=new Deck();
  69.         OpeningHand openinghand=new OpeningHand();
  70.         int TypeOfCardDrawn;
  71.         boolean KeepHand=false;
  72.        
  73.         for (int OpeningHandSize=7; OpeningHandSize>=1; OpeningHandSize--){
  74.             if (KeepHand==false){
  75.                 openinghand.SetHand(0,0,0,0,0,0,0);
  76.                 remainingdeck.SetDeck(deck.NumberOfLands,deck.NumberOfCardType2,deck.NumberOfCardType3,deck.NumberOfCardType4,deck.NumberOfCardType5,deck.NumberOfCardType6,deck.NumberOfSpells);
  77.                 int NumberOfLands=0;
  78.                 int NumberOfKeyCards=0;
  79.                 for (int CardsDrawn=0; CardsDrawn<OpeningHandSize; CardsDrawn++){
  80.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  81.                     if (TypeOfCardDrawn==1) {openinghand.NumberOfLands++; NumberOfLands++;}
  82.                     if (TypeOfCardDrawn==2) {openinghand.NumberOfCardType2++; NumberOfKeyCards++;}
  83.                     if (TypeOfCardDrawn==3) {openinghand.NumberOfCardType3++; NumberOfKeyCards++;}
  84.                     if (TypeOfCardDrawn==4) {openinghand.NumberOfCardType4++; NumberOfKeyCards++;}
  85.                     if (TypeOfCardDrawn==5) {openinghand.NumberOfCardType5++; NumberOfKeyCards++;}
  86.                     if (TypeOfCardDrawn==6) {openinghand.NumberOfCardType6++; NumberOfKeyCards++;}
  87.                     if (TypeOfCardDrawn==7) {openinghand.NumberOfSpells++;}
  88.                 }
  89.                 KeepHand=true;
  90.                 if (OpeningHandSize>1) {
  91.                     // We mulligan a hand if it contains 0, 1, 6, or 7 lands
  92.                     if (NumberOfLands<=1 || NumberOfLands>=6) {KeepHand=false;}
  93.                     // We also mulligan a 6-card or 7-card hand if we have no key card (card-draw spell or cycler)
  94.                     if (OpeningHandSize>=5 && NumberOfKeyCards==0) {KeepHand=false;}
  95.                 }
  96.             }
  97.         }
  98.        
  99.         return openinghand;
  100.     }//end of GiveOpeningHandAfterMulls
  101.    
  102.    
  103.     static int SimulateGame(Deck remainingdeck, OpeningHand openinghand, boolean OnThePlay) {
  104.        
  105.         //Initializing
  106.        
  107.         int TypeOfCardDrawn=0;
  108.         int Outcome=0;
  109.         int MountainInPlay=0;
  110.         boolean LandDrop;
  111.         int NrCardsDiscardedThisTurn;
  112.         int ManaRemaining;
  113.         int HollowOnesPlayed;
  114.         OpeningHand HandForRandomDiscard=new OpeningHand();
  115.         int PossibleLands;
  116.         int MountainInHand=openinghand.NumberOfLands;
  117.         int BurningInquiryInHand=openinghand.NumberOfCardType2;
  118.         int FaithlessLootingInHand=openinghand.NumberOfCardType3;
  119.         int GoblinLoreInHand=openinghand.NumberOfCardType4;
  120.         int StreetWraithInHand=openinghand.NumberOfCardType5;
  121.         int HollowOneInHand=openinghand.NumberOfCardType6;
  122.         int ExtraSpellsInHand=openinghand.NumberOfSpells;
  123.  
  124.         //Turn 1
  125.        
  126.         if (OnThePlay==false) {
  127.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  128.                 if (TypeOfCardDrawn==1) {MountainInHand++;}
  129.                 if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  130.                 if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  131.                 if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  132.                 if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  133.                 if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  134.                 if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  135.             }
  136.  
  137.         NrCardsDiscardedThisTurn=0;
  138.         LandDrop=false;
  139.         ManaRemaining=0;
  140.         HollowOnesPlayed=0;
  141.        
  142.         while (StreetWraithInHand>0){
  143.                 StreetWraithInHand--;
  144.                 NrCardsDiscardedThisTurn++;
  145.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  146.                 if (TypeOfCardDrawn==1) {MountainInHand++;}
  147.                 if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  148.                 if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  149.                 if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  150.                 if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  151.                 if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  152.                 if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  153.         }
  154.  
  155.         if (NrCardsDiscardedThisTurn>=3) {
  156.             HollowOnesPlayed=HollowOneInHand;
  157.             HollowOneInHand=0;
  158.         }
  159.        
  160.         if (MountainInHand>0) {MountainInHand--; MountainInPlay++; ManaRemaining++; LandDrop=true;}
  161.        
  162.         if (ManaRemaining>=1 && FaithlessLootingInHand>=1 && BurningInquiryInHand==0) {
  163.             FaithlessLootingInHand--;
  164.             ManaRemaining--;
  165.             NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+2;
  166.             for (int CardsDrawn=1; CardsDrawn<=2; CardsDrawn++){
  167.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  168.                 if (TypeOfCardDrawn==1) {MountainInHand++;}
  169.                 if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  170.                 if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  171.                 if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  172.                 if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  173.                 if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  174.                 if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  175.             }
  176.  
  177.             int CardsToDiscardToLooting=2;
  178.  
  179.             //Try to discard irrelevant cards if possible
  180.            
  181.             int SpellsThatCanBeDiscarded=Math.min(ExtraSpellsInHand,CardsToDiscardToLooting);
  182.             CardsToDiscardToLooting=CardsToDiscardToLooting-SpellsThatCanBeDiscarded;
  183.             ExtraSpellsInHand=ExtraSpellsInHand-SpellsThatCanBeDiscarded;
  184.  
  185.             int LandsOverSecondThatCanBeDiscarded=Math.min(Math.max(MountainInHand-1,0),CardsToDiscardToLooting);
  186.             CardsToDiscardToLooting=CardsToDiscardToLooting-LandsOverSecondThatCanBeDiscarded;
  187.             MountainInHand=MountainInHand-LandsOverSecondThatCanBeDiscarded;
  188.  
  189.             int GoblinLoresThatCanBeDiscarded=Math.min(GoblinLoreInHand,CardsToDiscardToLooting);
  190.             CardsToDiscardToLooting=CardsToDiscardToLooting-GoblinLoresThatCanBeDiscarded;
  191.             GoblinLoreInHand=GoblinLoreInHand-GoblinLoresThatCanBeDiscarded;
  192.  
  193.             int FaithlessLootingThatCanBeDiscarded=Math.min(FaithlessLootingInHand,CardsToDiscardToLooting);
  194.             CardsToDiscardToLooting=CardsToDiscardToLooting-FaithlessLootingThatCanBeDiscarded;
  195.             FaithlessLootingInHand=FaithlessLootingInHand-FaithlessLootingThatCanBeDiscarded;
  196.  
  197.             //It is extremely unlikely that we aren't done discarding to Faithless Looting by now, but let's catch all the corner cases
  198.  
  199.             int PossibleSecondLandToDiscard=Math.min(MountainInHand,CardsToDiscardToLooting);
  200.             CardsToDiscardToLooting=CardsToDiscardToLooting-PossibleSecondLandToDiscard;
  201.             MountainInHand=MountainInHand-PossibleSecondLandToDiscard;
  202.  
  203.             int BurningInquiryThatCanBeDiscarded=Math.min(BurningInquiryInHand,CardsToDiscardToLooting);
  204.             CardsToDiscardToLooting=CardsToDiscardToLooting-BurningInquiryThatCanBeDiscarded;
  205.             BurningInquiryInHand=BurningInquiryInHand-BurningInquiryThatCanBeDiscarded;
  206.  
  207.             int StreetWraithThatCanBeDiscarded=Math.min(StreetWraithInHand,CardsToDiscardToLooting);
  208.             CardsToDiscardToLooting=CardsToDiscardToLooting-StreetWraithThatCanBeDiscarded;
  209.             StreetWraithInHand=StreetWraithInHand-StreetWraithThatCanBeDiscarded;
  210.  
  211.             int HollowOneToSadlyDiscard=Math.min(HollowOneInHand,CardsToDiscardToLooting);
  212.             CardsToDiscardToLooting=CardsToDiscardToLooting-HollowOneToSadlyDiscard;
  213.             HollowOneInHand=HollowOneInHand-HollowOneToSadlyDiscard;
  214.        
  215.             //We have now resolved Faithless Looting
  216.         }
  217.        
  218.         if (ManaRemaining>0 && BurningInquiryInHand>=1) {
  219.             BurningInquiryInHand--;
  220.             ManaRemaining--;
  221.             NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
  222.             for (int CardsDrawn=1; CardsDrawn<=3; CardsDrawn++){
  223.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  224.                 if (TypeOfCardDrawn==1) {MountainInHand++;}
  225.                 if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  226.                 if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  227.                 if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  228.                 if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  229.                 if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  230.                 if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  231.             }
  232.  
  233.             HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
  234.             HandForRandomDiscard.DeleteThreeCardsAtRandom();
  235.             MountainInHand=HandForRandomDiscard.NumberOfLands;
  236.             BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
  237.             FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
  238.             GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
  239.             StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
  240.             HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
  241.             ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
  242.         }
  243.  
  244.         while (StreetWraithInHand>0){
  245.             StreetWraithInHand--;
  246.             NrCardsDiscardedThisTurn++;
  247.             TypeOfCardDrawn=remainingdeck.DrawCard();
  248.             if (TypeOfCardDrawn==1) {MountainInHand++;}
  249.             if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  250.             if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  251.             if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  252.             if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  253.             if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  254.             if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  255.         }
  256.        
  257.         // Cast turn-one Hollow Ones
  258.        
  259.         if (NrCardsDiscardedThisTurn>=3) {
  260.             Outcome=HollowOneInHand+HollowOnesPlayed;
  261.             HollowOneInHand=0;
  262.         }
  263.        
  264.         if (NrCardsDiscardedThisTurn>=2 && ManaRemaining==1 && HollowOneInHand>=1) {
  265.             Outcome=1;
  266.             HollowOneInHand=HollowOneInHand-1;
  267.         }
  268.        
  269.         //Turn 2 (if we cast 0 Hollow Ones on turn 1)
  270.        
  271.         if (Outcome == 0 ){
  272.            
  273.             TypeOfCardDrawn=remainingdeck.DrawCard();
  274.             if (TypeOfCardDrawn==1) {MountainInHand++;}
  275.             if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  276.             if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  277.             if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  278.             if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  279.             if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  280.             if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  281.  
  282.             NrCardsDiscardedThisTurn=0;
  283.             LandDrop=false;
  284.             ManaRemaining=0;
  285.             HollowOnesPlayed=0;
  286.  
  287.             while (StreetWraithInHand>0){
  288.                     StreetWraithInHand--;
  289.                     NrCardsDiscardedThisTurn++;
  290.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  291.                     if (TypeOfCardDrawn==1) {MountainInHand++;}
  292.                     if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  293.                     if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  294.                     if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  295.                     if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  296.                     if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  297.                     if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  298.             }
  299.  
  300.             if (NrCardsDiscardedThisTurn>=3) {
  301.                 HollowOnesPlayed=HollowOneInHand;
  302.                 HollowOneInHand=0;
  303.             }
  304.        
  305.             PossibleLands=MountainInPlay+MountainInHand;
  306.             if (MountainInPlay==0 && MountainInHand>0) {MountainInHand--; MountainInPlay++; LandDrop=true;}
  307.             ManaRemaining=MountainInPlay;
  308.            
  309.             // Turn 2 logic:
  310.             // If you have [ >=2 lands between hand/battlefield and { >=2 Looting/Inquiry OR ( >=1 Looting/Inquiry and no Goblin Lore) } ] OR [ one land between hand/battlefield and >=1 Looting/Inquiry]:
  311.             //      First (Inquiry if possible, else Looting), then Wraiths, then Hollow Ones, then another land if possible, then (Inquiry if possible, else Looting if possible), then Wraiths.
  312.             // If you have two lands between hand/battlefield and ( < Looting/Inquiry AND >=1 Goblin Lore):
  313.             //      Drop land, cast Goblin Lore, then Wraiths.
  314.            
  315.             if ((PossibleLands>=2 && ( FaithlessLootingInHand+BurningInquiryInHand>=2 || (FaithlessLootingInHand+BurningInquiryInHand>=1 && GoblinLoreInHand==0))) || ( PossibleLands==1 && FaithlessLootingInHand+BurningInquiryInHand>=1) ) {
  316.                
  317.                 if (BurningInquiryInHand>=1 && ManaRemaining>=1){
  318.                     BurningInquiryInHand--;
  319.                     ManaRemaining--;
  320.                     NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
  321.                     for (int CardsDrawn=1; CardsDrawn<=3; CardsDrawn++){
  322.                         TypeOfCardDrawn=remainingdeck.DrawCard();
  323.                         if (TypeOfCardDrawn==1) {MountainInHand++;}
  324.                         if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  325.                         if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  326.                         if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  327.                         if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  328.                         if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  329.                         if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  330.                     }
  331.  
  332.                     HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
  333.                     HandForRandomDiscard.DeleteThreeCardsAtRandom();
  334.                     MountainInHand=HandForRandomDiscard.NumberOfLands;
  335.                     BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
  336.                     FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
  337.                     GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
  338.                     StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
  339.                     HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
  340.                     ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
  341.                 }
  342.  
  343.                 if (FaithlessLootingInHand>=1 && ManaRemaining>=1){
  344.                     FaithlessLootingInHand--;
  345.                     ManaRemaining--;
  346.                     NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+2;
  347.                     for (int CardsDrawn=1; CardsDrawn<=2; CardsDrawn++){
  348.                         TypeOfCardDrawn=remainingdeck.DrawCard();
  349.                         if (TypeOfCardDrawn==1) {MountainInHand++;}
  350.                         if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  351.                         if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  352.                         if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  353.                         if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  354.                         if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  355.                         if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  356.                     }
  357.  
  358.                     int CardsToDiscardToLooting=2;
  359.  
  360.                     //Try to discard irrelevant cards if possible
  361.  
  362.                     int SpellsThatCanBeDiscarded=Math.min(ExtraSpellsInHand,CardsToDiscardToLooting);
  363.                     CardsToDiscardToLooting=CardsToDiscardToLooting-SpellsThatCanBeDiscarded;
  364.                     ExtraSpellsInHand=ExtraSpellsInHand-SpellsThatCanBeDiscarded;
  365.  
  366.                     int LandsOverSecondThatCanBeDiscarded=Math.min(Math.max(MountainInHand-1,0),CardsToDiscardToLooting);
  367.                     CardsToDiscardToLooting=CardsToDiscardToLooting-LandsOverSecondThatCanBeDiscarded;
  368.                     MountainInHand=MountainInHand-LandsOverSecondThatCanBeDiscarded;
  369.  
  370.                     int GoblinLoresThatCanBeDiscarded=Math.min(GoblinLoreInHand,CardsToDiscardToLooting);
  371.                     CardsToDiscardToLooting=CardsToDiscardToLooting-GoblinLoresThatCanBeDiscarded;
  372.                     GoblinLoreInHand=GoblinLoreInHand-GoblinLoresThatCanBeDiscarded;
  373.  
  374.                     int FaithlessLootingThatCanBeDiscarded=Math.min(FaithlessLootingInHand,CardsToDiscardToLooting);
  375.                     CardsToDiscardToLooting=CardsToDiscardToLooting-FaithlessLootingThatCanBeDiscarded;
  376.                     FaithlessLootingInHand=FaithlessLootingInHand-FaithlessLootingThatCanBeDiscarded;
  377.  
  378.                     //It is extremely unlikely that we aren't done discarding to Faithless Looting by now, but let's catch all the corner cases
  379.  
  380.                     int PossibleSecondLandToDiscard=Math.min(MountainInHand,CardsToDiscardToLooting);
  381.                     CardsToDiscardToLooting=CardsToDiscardToLooting-PossibleSecondLandToDiscard;
  382.                     MountainInHand=MountainInHand-PossibleSecondLandToDiscard;
  383.  
  384.                     int BurningInquiryThatCanBeDiscarded=Math.min(BurningInquiryInHand,CardsToDiscardToLooting);
  385.                     CardsToDiscardToLooting=CardsToDiscardToLooting-BurningInquiryThatCanBeDiscarded;
  386.                     BurningInquiryInHand=BurningInquiryInHand-BurningInquiryThatCanBeDiscarded;
  387.  
  388.                     int StreetWraithThatCanBeDiscarded=Math.min(StreetWraithInHand,CardsToDiscardToLooting);
  389.                     CardsToDiscardToLooting=CardsToDiscardToLooting-StreetWraithThatCanBeDiscarded;
  390.                     StreetWraithInHand=StreetWraithInHand-StreetWraithThatCanBeDiscarded;
  391.  
  392.                     int HollowOneToSadlyDiscard=Math.min(HollowOneInHand,CardsToDiscardToLooting);
  393.                     CardsToDiscardToLooting=CardsToDiscardToLooting-HollowOneToSadlyDiscard;
  394.                     HollowOneInHand=HollowOneInHand-HollowOneToSadlyDiscard;
  395.  
  396.                     //We have now resolved Faithless Looting
  397.                 }
  398.                
  399.                 while (StreetWraithInHand>0){
  400.                     StreetWraithInHand--;
  401.                     NrCardsDiscardedThisTurn++;
  402.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  403.                     if (TypeOfCardDrawn==1) {MountainInHand++;}
  404.                     if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  405.                     if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  406.                     if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  407.                     if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  408.                     if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  409.                     if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  410.                 }    
  411.                
  412.                 if (NrCardsDiscardedThisTurn>=3) {
  413.                     HollowOnesPlayed=HollowOnesPlayed+HollowOneInHand;
  414.                     HollowOneInHand=0;
  415.                 }
  416.                
  417.                 if (MountainInHand>=1 && LandDrop==false) {
  418.                     MountainInHand--; MountainInPlay++; LandDrop=true; ManaRemaining++;
  419.                 }
  420.                
  421.                 if (BurningInquiryInHand>=1 && ManaRemaining>=1){
  422.                     BurningInquiryInHand--;
  423.                     ManaRemaining--;
  424.                     NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
  425.                     for (int CardsDrawn=1; CardsDrawn<=3; CardsDrawn++){
  426.                         TypeOfCardDrawn=remainingdeck.DrawCard();
  427.                         if (TypeOfCardDrawn==1) {MountainInHand++;}
  428.                         if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  429.                         if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  430.                         if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  431.                         if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  432.                         if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  433.                         if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  434.                     }
  435.  
  436.                     HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
  437.                     HandForRandomDiscard.DeleteThreeCardsAtRandom();
  438.                     MountainInHand=HandForRandomDiscard.NumberOfLands;
  439.                     BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
  440.                     FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
  441.                     GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
  442.                     StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
  443.                     HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
  444.                     ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
  445.                 }
  446.  
  447.                 if (FaithlessLootingInHand>=1 && ManaRemaining>=1){
  448.                     FaithlessLootingInHand--;
  449.                     ManaRemaining--;
  450.                     NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+2;
  451.                     for (int CardsDrawn=1; CardsDrawn<=2; CardsDrawn++){
  452.                         TypeOfCardDrawn=remainingdeck.DrawCard();
  453.                         if (TypeOfCardDrawn==1) {MountainInHand++;}
  454.                         if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  455.                         if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  456.                         if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  457.                         if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  458.                         if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  459.                         if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  460.                     }
  461.  
  462.                     int CardsToDiscardToLooting=2;
  463.  
  464.                     //Try to discard irrelevant cards if possible
  465.  
  466.                     int SpellsThatCanBeDiscarded=Math.min(ExtraSpellsInHand,CardsToDiscardToLooting);
  467.                     CardsToDiscardToLooting=CardsToDiscardToLooting-SpellsThatCanBeDiscarded;
  468.                     ExtraSpellsInHand=ExtraSpellsInHand-SpellsThatCanBeDiscarded;
  469.  
  470.                     int LandsOverSecondThatCanBeDiscarded=Math.min(Math.max(MountainInHand-1,0),CardsToDiscardToLooting);
  471.                     CardsToDiscardToLooting=CardsToDiscardToLooting-LandsOverSecondThatCanBeDiscarded;
  472.                     MountainInHand=MountainInHand-LandsOverSecondThatCanBeDiscarded;
  473.  
  474.                     int GoblinLoresThatCanBeDiscarded=Math.min(GoblinLoreInHand,CardsToDiscardToLooting);
  475.                     CardsToDiscardToLooting=CardsToDiscardToLooting-GoblinLoresThatCanBeDiscarded;
  476.                     GoblinLoreInHand=GoblinLoreInHand-GoblinLoresThatCanBeDiscarded;
  477.  
  478.                     int FaithlessLootingThatCanBeDiscarded=Math.min(FaithlessLootingInHand,CardsToDiscardToLooting);
  479.                     CardsToDiscardToLooting=CardsToDiscardToLooting-FaithlessLootingThatCanBeDiscarded;
  480.                     FaithlessLootingInHand=FaithlessLootingInHand-FaithlessLootingThatCanBeDiscarded;
  481.  
  482.                     //It is extremely unlikely that we aren't done discarding to Faithless Looting by now, but let's catch all the corner cases
  483.  
  484.                     int PossibleSecondLandToDiscard=Math.min(MountainInHand,CardsToDiscardToLooting);
  485.                     CardsToDiscardToLooting=CardsToDiscardToLooting-PossibleSecondLandToDiscard;
  486.                     MountainInHand=MountainInHand-PossibleSecondLandToDiscard;
  487.  
  488.                     int BurningInquiryThatCanBeDiscarded=Math.min(BurningInquiryInHand,CardsToDiscardToLooting);
  489.                     CardsToDiscardToLooting=CardsToDiscardToLooting-BurningInquiryThatCanBeDiscarded;
  490.                     BurningInquiryInHand=BurningInquiryInHand-BurningInquiryThatCanBeDiscarded;
  491.  
  492.                     int StreetWraithThatCanBeDiscarded=Math.min(StreetWraithInHand,CardsToDiscardToLooting);
  493.                     CardsToDiscardToLooting=CardsToDiscardToLooting-StreetWraithThatCanBeDiscarded;
  494.                     StreetWraithInHand=StreetWraithInHand-StreetWraithThatCanBeDiscarded;
  495.  
  496.                     int HollowOneToSadlyDiscard=Math.min(HollowOneInHand,CardsToDiscardToLooting);
  497.                     CardsToDiscardToLooting=CardsToDiscardToLooting-HollowOneToSadlyDiscard;
  498.                     HollowOneInHand=HollowOneInHand-HollowOneToSadlyDiscard;
  499.  
  500.                     //We have now resolved Faithless Looting
  501.                 }
  502.                
  503.             }
  504.  
  505.             if (MountainInHand>=1 && LandDrop==false) {
  506.                 MountainInHand--; MountainInPlay++; LandDrop=true; ManaRemaining++;
  507.             }
  508.            
  509.             if (NrCardsDiscardedThisTurn==2 && HollowOneInHand>=2 && ManaRemaining>=2) {
  510.                 HollowOnesPlayed=HollowOnesPlayed+2;
  511.                 HollowOneInHand=HollowOneInHand-2;
  512.                 ManaRemaining=0;
  513.             }
  514.            
  515.             if (NrCardsDiscardedThisTurn==2 && HollowOneInHand>=1 && ManaRemaining>=1 && GoblinLoreInHand==0) {
  516.                 HollowOnesPlayed=HollowOnesPlayed+Math.min(HollowOneInHand,ManaRemaining);
  517.                 HollowOneInHand=HollowOneInHand-Math.min(HollowOneInHand,ManaRemaining);
  518.                 ManaRemaining=ManaRemaining-Math.min(HollowOneInHand,ManaRemaining);
  519.             }
  520.            
  521.             if (ManaRemaining>=2 && GoblinLoreInHand>=1) {
  522.                 GoblinLoreInHand--;
  523.                 ManaRemaining=ManaRemaining-2;
  524.                 NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
  525.                 for (int CardsDrawn=1; CardsDrawn<=4; CardsDrawn++){
  526.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  527.                     if (TypeOfCardDrawn==1) {MountainInHand++;}
  528.                     if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  529.                     if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  530.                     if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  531.                     if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  532.                     if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  533.                     if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  534.                 }
  535.  
  536.                 HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
  537.                 HandForRandomDiscard.DeleteThreeCardsAtRandom();
  538.                 MountainInHand=HandForRandomDiscard.NumberOfLands;
  539.                 BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
  540.                 FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
  541.                 GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
  542.                 StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
  543.                 HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
  544.                 ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
  545.             }
  546.            
  547.             //If all else fails, cycle Hollow One and hope
  548.            
  549.             if (ManaRemaining>=2 && HollowOneInHand>=1) {
  550.                 HollowOneInHand--;
  551.                 ManaRemaining=ManaRemaining-2;
  552.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  553.                 if (TypeOfCardDrawn==1) {MountainInHand++;}
  554.                 if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  555.                 if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  556.                 if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  557.                 if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  558.                 if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  559.                 if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  560.             }
  561.            
  562.             while (StreetWraithInHand>0){
  563.                 StreetWraithInHand--;
  564.                 NrCardsDiscardedThisTurn++;
  565.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  566.                 if (TypeOfCardDrawn==1) {MountainInHand++;}
  567.                 if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
  568.                 if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
  569.                 if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
  570.                 if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
  571.                 if (TypeOfCardDrawn==6) {HollowOneInHand++;}
  572.                 if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
  573.             }
  574.        
  575.             // Cast turn-two Hollow Ones
  576.        
  577.             if (NrCardsDiscardedThisTurn>=3 && HollowOneInHand+HollowOnesPlayed>0) {
  578.                 Outcome=10+HollowOneInHand+HollowOnesPlayed;
  579.                 HollowOneInHand=0;
  580.             }
  581.  
  582.             if (NrCardsDiscardedThisTurn==2 && HollowOnesPlayed>0) {
  583.                 Outcome=10+HollowOnesPlayed;
  584.             }
  585.  
  586.         }            
  587.  
  588.         return Outcome;
  589.     }//end of SimulateGame
  590.    
  591. }
  592.  
  593. class OpeningHand {
  594.     int NumberOfLands;
  595.     int NumberOfCardType2;
  596.     int NumberOfCardType3;
  597.     int NumberOfCardType4;
  598.     int NumberOfCardType5;
  599.     int NumberOfCardType6;
  600.     int NumberOfSpells;
  601.  
  602.     int NrOfCards(){
  603.         return NumberOfLands+NumberOfCardType2+NumberOfCardType3+NumberOfCardType4+NumberOfCardType5+NumberOfCardType6+NumberOfSpells;
  604.     }
  605.  
  606.     void SetHand (int Nr1, int Nr2, int Nr3, int Nr4, int Nr5, int Nr6, int Nr7) {
  607.         NumberOfLands=Nr1;
  608.         NumberOfCardType2=Nr2;
  609.         NumberOfCardType3=Nr3;
  610.         NumberOfCardType4=Nr4;
  611.         NumberOfCardType5=Nr5;
  612.         NumberOfCardType6=Nr6;
  613.         NumberOfSpells=Nr7;
  614.     }
  615.    
  616.     void DeleteThreeCardsAtRandom () {
  617.         Random generator = new Random();
  618.         int CardType=0;
  619.         for (int RandomDiscard=1; RandomDiscard<=3; RandomDiscard++){
  620.             int RandomIntegerBetweenOneAndHandSize=generator.nextInt( this.NrOfCards() )+1;
  621.             int OneCutoff=NumberOfLands;
  622.             int TwoCutoff=OneCutoff+NumberOfCardType2;
  623.             int ThreeCutoff=TwoCutoff+NumberOfCardType3;
  624.             int FourCutoff=ThreeCutoff+NumberOfCardType4;
  625.             int FiveCutoff=FourCutoff+NumberOfCardType5;
  626.             int SixCutoff=FiveCutoff+NumberOfCardType6;
  627.             int SevenCutoff=SixCutoff+NumberOfSpells;
  628.  
  629.             if (RandomIntegerBetweenOneAndHandSize<=OneCutoff) {this.NumberOfLands--;}
  630.             if (RandomIntegerBetweenOneAndHandSize>OneCutoff && RandomIntegerBetweenOneAndHandSize<=TwoCutoff) {CardType=2; this.NumberOfCardType2--;}
  631.             if (RandomIntegerBetweenOneAndHandSize>TwoCutoff && RandomIntegerBetweenOneAndHandSize<=ThreeCutoff) {CardType=3; this.NumberOfCardType3--;}
  632.             if (RandomIntegerBetweenOneAndHandSize>ThreeCutoff && RandomIntegerBetweenOneAndHandSize<=FourCutoff) {CardType=4; this.NumberOfCardType4--;}
  633.             if (RandomIntegerBetweenOneAndHandSize>FourCutoff && RandomIntegerBetweenOneAndHandSize<=FiveCutoff) {CardType=5; this.NumberOfCardType5--;}
  634.             if (RandomIntegerBetweenOneAndHandSize>FiveCutoff && RandomIntegerBetweenOneAndHandSize<=SixCutoff) {CardType=6; this.NumberOfCardType6--;}
  635.             if (RandomIntegerBetweenOneAndHandSize>SixCutoff && RandomIntegerBetweenOneAndHandSize<=SevenCutoff) {CardType=7; this.NumberOfSpells--;}
  636.         }
  637.     }
  638.  
  639. }//end of OpeningHand
  640.  
  641. class Deck {
  642.     int NumberOfLands;
  643.     int NumberOfCardType2;
  644.     int NumberOfCardType3;
  645.     int NumberOfCardType4;
  646.     int NumberOfCardType5;
  647.     int NumberOfCardType6;
  648.     int NumberOfSpells;
  649.    
  650.     void SetDeck (int Nr1, int Nr2, int Nr3, int Nr4, int Nr5, int Nr6, int Nr7) {
  651.         NumberOfLands=Nr1;
  652.         NumberOfCardType2=Nr2;
  653.         NumberOfCardType3=Nr3;
  654.         NumberOfCardType4=Nr4;
  655.         NumberOfCardType5=Nr5;
  656.         NumberOfCardType6=Nr6;
  657.         NumberOfSpells=Nr7;
  658.     }
  659.    
  660.     int NrOfCards(){
  661.         return NumberOfLands+NumberOfCardType2+NumberOfCardType3+NumberOfCardType4+NumberOfCardType5+NumberOfCardType6+NumberOfSpells;
  662.     }
  663.    
  664.     int DrawCard (){
  665.         Random generator = new Random();
  666.         int CardType=0;
  667.         int RandomIntegerBetweenOneAndDeckSize=generator.nextInt( this.NrOfCards() )+1;
  668.         int OneCutoff=NumberOfLands;
  669.         int TwoCutoff=OneCutoff+NumberOfCardType2;
  670.         int ThreeCutoff=TwoCutoff+NumberOfCardType3;
  671.         int FourCutoff=ThreeCutoff+NumberOfCardType4;
  672.         int FiveCutoff=FourCutoff+NumberOfCardType5;
  673.         int SixCutoff=FiveCutoff+NumberOfCardType6;
  674.         int SevenCutoff=SixCutoff+NumberOfSpells;
  675.  
  676.         if (RandomIntegerBetweenOneAndDeckSize<=OneCutoff) {CardType=1; this.NumberOfLands--;}
  677.         if (RandomIntegerBetweenOneAndDeckSize>OneCutoff && RandomIntegerBetweenOneAndDeckSize<=TwoCutoff) {CardType=2; this.NumberOfCardType2--;}
  678.         if (RandomIntegerBetweenOneAndDeckSize>TwoCutoff && RandomIntegerBetweenOneAndDeckSize<=ThreeCutoff) {CardType=3; this.NumberOfCardType3--;}
  679.         if (RandomIntegerBetweenOneAndDeckSize>ThreeCutoff && RandomIntegerBetweenOneAndDeckSize<=FourCutoff) {CardType=4; this.NumberOfCardType4--;}
  680.         if (RandomIntegerBetweenOneAndDeckSize>FourCutoff && RandomIntegerBetweenOneAndDeckSize<=FiveCutoff) {CardType=5; this.NumberOfCardType5--;}
  681.         if (RandomIntegerBetweenOneAndDeckSize>FiveCutoff && RandomIntegerBetweenOneAndDeckSize<=SixCutoff) {CardType=6; this.NumberOfCardType6--;}
  682.         if (RandomIntegerBetweenOneAndDeckSize>SixCutoff && RandomIntegerBetweenOneAndDeckSize<=SevenCutoff) {CardType=7; this.NumberOfSpells--;}
  683.         return CardType;
  684.     }
  685.    
  686. }//end of Deck
RAW Paste Data