frankkarsten

MTG Optimal Deck for Lightning Bolt format

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