SHARE
TWEET

Evaluating new mulligan rule with goldfish decks

frankkarsten Jul 6th, 2015 611 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package newmullrule;
  2.  
  3. import java.util.Arrays.*;
  4. import java.util.Random;
  5.  
  6. public class NewMullRule {
  7.  
  8.     public static void main(String[] args) {
  9.        
  10.         Deck deck=new Deck();
  11.         double KillTurn;
  12.         boolean NewMullRuleActive;
  13.         System.out.println("---New mull rule active---");
  14.         NewMullRuleActive = true;
  15.         deck.SetDeck(13,11,3,14,19);
  16.         //deck.SetDeck(16,11,0,13,20);
  17.         //deck.SetDeck(0,0,0,44,16);
  18.         boolean[][][][][][] ScryToBottom=GiveOptimalScryStrategy(deck);
  19.         boolean[][][][][][] KeepOpeningHand=GiveOptimalMulliganStrategy(deck,ScryToBottom,NewMullRuleActive);
  20.         KillTurn=AverageKillTurnForRandomHand(deck,7,KeepOpeningHand,ScryToBottom,NewMullRuleActive);
  21.         System.out.println("Kill turn for new mull rule:"+KillTurn);
  22.         KillTurn=AverageKillTurnForRandomHand(deck,6,KeepOpeningHand,ScryToBottom,NewMullRuleActive);
  23.         System.out.println("Kill turn for new mull rule after choosing to mull original 7:"+KillTurn);
  24.         KillTurn=AverageKillTurnForRandomHand(deck,5,KeepOpeningHand,ScryToBottom,NewMullRuleActive);
  25.         System.out.println("Kill turn for new mull rule after second mull decision (may still end up lower than 5):"+KillTurn);
  26.         System.out.println("---Old mull rule active---");
  27.         NewMullRuleActive = false;
  28.         deck.SetDeck(13,11,3,14,19);
  29.         boolean[][][][][][] KeepOpeningHandOld=GiveOptimalMulliganStrategy(deck,ScryToBottom,NewMullRuleActive);
  30.         KillTurn=AverageKillTurnForRandomHand(deck,7,KeepOpeningHandOld,ScryToBottom,NewMullRuleActive);
  31.         System.out.println("Kill turn for old mull rule:"+KillTurn);
  32.         KillTurn=AverageKillTurnForRandomHand(deck,6,KeepOpeningHandOld,ScryToBottom,NewMullRuleActive);
  33.         System.out.println("Kill turn for old mull rule after choosing to mull original 7:"+KillTurn);
  34.         KillTurn=AverageKillTurnForRandomHand(deck,5,KeepOpeningHandOld,ScryToBottom,NewMullRuleActive);
  35.         System.out.println("Kill turn for old mull rule after second mull decision (may still end up lower than 5):"+KillTurn);
  36.         for (int StartingCards=5; StartingCards<=7; StartingCards++){
  37.             for (int OneDropCount=0; OneDropCount<=deck.NumberOf1Cost && OneDropCount<=StartingCards; OneDropCount++){
  38.                 for (int TwoDropCount=0; TwoDropCount<=deck.NumberOf2Cost && TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  39.                     for  (int ThreeDropCount=0; ThreeDropCount<=deck.NumberOf3Cost && ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  40.                         for (int BoltCount=0; BoltCount<=deck.NumberOfBolts && BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  41.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  42.                                 if (KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]!=KeepOpeningHandOld[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]) {
  43.                                 System.out.print("With an opening hand of"+StartingCards+"cards,"+ OneDropCount+" one-drops, "+TwoDropCount+" two-drops, "+ThreeDropCount+" three-drops, "+BoltCount+" bolts, and"+LandCount+" lands, what happens?");
  44.                                 System.out.print("==>Keep hand? Old says "+KeepOpeningHandOld[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]);
  45.                                 System.out.println(". New says "+KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]);
  46.                             }
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.         }
  52.     }//end of main
  53.  
  54.     public static boolean[][][][][][] GiveOptimalScryStrategy(Deck deck) {
  55.         boolean[][][][][][] ScryToBottom = new boolean[8][8][8][8][8][8];
  56.         OpeningHand openinghand=new OpeningHand();
  57.         int OriginalNr1Cost=deck.NumberOf1Cost;
  58.         int OriginalNr2Cost=deck.NumberOf2Cost;
  59.         int OriginalNr3Cost=deck.NumberOf3Cost;
  60.         int OriginalNrBolts=deck.NumberOfBolts;
  61.         int OriginalNrLands=deck.NumberOfLands;
  62.         boolean NewMullRuleActive = true;
  63.         for (int StartingCards=1; StartingCards<=7; StartingCards++){
  64.             System.out.print(".");
  65.             for (int OneDropCount=0; OneDropCount<=OriginalNr1Cost && OneDropCount<=StartingCards; OneDropCount++){
  66.                 for (int TwoDropCount=0; TwoDropCount<=OriginalNr2Cost && TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  67.                     for  (int ThreeDropCount=0; ThreeDropCount<=OriginalNr3Cost && ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  68.                         for (int BoltCount=0; BoltCount<=OriginalNrBolts && BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  69.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  70.                             if (LandCount<=OriginalNrLands){
  71.                                 for (int CardType=1; CardType<=5; CardType++){
  72.                                     //I didn't build in a check to see if this card type is still in the deck because that's not an issue for the deck I'm currently checking.
  73.                                     openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  74.                                     deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  75.                                     ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=true;
  76.                                     double AvgKillTurnWithBottom=AverageKillTurnForSpecificHand(deck,openinghand, ScryToBottom, CardType, NewMullRuleActive);
  77.                                     //Checked how well scrying to botttom does
  78.                                     openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  79.                                     deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  80.                                     ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=false;
  81.                                     double AvgKillTurnWithTop=AverageKillTurnForSpecificHand(deck,openinghand, ScryToBottom, CardType, NewMullRuleActive);
  82.                                     //Checked how well scrying to top does
  83.                                     if (AvgKillTurnWithTop>AvgKillTurnWithBottom) {ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=true;}
  84.                                     if (AvgKillTurnWithTop<=AvgKillTurnWithBottom) {ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=false;}
  85.                                     }
  86.                                 }
  87.                             }
  88.                         }
  89.                     }
  90.                 }
  91.         }
  92.         return ScryToBottom;
  93.     }
  94.            
  95.     public static double AverageKillTurnForSpecificHand(Deck deck, OpeningHand openinghand, boolean[][][][][][] ScryToBottom, int CardOnTop, boolean NewMullRuleActive){
  96.         int NumberOfIterations=50000;
  97.         Deck remainingdeck=new Deck();
  98.         double AverageKillTurn=0;
  99.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  100.             remainingdeck.SetDeck(deck.NumberOf1Cost-openinghand.NumberOf1Cost,deck.NumberOf2Cost-openinghand.NumberOf2Cost,deck.NumberOf3Cost-openinghand.NumberOf3Cost,deck.NumberOfBolts-openinghand.NumberOfBolts,deck.NumberOfLands-openinghand.NumberOfLands);
  101.             AverageKillTurn=AverageKillTurn+TurnKill(remainingdeck,openinghand,ScryToBottom,CardOnTop,NewMullRuleActive);
  102.         }
  103.         return (AverageKillTurn/(NumberOfIterations+0.0));
  104.     }//end of AverageKillTurnForSpecificHand
  105.  
  106.    
  107.     public static boolean[][][][][][] GiveOptimalMulliganStrategy(Deck deck, boolean[][][][][][] ScryToBottom, boolean NewMullRuleActive) {
  108.         boolean[][][][][][] KeepOpeningHand = new boolean[8][8][8][8][8][8];
  109.         OpeningHand openinghand=new OpeningHand();
  110.         int OriginalNr1Cost=deck.NumberOf1Cost;
  111.         int OriginalNr2Cost=deck.NumberOf2Cost;
  112.         int OriginalNr3Cost=deck.NumberOf3Cost;
  113.         int OriginalNrBolts=deck.NumberOfBolts;
  114.         int OriginalNrLands=deck.NumberOfLands;
  115.         double CutOffTurn = AverageKillTurnForRandomHand(deck,1,KeepOpeningHand,ScryToBottom,NewMullRuleActive);
  116.         for (int StartingCards=2; StartingCards<=7; StartingCards++){
  117.             System.out.print(".");
  118.             for (int OneDropCount=0; OneDropCount<=OriginalNr1Cost && OneDropCount<=StartingCards; OneDropCount++){
  119.                 for (int TwoDropCount=0; TwoDropCount<=OriginalNr2Cost && TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  120.                     for  (int ThreeDropCount=0; ThreeDropCount<=OriginalNr3Cost && ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  121.                         for (int BoltCount=0; BoltCount<=OriginalNrBolts && BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  122.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  123.                             if (LandCount<=OriginalNrLands){
  124.                                 openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  125.                                 deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  126.                                 double AvgKillTurn=AverageKillTurnForSpecificHand(deck,openinghand, ScryToBottom,0,NewMullRuleActive);
  127.                                 if (AvgKillTurn<=CutOffTurn) { KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=true;}
  128.                                 if (AvgKillTurn>CutOffTurn) { KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=false;}
  129.                                 }
  130.                             }
  131.                         }
  132.                     }
  133.                 }
  134.             deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  135.             if (StartingCards<7) {CutOffTurn=AverageKillTurnForRandomHand(deck,StartingCards,KeepOpeningHand, ScryToBottom,NewMullRuleActive);}
  136.         }
  137.         return KeepOpeningHand;
  138.     }
  139.  
  140.     public static double AverageKillTurnForRandomHand(Deck deck, int StartingCards, boolean[][][][][][] KeepOpeningHand, boolean[][][][][][] ScryToBottom, boolean NewMullRuleActive){
  141.         Deck remainingdeck=new Deck();
  142.         int NumberOfIterations=5000000;
  143.         double AverageKillTurn=0;
  144.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  145.             OpeningHand openinghand=GiveOpeningHandAfterMulls(deck, StartingCards, KeepOpeningHand);
  146.             remainingdeck.SetDeck(deck.NumberOf1Cost-openinghand.NumberOf1Cost,deck.NumberOf2Cost-openinghand.NumberOf2Cost,deck.NumberOf3Cost-openinghand.NumberOf3Cost,deck.NumberOfBolts-openinghand.NumberOfBolts,deck.NumberOfLands-openinghand.NumberOfLands);
  147.             AverageKillTurn=AverageKillTurn+TurnKill(remainingdeck,openinghand,ScryToBottom,0,NewMullRuleActive);
  148.         }
  149.         return AverageKillTurn/(NumberOfIterations+0.0);
  150.     }//end of AverageKillTurnForRandomHand
  151.    
  152.     static OpeningHand GiveOpeningHandAfterMulls (Deck deck, int StartingCards, boolean[][][][][][] KeepOpeningHand) {
  153.        
  154.         Deck remainingdeck=new Deck();
  155.         OpeningHand openinghand=new OpeningHand();
  156.         int TypeOfCardDrawn;
  157.         boolean KeepHand=false;
  158.        
  159.         for (int OpeningHandSize=7; OpeningHandSize>=1; OpeningHandSize--){
  160.             if (KeepHand==false && StartingCards>=OpeningHandSize){
  161.                 openinghand.ResetHand();
  162.                 remainingdeck.SetDeck(deck.NumberOf1Cost,deck.NumberOf2Cost,deck.NumberOf3Cost,deck.NumberOfBolts,deck.NumberOfLands);
  163.                 for (int CardsDrawn=0; CardsDrawn<OpeningHandSize; CardsDrawn++){
  164.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  165.                     if (TypeOfCardDrawn==1) {openinghand.NumberOf1Cost++;}
  166.                     if (TypeOfCardDrawn==2) {openinghand.NumberOf2Cost++;}
  167.                     if (TypeOfCardDrawn==3) {openinghand.NumberOf3Cost++;}
  168.                     if (TypeOfCardDrawn==4) {openinghand.NumberOfBolts++;}
  169.                     if (TypeOfCardDrawn==5) {openinghand.NumberOfLands++;}
  170.                 }
  171.                 KeepHand=true;
  172.                 if (OpeningHandSize>1) {
  173.                     if (KeepOpeningHand[OpeningHandSize][openinghand.NumberOf1Cost][openinghand.NumberOf2Cost][openinghand.NumberOf3Cost][openinghand.NumberOfBolts][openinghand.NumberOfLands]==false) {KeepHand=false;}
  174.                 }
  175.             }
  176.         }
  177.        
  178.         return openinghand;
  179.     }//end of GiveOpeningHandAfterMulls
  180.    
  181.     static int TurnKill(Deck remainingdeck, OpeningHand openinghand, boolean[][][][][][] ScryToBottom, int CardOnTop, boolean NewMullRuleActive) {
  182.        
  183.         int OneCostPower=1;
  184.         int TwoCostPower=2;
  185.         int ThreeCostPower=3;
  186.         int BoltDamage=2;
  187.        
  188.         int Turn=0;
  189.         int OppLife=20;
  190.         int ManaLeft;
  191.         int TypeOfCardDrawn;
  192.    
  193.         int OneDropsInPlay=0;
  194.         int TwoDropsInPlay=0;
  195.         int ThreeDropsInPlay=0;
  196.         int LandsInPlay=0;
  197.        
  198.         int OneDropsInHand=openinghand.NumberOf1Cost;
  199.         int TwoDropsInHand=openinghand.NumberOf2Cost;
  200.         int ThreeDropsInHand=openinghand.NumberOf3Cost;
  201.         int BoltsInHand=openinghand.NumberOfBolts;
  202.         int LandsInHand=openinghand.NumberOfLands;
  203.        
  204.         boolean CardOnTopFixed=false;
  205.         int TypeOfCardOnTop=0;
  206.        
  207.         if (openinghand.NumberOf1Cost+openinghand.NumberOf2Cost+openinghand.NumberOf3Cost+openinghand.NumberOfBolts+openinghand.NumberOfLands<7 && NewMullRuleActive) {
  208.             if (CardOnTop==0){
  209.                 TypeOfCardOnTop=remainingdeck.DrawCard();
  210.             }
  211.             if (CardOnTop>0){
  212.                 TypeOfCardOnTop=CardOnTop;
  213.                 if (CardOnTop==1){remainingdeck.NumberOf1Cost--;}
  214.                 if (CardOnTop==2){remainingdeck.NumberOf2Cost--;}
  215.                 if (CardOnTop==3){remainingdeck.NumberOf3Cost--;}
  216.                 if (CardOnTop==4){remainingdeck.NumberOfBolts--;}
  217.                 if (CardOnTop==5){remainingdeck.NumberOfLands--;}
  218.             }
  219.             if (ScryToBottom[OneDropsInHand][TwoDropsInHand][ThreeDropsInHand][BoltsInHand][LandsInHand][TypeOfCardOnTop]==true) {
  220.                 CardOnTopFixed=false;
  221.                 //The drawn card is set aside, we don't do anything with it, which can be interpreted as pushing it to the bottom
  222.             }
  223.             if (ScryToBottom[OneDropsInHand][TwoDropsInHand][ThreeDropsInHand][BoltsInHand][LandsInHand][TypeOfCardOnTop]==false) {
  224.                 CardOnTopFixed=true;
  225.                 //The drawn card is set aside to be drawn next turn instead of a random draw
  226.             }
  227.         }
  228.  
  229.         do {
  230.            
  231.             Turn++;
  232.            
  233.             if (Turn==1) {
  234.                
  235.                 if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  236.                 ManaLeft=LandsInPlay;
  237.                 if (OneDropsInHand>=1 && ManaLeft==1) {OneDropsInPlay++; ManaLeft--; OneDropsInHand--;}
  238.                 if (BoltsInHand>=1 && ManaLeft==1) {OppLife=OppLife-BoltDamage; ManaLeft--; BoltsInHand--;}
  239.                
  240.             } //end of the first turn
  241.            
  242.             if (Turn>1) {
  243.  
  244.                 if (Turn==2 && CardOnTopFixed){
  245.                     TypeOfCardDrawn=TypeOfCardOnTop;
  246.                 }
  247.                 else {
  248.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  249.                 }
  250.                 if (TypeOfCardDrawn==1) {OneDropsInHand++;}
  251.                 if (TypeOfCardDrawn==2) {TwoDropsInHand++;}
  252.                 if (TypeOfCardDrawn==3) {ThreeDropsInHand++;}
  253.                 if (TypeOfCardDrawn==4) {BoltsInHand++;}
  254.                 if (TypeOfCardDrawn==5) {LandsInHand++;}
  255.  
  256.                 if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  257.                 ManaLeft=LandsInPlay;
  258.                 OppLife=OppLife-OneCostPower*OneDropsInPlay;
  259.                 OppLife=OppLife-TwoCostPower*TwoDropsInPlay;
  260.                 OppLife=OppLife-ThreeCostPower*ThreeDropsInPlay;
  261.                
  262.                 if (ManaLeft==1) {
  263.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  264.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  265.                     if (OneDropsInHand>=1 && ManaLeft==1) {OneDropsInPlay++; ManaLeft--; OneDropsInHand--;}
  266.                     if (BoltsInHand>=1 && ManaLeft==1) {OppLife=OppLife-BoltDamage; ManaLeft--; BoltsInHand--;}
  267.                 }
  268.                
  269.                 if (ManaLeft==2) {
  270.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  271.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  272.                     if (TwoDropsInHand>=1 && ManaLeft==2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  273.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  274.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  275.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  276.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  277.                 }
  278.  
  279.                 if (ManaLeft==3) {
  280.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  281.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  282.                     if (ThreeDropsInHand>=1 && ManaLeft==3) {ThreeDropsInPlay++; ManaLeft=ManaLeft-3; ThreeDropsInHand--;}
  283.                     if (TwoDropsInHand>=1 && ManaLeft>=2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  284.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  285.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  286.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  287.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  288.                 }
  289.                
  290.                 if (ManaLeft==4) {
  291.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  292.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  293.                     int CastableTwoDrops=Math.min(TwoDropsInHand, ManaLeft/2);
  294.                     if (CastableTwoDrops==2) {TwoDropsInPlay=TwoDropsInPlay+2; ManaLeft=ManaLeft-4; TwoDropsInHand=TwoDropsInHand-2;}
  295.                     if (ThreeDropsInHand>=1 && ManaLeft>=3) {ThreeDropsInPlay++; ManaLeft=ManaLeft-3; ThreeDropsInHand--;}
  296.                     if (TwoDropsInHand>=1 && ManaLeft>=2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  297.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  298.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  299.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  300.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  301.                 }
  302.                        
  303.                 if (ManaLeft>=5) {
  304.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  305.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  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;}
  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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top