frankkarsten

MTG Optimal Deck for Goblin Guide Format

Sep 14th, 2013
434
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package goblinguidegoldfish;
  2.  
  3. import java.util.Arrays.*;
  4. import java.util.Random;
  5.  
  6. public class GoblinGuideGoldfish {
  7.  
  8.     public static void main(String[] args) {
  9.        
  10.         Deck deck=new Deck();
  11.         boolean[][][][][][] KeepOpeningHand = new boolean[8][8][8][8][8][8];
  12.         boolean TakeTimeToFindOptimalMulliganStrategy = false;
  13.         if (TakeTimeToFindOptimalMulliganStrategy==false) {KeepOpeningHand=GiveLooseMulliganStrategy();}
  14.         int NumberOfSimulationsPerDeck=1000;
  15.         double FastestTurn=50;
  16.         double KillTurn;
  17.         int OptimalOneDrops=0;
  18.         int OptimalTwoDrops=0;
  19.         int OptimalThreeDrops=0;
  20.         int OptimalBolts=0;
  21.         int OptimalLands=0;
  22.  
  23.         for (int OneDropCount=0; OneDropCount<=50; OneDropCount++){
  24.             for (int TwoDropCount=0; TwoDropCount<=20; TwoDropCount++){
  25.                 for (int ThreeDropCount=0; ThreeDropCount<=10; ThreeDropCount++){
  26.                     for (int BoltCount=0; BoltCount<=30; BoltCount++){
  27.                         int LandCount=60-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  28.                         if (LandCount>=10 && LandCount<=25) {
  29.                             deck.SetDeck(OneDropCount,TwoDropCount,ThreeDropCount,BoltCount,LandCount);
  30.                             deck.PrintDeckBrief();
  31.                             if (TakeTimeToFindOptimalMulliganStrategy==true) {KeepOpeningHand=GiveOptimalMulliganStrategy(deck);}
  32.                             KillTurn=AverageKillTurnForRandomHand(deck,7,KeepOpeningHand,NumberOfSimulationsPerDeck);
  33.                             System.out.println(" "+KillTurn);
  34.                             if (KillTurn<FastestTurn){
  35.                                 FastestTurn=KillTurn;
  36.                                 OptimalOneDrops=OneDropCount;
  37.                                 OptimalTwoDrops=TwoDropCount;
  38.                                 OptimalThreeDrops=ThreeDropCount;
  39.                                 OptimalBolts=BoltCount;
  40.                                 OptimalLands=LandCount;
  41.                             }
  42.                         }
  43.                     }
  44.                 }
  45.             }
  46.         }
  47.        
  48.         System.out.println("----------------");
  49.         System.out.print("The optimal deck was:");
  50.         deck.SetDeck(OptimalOneDrops,OptimalTwoDrops,OptimalThreeDrops,OptimalBolts,OptimalLands);
  51.         deck.PrintDeckBrief();
  52.         System.out.println();
  53.         System.out.println("----------------");
  54.        
  55.         TakeTimeToFindOptimalMulliganStrategy=true;
  56.         NumberOfSimulationsPerDeck=100000;
  57.         FastestTurn=50;
  58.         int SuperOptimalOneDrops=0;
  59.         int SuperOptimalTwoDrops=0;
  60.         int SuperOptimalThreeDrops=0;
  61.         int SuperOptimalBolts=0;
  62.         int SuperOptimalLands=0;
  63.        
  64.         for (int OneDropCount=Math.max(0,OptimalOneDrops-3); OneDropCount<=Math.min(60,OptimalOneDrops+3); OneDropCount++){
  65.             for (int TwoDropCount=Math.max(0,OptimalTwoDrops-3); TwoDropCount<=Math.min(60,OptimalTwoDrops+3); TwoDropCount++){
  66.                 for (int ThreeDropCount=Math.max(0,OptimalThreeDrops-3); ThreeDropCount<=Math.min(60,OptimalThreeDrops+3); ThreeDropCount++){
  67.                     for (int BoltCount=Math.max(0,OptimalBolts-3); BoltCount<=Math.min(60,OptimalBolts+3); BoltCount++){
  68.                         int LandCount=60-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  69.                         if (LandCount>=Math.max(0,OptimalLands-3) && LandCount<=Math.min(60,OptimalLands+3)) {
  70.                             deck.SetDeck(OneDropCount,TwoDropCount,ThreeDropCount,BoltCount,LandCount);
  71.                             deck.PrintDeckBrief();
  72.                             if (TakeTimeToFindOptimalMulliganStrategy==true) {KeepOpeningHand=GiveOptimalMulliganStrategy(deck);}
  73.                             KillTurn=AverageKillTurnForRandomHand(deck,7,KeepOpeningHand,NumberOfSimulationsPerDeck);
  74.                             System.out.println(" "+KillTurn);
  75.                             if (KillTurn<FastestTurn){
  76.                                 FastestTurn=KillTurn;
  77.                                 SuperOptimalOneDrops=OneDropCount;
  78.                                 SuperOptimalTwoDrops=TwoDropCount;
  79.                                 SuperOptimalThreeDrops=ThreeDropCount;
  80.                                 SuperOptimalBolts=BoltCount;
  81.                                 SuperOptimalLands=LandCount;
  82.                             }
  83.                         }
  84.                     }
  85.                 }
  86.             }
  87.         }
  88.        
  89.         System.out.println("----------------");
  90.         System.out.print("The optimal deck was:");
  91.         deck.SetDeck(SuperOptimalOneDrops,SuperOptimalTwoDrops,SuperOptimalThreeDrops,SuperOptimalBolts,SuperOptimalLands);
  92.         deck.PrintDeckBrief();
  93.         System.out.println();
  94.         System.out.println("----------------");
  95.  
  96.        
  97.     }//end of main
  98.  
  99.     public static boolean[][][][][][] GiveOptimalMulliganStrategy(Deck deck) {
  100.         boolean[][][][][][] KeepOpeningHand = new boolean[8][8][8][8][8][8];
  101.         OpeningHand openinghand=new OpeningHand();
  102.         int NumberOfSimulationsPerOpeningHandSize=10000;
  103.         int OriginalNr1Cost=deck.NumberOf1Cost;
  104.         int OriginalNr2Cost=deck.NumberOf2Cost;
  105.         int OriginalNr3Cost=deck.NumberOf3Cost;
  106.         int OriginalNrBolts=deck.NumberOfBolts;
  107.         int OriginalNrLands=deck.NumberOfLands;
  108.         double CutOffTurn = AverageKillTurnForRandomHand(deck,1,KeepOpeningHand,NumberOfSimulationsPerOpeningHandSize);
  109.         for (int StartingCards=2; StartingCards<=7; StartingCards++){
  110.             System.out.print(".");
  111.             for (int OneDropCount=0; OneDropCount<=OriginalNr1Cost && OneDropCount<=StartingCards; OneDropCount++){
  112.                 for (int TwoDropCount=0; TwoDropCount<=OriginalNr2Cost && TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  113.                     for  (int ThreeDropCount=0; ThreeDropCount<=OriginalNr3Cost && ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  114.                         for (int BoltCount=0; BoltCount<=OriginalNrBolts && BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  115.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  116.                             if (LandCount<=OriginalNrLands){
  117.                                 openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  118.                                 deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  119.                                 double AvgKillTurn=AverageKillTurnForSpecificHand(deck,openinghand);
  120.                                 if (AvgKillTurn<=CutOffTurn) { KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=true;}
  121.                                 if (AvgKillTurn>CutOffTurn) { KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=false;}
  122.                                 }
  123.                             }
  124.                         }
  125.                     }
  126.                 }
  127.             deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  128.             if (StartingCards<7) {CutOffTurn=AverageKillTurnForRandomHand(deck,StartingCards,KeepOpeningHand,NumberOfSimulationsPerOpeningHandSize);}
  129.         }
  130.         return KeepOpeningHand;
  131.     }
  132.  
  133.     public static boolean[][][][][][] GiveLooseMulliganStrategy() {
  134.         boolean[][][][][][] KeepOpeningHand = new boolean[8][8][8][8][8][8];
  135.         for (int StartingCards=2; StartingCards<=7; StartingCards++){
  136.             for (int OneDropCount=0; OneDropCount<=StartingCards; OneDropCount++){
  137.                 for (int TwoDropCount=0; TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  138.                     for  (int ThreeDropCount=0; ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  139.                         for (int BoltCount=0; BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  140.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  141.                             KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=false;
  142.                             if (LandCount>=1 && LandCount<=4) {KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=true;}
  143.                         }
  144.                     }
  145.                 }
  146.             }
  147.         }
  148.         return KeepOpeningHand;
  149.     }
  150.    
  151.     public static double AverageKillTurnForSpecificHand(Deck deck, OpeningHand openinghand){
  152.         int NumberOfIterations=2000;
  153.         Deck remainingdeck=new Deck();
  154.         double AverageKillTurn=0;
  155.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  156.             remainingdeck.SetDeck(deck.NumberOf1Cost-openinghand.NumberOf1Cost,deck.NumberOf2Cost-openinghand.NumberOf2Cost,deck.NumberOf3Cost-openinghand.NumberOf3Cost,deck.NumberOfBolts-openinghand.NumberOfBolts,deck.NumberOfLands-openinghand.NumberOfLands);
  157.             AverageKillTurn=AverageKillTurn+TurnKill(remainingdeck,openinghand);
  158.         }
  159.         return (AverageKillTurn/(NumberOfIterations+0.0));
  160.     }//end of AverageKillTurnForSpecificHand
  161.  
  162.     public static double AverageKillTurnForRandomHand(Deck deck, int StartingCards, boolean[][][][][][] KeepOpeningHand, int NumberOfIterations){
  163.         Deck remainingdeck=new Deck();
  164.         double AverageKillTurn=0;
  165.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  166.             OpeningHand openinghand=GiveOpeningHandAfterMulls(deck, StartingCards, KeepOpeningHand);
  167.             remainingdeck.SetDeck(deck.NumberOf1Cost-openinghand.NumberOf1Cost,deck.NumberOf2Cost-openinghand.NumberOf2Cost,deck.NumberOf3Cost-openinghand.NumberOf3Cost,deck.NumberOfBolts-openinghand.NumberOfBolts,deck.NumberOfLands-openinghand.NumberOfLands);
  168.             AverageKillTurn=AverageKillTurn+TurnKill(remainingdeck,openinghand);
  169.             if ( IterationCounter % 200000 == 0) {System.out.print(".");}
  170.         }
  171.         return AverageKillTurn/(NumberOfIterations+0.0);
  172.     }//end of AverageKillTurnForRandomHand
  173.    
  174.     static OpeningHand GiveOpeningHandAfterMulls (Deck deck, int StartingCards, boolean[][][][][][] KeepOpeningHand) {
  175.        
  176.         Deck remainingdeck=new Deck();
  177.         OpeningHand openinghand=new OpeningHand();
  178.         int TypeOfCardDrawn;
  179.         boolean KeepHand=false;
  180.        
  181.         for (int OpeningHandSize=7; OpeningHandSize>=1; OpeningHandSize--){
  182.             if (KeepHand==false && StartingCards>=OpeningHandSize){
  183.                 openinghand.ResetHand();
  184.                 remainingdeck.SetDeck(deck.NumberOf1Cost,deck.NumberOf2Cost,deck.NumberOf3Cost,deck.NumberOfBolts,deck.NumberOfLands);
  185.                 for (int CardsDrawn=0; CardsDrawn<OpeningHandSize; CardsDrawn++){
  186.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  187.                     if (TypeOfCardDrawn==1) {openinghand.NumberOf1Cost++;}
  188.                     if (TypeOfCardDrawn==2) {openinghand.NumberOf2Cost++;}
  189.                     if (TypeOfCardDrawn==3) {openinghand.NumberOf3Cost++;}
  190.                     if (TypeOfCardDrawn==4) {openinghand.NumberOfBolts++;}
  191.                     if (TypeOfCardDrawn==5) {openinghand.NumberOfLands++;}
  192.                 }
  193.                 KeepHand=true;
  194.                 if (OpeningHandSize>1) {
  195.                     if (KeepOpeningHand[OpeningHandSize][openinghand.NumberOf1Cost][openinghand.NumberOf2Cost][openinghand.NumberOf3Cost][openinghand.NumberOfBolts][openinghand.NumberOfLands]==false) {KeepHand=false;}
  196.                 }
  197.             }
  198.         }
  199.        
  200.         return openinghand;
  201.     }//end of GiveOpeningHandAfterMulls
  202.    
  203.     static int TurnKill(Deck remainingdeck, OpeningHand openinghand) {
  204.        
  205.         int OneCostPower=2;
  206.         int TwoCostPower=4;
  207.         int ThreeCostPower=6;
  208.         int BoltDamage=3;
  209.        
  210.         int Turn=0;
  211.         int OppLife=20;
  212.         int ManaLeft;
  213.         int TypeOfCardDrawn;
  214.    
  215.         int OneDropsInPlay=0;
  216.         int TwoDropsInPlay=0;
  217.         int ThreeDropsInPlay=0;
  218.         int LandsInPlay=0;
  219.        
  220.         int OneDropsInHand=openinghand.NumberOf1Cost;
  221.         int TwoDropsInHand=openinghand.NumberOf2Cost;
  222.         int ThreeDropsInHand=openinghand.NumberOf3Cost;
  223.         int BoltsInHand=openinghand.NumberOfBolts;
  224.         int LandsInHand=openinghand.NumberOfLands;
  225.        
  226.         do {
  227.            
  228.             Turn++;
  229.            
  230.             if (Turn==1) {
  231.                
  232.                 if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  233.                 ManaLeft=LandsInPlay;
  234.                 if (OneDropsInHand>=1 && ManaLeft==1) {OneDropsInPlay++; ManaLeft--; OppLife=OppLife-OneCostPower; OneDropsInHand--;}
  235.                 if (BoltsInHand>=1 && ManaLeft==1) {OppLife=OppLife-BoltDamage; ManaLeft--; BoltsInHand--;}
  236.                
  237.             } //end of the first turn
  238.            
  239.             if (Turn>1) {
  240.  
  241.                 TypeOfCardDrawn=remainingdeck.DrawCard();
  242.                 if (TypeOfCardDrawn==1) {OneDropsInHand++;}
  243.                 if (TypeOfCardDrawn==2) {TwoDropsInHand++;}
  244.                 if (TypeOfCardDrawn==3) {ThreeDropsInHand++;}
  245.                 if (TypeOfCardDrawn==4) {BoltsInHand++;}
  246.                 if (TypeOfCardDrawn==5) {LandsInHand++;}
  247.  
  248.                 if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  249.                 ManaLeft=LandsInPlay;
  250.                 OppLife=OppLife-OneCostPower*OneDropsInPlay;
  251.                 OppLife=OppLife-TwoCostPower*TwoDropsInPlay;
  252.                 OppLife=OppLife-ThreeCostPower*ThreeDropsInPlay;
  253.                
  254.                 if (ManaLeft==1) {
  255.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  256.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  257.                     if (OneDropsInHand>=1 && ManaLeft==1) {OneDropsInPlay++; OppLife=OppLife-OneCostPower; ManaLeft--; OneDropsInHand--;}
  258.                     if (BoltsInHand>=1 && ManaLeft==1) {OppLife=OppLife-BoltDamage; ManaLeft--; BoltsInHand--;}
  259.                 }
  260.                
  261.                 if (ManaLeft==2) {
  262.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  263.                     int CastableGuidesAfterBolt=Math.min(OneDropsInHand,ManaLeft-CastableBolts);
  264.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  265.                     if (OppLife<=CastableBolts*BoltDamage+CastableGuidesAfterBolt*OneCostPower) {OppLife=OppLife-CastableBolts*BoltDamage-CastableGuidesAfterBolt*OneCostPower; ManaLeft=ManaLeft-CastableBolts-CastableGuidesAfterBolt; BoltsInHand=BoltsInHand-CastableBolts; OneDropsInHand=CastableGuidesAfterBolt;}
  266.                     if (TwoDropsInHand>=1 && ManaLeft==2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  267.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  268.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops; OppLife=OppLife-CastableOneDrops*OneCostPower;}
  269.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  270.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  271.                 }
  272.  
  273.                 if (ManaLeft==3) {
  274.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  275.                     int CastableGuidesAfterBolt=Math.min(OneDropsInHand,ManaLeft-CastableBolts);
  276.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  277.                     if (OppLife<=CastableBolts*BoltDamage+CastableGuidesAfterBolt*OneCostPower) {OppLife=OppLife-CastableBolts*BoltDamage-CastableGuidesAfterBolt*OneCostPower; ManaLeft=ManaLeft-CastableBolts-CastableGuidesAfterBolt; BoltsInHand=BoltsInHand-CastableBolts; OneDropsInHand=CastableGuidesAfterBolt;}
  278.                     if (ThreeDropsInHand>=1 && ManaLeft==3) {ThreeDropsInPlay++; ManaLeft=ManaLeft-3; ThreeDropsInHand--;}
  279.                     if (TwoDropsInHand>=1 && ManaLeft>=2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  280.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  281.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops; OppLife=OppLife-CastableOneDrops*OneCostPower;}
  282.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  283.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  284.                 }
  285.                
  286.                 if (ManaLeft==4) {
  287.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  288.                     int CastableGuidesAfterBolt=Math.min(OneDropsInHand,ManaLeft-CastableBolts);
  289.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  290.                     if (OppLife<=CastableBolts*BoltDamage+CastableGuidesAfterBolt*OneCostPower) {OppLife=OppLife-CastableBolts*BoltDamage-CastableGuidesAfterBolt*OneCostPower; ManaLeft=ManaLeft-CastableBolts-CastableGuidesAfterBolt; BoltsInHand=BoltsInHand-CastableBolts; OneDropsInHand=CastableGuidesAfterBolt;}
  291.                     int CastableTwoDrops=Math.min(TwoDropsInHand, ManaLeft/2);
  292.                     if (CastableTwoDrops==2) {TwoDropsInPlay=TwoDropsInPlay+2; ManaLeft=ManaLeft-4; TwoDropsInHand=TwoDropsInHand-2;}
  293.                     if (ThreeDropsInHand>=1 && ManaLeft>=3) {ThreeDropsInPlay++; ManaLeft=ManaLeft-3; ThreeDropsInHand--;}
  294.                     if (TwoDropsInHand>=1 && ManaLeft>=2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  295.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  296.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops; OppLife=OppLife-CastableOneDrops*OneCostPower;}
  297.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  298.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  299.                 }
  300.                        
  301.                 if (ManaLeft>=5) {
  302.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  303.                     int CastableGuidesAfterBolt=Math.min(OneDropsInHand,ManaLeft-CastableBolts);
  304.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  305.                     if (OppLife<=CastableBolts*BoltDamage+CastableGuidesAfterBolt*OneCostPower) {OppLife=OppLife-CastableBolts*BoltDamage-CastableGuidesAfterBolt*OneCostPower; ManaLeft=ManaLeft-CastableBolts-CastableGuidesAfterBolt; BoltsInHand=BoltsInHand-CastableBolts; OneDropsInHand=CastableGuidesAfterBolt;}
  306.                     int CastableThreeDrops=Math.min(ThreeDropsInHand, ManaLeft/3);
  307.                     if (CastableThreeDrops>=1) {ThreeDropsInPlay=ThreeDropsInPlay+CastableThreeDrops; ManaLeft=ManaLeft-3*CastableThreeDrops; ThreeDropsInHand=ThreeDropsInHand-CastableThreeDrops;}
  308.                     int CastableTwoDrops=Math.min(TwoDropsInHand, ManaLeft/2);
  309.                     if (CastableTwoDrops>=1) {TwoDropsInPlay=TwoDropsInPlay+CastableTwoDrops; ManaLeft=ManaLeft-2*CastableTwoDrops; TwoDropsInHand=TwoDropsInHand-CastableTwoDrops;}
  310.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  311.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops; OppLife=OppLife-CastableOneDrops*OneCostPower;}
  312.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  313.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  314.                 }
  315.                
  316.             } //end of a turn in which we drew a card and attacked
  317.  
  318.         } while (OppLife>0 &&Turn<=50);
  319.        
  320.         return Turn;
  321.     }//end of TurnKill
  322.  
  323. }//end of OptimalAggroGoldfishDeck
  324.  
  325. class OpeningHand {
  326.     int NumberOf1Cost;
  327.     int NumberOf2Cost;
  328.     int NumberOf3Cost;
  329.     int NumberOfBolts;
  330.     int NumberOfLands;
  331.  
  332.     void ResetHand(){
  333.         NumberOf1Cost=0;
  334.         NumberOf2Cost=0;
  335.         NumberOf3Cost=0;
  336.         NumberOfBolts=0;
  337.         NumberOfLands=0;
  338.     }
  339.            
  340.     void SetHand (int Nr1Cost, int Nr2Cost, int Nr3Cost, int NrBolts, int NrLands) {
  341.         NumberOf1Cost=Nr1Cost;
  342.         NumberOf2Cost=Nr2Cost;
  343.         NumberOf3Cost=Nr3Cost;
  344.         NumberOfBolts=NrBolts;
  345.         NumberOfLands=NrLands;
  346.     }
  347.  
  348. }//end of OpeningHand
  349.  
  350. class Deck {
  351.     int NumberOf1Cost;
  352.     int NumberOf2Cost;
  353.     int NumberOf3Cost;
  354.     int NumberOfBolts;
  355.     int NumberOfLands;
  356.  
  357.     void PrintDeckBrief () {
  358.         if(NumberOf1Cost<10) {System.out.print("0");}
  359.         System.out.print(NumberOf1Cost+" ");
  360.         if(NumberOf2Cost<10) {System.out.print("0");}
  361.         System.out.print(NumberOf2Cost+" ");
  362.         if(NumberOf3Cost<10) {System.out.print("0");}
  363.         System.out.print(NumberOf3Cost+" ");
  364.         if(NumberOfBolts<10) {System.out.print("0");}
  365.         System.out.print(NumberOfBolts+" ");
  366.         if(NumberOfLands<10) {System.out.print("0");}
  367.         System.out.print(NumberOfLands);
  368.         System.out.print(" ");
  369.     }
  370.  
  371.     void SetDeck (int Nr1Cost, int Nr2Cost, int Nr3Cost, int NrBolts, int NrLands) {
  372.         NumberOf1Cost=Nr1Cost;
  373.         NumberOf2Cost=Nr2Cost;
  374.         NumberOf3Cost=Nr3Cost;
  375.         NumberOfBolts=NrBolts;
  376.         NumberOfLands=NrLands;
  377.     }
  378.    
  379.     int NrOfCards(){
  380.         return NumberOf1Cost+NumberOf2Cost+NumberOf3Cost+NumberOfBolts+NumberOfLands;
  381.     }
  382.    
  383.     int DrawCard (){
  384.             Random generator = new Random();
  385.             int RandomIntegerBetweenOneAndDeckSize=generator.nextInt( this.NrOfCards() )+1;
  386.             int CardType=0;
  387.             int OneCostCutoff=NumberOf1Cost;
  388.             int TwoCostCutoff=OneCostCutoff+NumberOf2Cost;
  389.             int ThreeCostCutoff=TwoCostCutoff+NumberOf3Cost;
  390.             int BoltCutoff=ThreeCostCutoff+NumberOfBolts;
  391.             int LandCutoff=BoltCutoff+NumberOfLands;
  392.            
  393.             if (RandomIntegerBetweenOneAndDeckSize<=OneCostCutoff) {CardType=1; this.NumberOf1Cost--;}
  394.             if (RandomIntegerBetweenOneAndDeckSize>OneCostCutoff && RandomIntegerBetweenOneAndDeckSize<=TwoCostCutoff) {CardType=2; this.NumberOf2Cost--;}
  395.             if (RandomIntegerBetweenOneAndDeckSize>TwoCostCutoff && RandomIntegerBetweenOneAndDeckSize<=ThreeCostCutoff) {CardType=3; this.NumberOf3Cost--;}
  396.             if (RandomIntegerBetweenOneAndDeckSize>ThreeCostCutoff && RandomIntegerBetweenOneAndDeckSize<=BoltCutoff) {CardType=4; this.NumberOfBolts--;}
  397.             if (RandomIntegerBetweenOneAndDeckSize>BoltCutoff && RandomIntegerBetweenOneAndDeckSize<=LandCutoff) {CardType=5; this.NumberOfLands--;}
  398.             return CardType;
  399.     }
  400.    
  401. }//end of Deck
RAW Paste Data