Advertisement
frankkarsten

Should we play one fewer land under the new mull rule?

Sep 2nd, 2015
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.58 KB | None | 0 0
  1. package newmullruleonefewerland;
  2.  
  3. import java.util.Arrays.*;
  4. import java.util.Random;
  5.  
  6. public class NewMullRuleOneFewerLand {
  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.        
  16.         for (int OneDrops=13; OneDrops<=17; OneDrops++){
  17.             for (int TwoDrops=9; TwoDrops<=13; TwoDrops++){
  18.                 for (int ThreeDrops=0; ThreeDrops<=2; ThreeDrops++){
  19.                     for (int Bolts=12; Bolts<=16; Bolts++){
  20.                        
  21.                     int NumberLands=60-OneDrops-TwoDrops-ThreeDrops-Bolts;    
  22.                     deck.SetDeck(OneDrops,TwoDrops,ThreeDrops,Bolts,NumberLands);
  23.  
  24.                     if (Math.abs(OneDrops-15)+Math.abs(TwoDrops-11)+Math.abs(ThreeDrops-0)+Math.abs(Bolts-14)+Math.abs(NumberLands-20)<=4){
  25.                         //analyze if deck is at most 2 cards different from original optimal deck
  26.                         boolean[][][][][][] ScryToBottom=GiveOptimalScryStrategy(deck);
  27.                         boolean[][][][][][] KeepOpeningHand=GiveOptimalMulliganStrategy(deck,ScryToBottom,NewMullRuleActive);
  28.                         KillTurn=AverageKillTurnForRandomHand(deck,7,KeepOpeningHand,ScryToBottom,NewMullRuleActive,false,20000000);
  29.                         System.out.print("Kill turn for new mull rule:"+KillTurn+". ");
  30.                         deck.PrintDeckBrief();
  31.                         System.out.println();
  32.                     }
  33.  
  34.         }}}} //end of all the for-loops
  35.        
  36.     }//end of main
  37.  
  38.     public static boolean[][][][][][] GiveOptimalScryStrategy(Deck deck) {
  39.         boolean[][][][][][] ScryToBottom = new boolean[8][8][8][8][8][8];
  40.         OpeningHand openinghand=new OpeningHand();
  41.         int OriginalNr1Cost=deck.NumberOf1Cost;
  42.         int OriginalNr2Cost=deck.NumberOf2Cost;
  43.         int OriginalNr3Cost=deck.NumberOf3Cost;
  44.         int OriginalNrBolts=deck.NumberOfBolts;
  45.         int OriginalNrLands=deck.NumberOfLands;
  46.         boolean NewMullRuleActive = true;
  47.         for (int StartingCards=1; StartingCards<=7; StartingCards++){
  48.             System.out.print(".");
  49.             for (int OneDropCount=0; OneDropCount<=OriginalNr1Cost && OneDropCount<=StartingCards; OneDropCount++){
  50.                 for (int TwoDropCount=0; TwoDropCount<=OriginalNr2Cost && TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  51.                     for  (int ThreeDropCount=0; ThreeDropCount<=OriginalNr3Cost && ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  52.                         for (int BoltCount=0; BoltCount<=OriginalNrBolts && BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  53.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  54.                             if (LandCount<=OriginalNrLands){
  55.                                 for (int CardType=1; CardType<=5; CardType++){
  56.                                     boolean DoWeCheckThis=false;
  57.                                     if (CardType==1 && OneDropCount+1<=OriginalNr1Cost) {DoWeCheckThis=true;}
  58.                                     if (CardType==2 && TwoDropCount+1<=OriginalNr2Cost) {DoWeCheckThis=true;}
  59.                                     if (CardType==3 && ThreeDropCount+1<=OriginalNr3Cost) {DoWeCheckThis=true;}
  60.                                     if (CardType==4 && BoltCount+1<=OriginalNrBolts) {DoWeCheckThis=true;}
  61.                                     if (CardType==5 && LandCount+1<=OriginalNrLands) {DoWeCheckThis=true;}
  62.                                     if (DoWeCheckThis) {
  63.                                         openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  64.                                         deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  65.                                         ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=true;
  66.                                         double AvgKillTurnWithBottom=AverageKillTurnForSpecificHand(deck,openinghand, ScryToBottom, CardType, NewMullRuleActive);
  67.                                         //Checked how well scrying to botttom does
  68.                                         openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  69.                                         deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  70.                                         ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=false;
  71.                                         double AvgKillTurnWithTop=AverageKillTurnForSpecificHand(deck,openinghand, ScryToBottom, CardType, NewMullRuleActive);
  72.                                         //Checked how well scrying to top does
  73.                                         if (AvgKillTurnWithTop>AvgKillTurnWithBottom) {ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=true;}
  74.                                         if (AvgKillTurnWithTop<=AvgKillTurnWithBottom) {ScryToBottom[OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount][CardType]=false;}
  75.                                     }
  76.                                 }
  77.                             }
  78.                         }
  79.                     }
  80.                 }
  81.             }
  82.         }
  83.         return ScryToBottom;
  84.     }
  85.  
  86.     public static boolean[][][][][][] GiveOptimalMulliganStrategy(Deck deck, boolean[][][][][][] ScryToBottom, boolean NewMullRuleActive) {
  87.         boolean[][][][][][] KeepOpeningHand = new boolean[8][8][8][8][8][8];
  88.         OpeningHand openinghand=new OpeningHand();
  89.         int OriginalNr1Cost=deck.NumberOf1Cost;
  90.         int OriginalNr2Cost=deck.NumberOf2Cost;
  91.         int OriginalNr3Cost=deck.NumberOf3Cost;
  92.         int OriginalNrBolts=deck.NumberOfBolts;
  93.         int OriginalNrLands=deck.NumberOfLands;
  94.         double CutOffTurn = AverageKillTurnForRandomHand(deck,1,KeepOpeningHand,ScryToBottom,NewMullRuleActive,false,200000); //Switch to 1000000!!!!!!!!!!!!!!!!!!!!!!
  95.         for (int StartingCards=2; StartingCards<=7; StartingCards++){
  96.             System.out.print(".");
  97.             for (int OneDropCount=0; OneDropCount<=OriginalNr1Cost && OneDropCount<=StartingCards; OneDropCount++){
  98.                 for (int TwoDropCount=0; TwoDropCount<=OriginalNr2Cost && TwoDropCount+OneDropCount<=StartingCards; TwoDropCount++){
  99.                     for  (int ThreeDropCount=0; ThreeDropCount<=OriginalNr3Cost && ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; ThreeDropCount++){
  100.                         for (int BoltCount=0; BoltCount<=OriginalNrBolts && BoltCount+ThreeDropCount+TwoDropCount+OneDropCount<=StartingCards; BoltCount++){
  101.                             int LandCount=StartingCards-OneDropCount-TwoDropCount-ThreeDropCount-BoltCount;
  102.                             if (LandCount<=OriginalNrLands){
  103.                                 openinghand.SetHand(OneDropCount, TwoDropCount, ThreeDropCount, BoltCount, LandCount);
  104.                                 deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  105.                                 double AvgKillTurn=AverageKillTurnForSpecificHand(deck,openinghand, ScryToBottom,0,NewMullRuleActive);
  106.                                 if (AvgKillTurn<=CutOffTurn) { KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=true;}
  107.                                 if (AvgKillTurn>CutOffTurn) { KeepOpeningHand[StartingCards][OneDropCount][TwoDropCount][ThreeDropCount][BoltCount][LandCount]=false;}
  108.                                 }
  109.                             }
  110.                         }
  111.                     }
  112.                 }
  113.             deck.SetDeck(OriginalNr1Cost,OriginalNr2Cost,OriginalNr3Cost,OriginalNrBolts,OriginalNrLands);
  114.             if (StartingCards<7) {CutOffTurn=AverageKillTurnForRandomHand(deck,StartingCards,KeepOpeningHand, ScryToBottom,NewMullRuleActive,false,1000000);}
  115.         }
  116.         return KeepOpeningHand;
  117.     }
  118.    
  119.     public static double AverageKillTurnForSpecificHand(Deck deck, OpeningHand openinghand, boolean[][][][][][] ScryToBottom, int CardOnTop, boolean NewMullRuleActive){
  120.         int NumberOfIterations=10000;
  121.         Deck remainingdeck=new Deck();
  122.         double AverageKillTurn=0;
  123.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  124.             remainingdeck.SetDeck(deck.NumberOf1Cost-openinghand.NumberOf1Cost,deck.NumberOf2Cost-openinghand.NumberOf2Cost,deck.NumberOf3Cost-openinghand.NumberOf3Cost,deck.NumberOfBolts-openinghand.NumberOfBolts,deck.NumberOfLands-openinghand.NumberOfLands);
  125.             AverageKillTurn=AverageKillTurn+TurnKill(remainingdeck,openinghand,ScryToBottom,CardOnTop,NewMullRuleActive,false);
  126.         }
  127.         return (AverageKillTurn/(NumberOfIterations+0.0));
  128.     }//end of AverageKillTurnForSpecificHand
  129.  
  130.    
  131.     public static double AverageKillTurnForRandomHand(Deck deck, int StartingCards, boolean[][][][][][] KeepOpeningHand, boolean[][][][][][] ScryToBottom, boolean NewMullRuleActive, boolean NonInteractiveCheck, int NumberOfIterations){
  132.         Deck remainingdeck=new Deck();
  133.         double AverageKillTurn=0;
  134.         for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
  135.             OpeningHand openinghand=GiveOpeningHandAfterMulls(deck, StartingCards, KeepOpeningHand);
  136.             remainingdeck.SetDeck(deck.NumberOf1Cost-openinghand.NumberOf1Cost,deck.NumberOf2Cost-openinghand.NumberOf2Cost,deck.NumberOf3Cost-openinghand.NumberOf3Cost,deck.NumberOfBolts-openinghand.NumberOfBolts,deck.NumberOfLands-openinghand.NumberOfLands);
  137.             AverageKillTurn=AverageKillTurn+TurnKill(remainingdeck,openinghand,ScryToBottom,0,NewMullRuleActive,NonInteractiveCheck);
  138.         }
  139.         return AverageKillTurn/(NumberOfIterations+0.0);
  140.     }//end of AverageKillTurnForRandomHand
  141.    
  142.     static OpeningHand GiveOpeningHandAfterMulls (Deck deck, int StartingCards, boolean[][][][][][] KeepOpeningHand) {
  143.        
  144.         Deck remainingdeck=new Deck();
  145.         OpeningHand openinghand=new OpeningHand();
  146.         int TypeOfCardDrawn;
  147.         boolean KeepHand=false;
  148.        
  149.         for (int OpeningHandSize=7; OpeningHandSize>=1; OpeningHandSize--){
  150.             if (KeepHand==false && StartingCards>=OpeningHandSize){
  151.                 openinghand.ResetHand();
  152.                 remainingdeck.SetDeck(deck.NumberOf1Cost,deck.NumberOf2Cost,deck.NumberOf3Cost,deck.NumberOfBolts,deck.NumberOfLands);
  153.                 for (int CardsDrawn=0; CardsDrawn<OpeningHandSize; CardsDrawn++){
  154.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  155.                     if (TypeOfCardDrawn==1) {openinghand.NumberOf1Cost++;}
  156.                     if (TypeOfCardDrawn==2) {openinghand.NumberOf2Cost++;}
  157.                     if (TypeOfCardDrawn==3) {openinghand.NumberOf3Cost++;}
  158.                     if (TypeOfCardDrawn==4) {openinghand.NumberOfBolts++;}
  159.                     if (TypeOfCardDrawn==5) {openinghand.NumberOfLands++;}
  160.                 }
  161.                 KeepHand=true;
  162.                 if (OpeningHandSize>1) {
  163.                     if (KeepOpeningHand[OpeningHandSize][openinghand.NumberOf1Cost][openinghand.NumberOf2Cost][openinghand.NumberOf3Cost][openinghand.NumberOfBolts][openinghand.NumberOfLands]==false) {KeepHand=false;}
  164.                 }
  165.             }
  166.         }
  167.        
  168.         return openinghand;
  169.     }//end of GiveOpeningHandAfterMulls
  170.    
  171.    
  172.     static int TurnKill(Deck remainingdeck, OpeningHand openinghand, boolean[][][][][][] ScryToBottom, int CardOnTop, boolean NewMullRuleActive, boolean NonInteractiveCheck) {
  173.        
  174.         int OneCostPower=2;
  175.         int TwoCostPower=4;
  176.         int ThreeCostPower=6;
  177.         int BoltDamage=3;
  178.        
  179.         int Turn=0;
  180.         int OppLife=20;
  181.         int ManaLeft;
  182.         int TypeOfCardDrawn;
  183.    
  184.         int OneDropsInPlay=0;
  185.         int TwoDropsInPlay=0;
  186.         int ThreeDropsInPlay=0;
  187.         int LandsInPlay=0;
  188.        
  189.         int OneDropsInHand=openinghand.NumberOf1Cost;
  190.         int TwoDropsInHand=openinghand.NumberOf2Cost;
  191.         int ThreeDropsInHand=openinghand.NumberOf3Cost;
  192.         int BoltsInHand=openinghand.NumberOfBolts;
  193.         int LandsInHand=openinghand.NumberOfLands;
  194.        
  195.         boolean CardOnTopFixed=false;
  196.         int TypeOfCardOnTop=0;
  197.        
  198.         if (openinghand.NumberOf1Cost+openinghand.NumberOf2Cost+openinghand.NumberOf3Cost+openinghand.NumberOfBolts+openinghand.NumberOfLands<7 && NewMullRuleActive) {
  199.             if (CardOnTop==0){
  200.                 TypeOfCardOnTop=remainingdeck.DrawCard();
  201.             }
  202.             if (CardOnTop>0){
  203.                 TypeOfCardOnTop=CardOnTop;
  204.                 if (CardOnTop==1){remainingdeck.NumberOf1Cost--;}
  205.                 if (CardOnTop==2){remainingdeck.NumberOf2Cost--;}
  206.                 if (CardOnTop==3){remainingdeck.NumberOf3Cost--;}
  207.                 if (CardOnTop==4){remainingdeck.NumberOfBolts--;}
  208.                 if (CardOnTop==5){remainingdeck.NumberOfLands--;}
  209.             }
  210.             if (ScryToBottom[OneDropsInHand][TwoDropsInHand][ThreeDropsInHand][BoltsInHand][LandsInHand][TypeOfCardOnTop]==true) {
  211.                 CardOnTopFixed=false;
  212.                 //The drawn card is set aside, we don't do anything with it, which can be interpreted as pushing it to the bottom
  213.             }
  214.             if (ScryToBottom[OneDropsInHand][TwoDropsInHand][ThreeDropsInHand][BoltsInHand][LandsInHand][TypeOfCardOnTop]==false) {
  215.                 CardOnTopFixed=true;
  216.                 //The drawn card is set aside to be drawn next turn instead of a random draw
  217.             }
  218.         }
  219.         do {
  220.            
  221.             Turn++;
  222.            
  223.             if (Turn==1) {
  224.                
  225.                 if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  226.                 ManaLeft=LandsInPlay;
  227.                 if (OneDropsInHand>=1 && ManaLeft==1) {OneDropsInPlay++; ManaLeft--; OneDropsInHand--;}
  228.                 if (BoltsInHand>=1 && ManaLeft==1) {OppLife=OppLife-BoltDamage; ManaLeft--; BoltsInHand--;}
  229.                
  230.             } //end of the first turn
  231.            
  232.             if (Turn>1) {
  233.  
  234.                 if (Turn==2 && CardOnTopFixed){
  235.                     TypeOfCardDrawn=TypeOfCardOnTop;
  236.                 }
  237.                 else {
  238.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  239.                 }
  240.                 if (TypeOfCardDrawn==1) {OneDropsInHand++;}
  241.                 if (TypeOfCardDrawn==2) {TwoDropsInHand++;}
  242.                 if (TypeOfCardDrawn==3) {ThreeDropsInHand++;}
  243.                 if (TypeOfCardDrawn==4) {BoltsInHand++;}
  244.                 if (TypeOfCardDrawn==5) {LandsInHand++;}
  245.  
  246.                 if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  247.                 ManaLeft=LandsInPlay;
  248.                 OppLife=OppLife-OneCostPower*OneDropsInPlay;
  249.                 OppLife=OppLife-TwoCostPower*TwoDropsInPlay;
  250.                 OppLife=OppLife-ThreeCostPower*ThreeDropsInPlay;
  251.                
  252.                 if (ManaLeft==1) {
  253.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  254.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  255.                     if (OneDropsInHand>=1 && ManaLeft==1) {OneDropsInPlay++; ManaLeft--; OneDropsInHand--;}
  256.                     if (BoltsInHand>=1 && ManaLeft==1) {OppLife=OppLife-BoltDamage; ManaLeft--; BoltsInHand--;}
  257.                 }
  258.                
  259.                 if (ManaLeft==2) {
  260.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  261.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  262.                     if (TwoDropsInHand>=1 && ManaLeft==2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  263.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  264.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  265.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  266.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  267.                 }
  268.  
  269.                 if (ManaLeft==3) {
  270.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  271.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  272.                     if (ThreeDropsInHand>=1 && ManaLeft==3) {ThreeDropsInPlay++; ManaLeft=ManaLeft-3; ThreeDropsInHand--;}
  273.                     if (TwoDropsInHand>=1 && ManaLeft>=2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  274.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  275.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  276.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  277.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  278.                 }
  279.                
  280.                 if (ManaLeft==4) {
  281.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  282.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  283.                     int CastableTwoDrops=Math.min(TwoDropsInHand, ManaLeft/2);
  284.                     if (CastableTwoDrops==2) {TwoDropsInPlay=TwoDropsInPlay+2; ManaLeft=ManaLeft-4; TwoDropsInHand=TwoDropsInHand-2;}
  285.                     if (ThreeDropsInHand>=1 && ManaLeft>=3) {ThreeDropsInPlay++; ManaLeft=ManaLeft-3; ThreeDropsInHand--;}
  286.                     if (TwoDropsInHand>=1 && ManaLeft>=2) {TwoDropsInPlay++; ManaLeft=ManaLeft-2; TwoDropsInHand--;}
  287.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  288.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  289.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  290.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  291.                 }
  292.                        
  293.                 if (ManaLeft>=5) {
  294.                     int CastableBolts=Math.min(BoltsInHand, ManaLeft);
  295.                     if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  296.                     int CastableThreeDrops=Math.min(ThreeDropsInHand, ManaLeft/3);
  297.                     if (CastableThreeDrops>=1) {ThreeDropsInPlay=ThreeDropsInPlay+CastableThreeDrops; ManaLeft=ManaLeft-3*CastableThreeDrops; ThreeDropsInHand=ThreeDropsInHand-CastableThreeDrops;}
  298.                     int CastableTwoDrops=Math.min(TwoDropsInHand, ManaLeft/2);
  299.                     if (CastableTwoDrops>=1) {TwoDropsInPlay=TwoDropsInPlay+CastableTwoDrops; ManaLeft=ManaLeft-2*CastableTwoDrops; TwoDropsInHand=TwoDropsInHand-CastableTwoDrops;}
  300.                     int CastableOneDrops=Math.min(OneDropsInHand, ManaLeft);
  301.                     if (CastableOneDrops>=1) {OneDropsInPlay=OneDropsInPlay+CastableOneDrops; ManaLeft=ManaLeft-CastableOneDrops; OneDropsInHand=OneDropsInHand-CastableOneDrops;}
  302.                     CastableBolts=Math.min(BoltsInHand, ManaLeft);
  303.                     if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  304.                 }
  305.                
  306.                
  307.                
  308.             } //end of a turn in which we drew a card and attacked
  309.  
  310.          
  311.         } while (OppLife>0 &&Turn<=50);
  312.         int Outcome=Turn;
  313.  
  314.         return Outcome;
  315.     }//end of TurnKill
  316.    
  317. /*
  318.     static int TurnKill(Deck remainingdeck, OpeningHand openinghand, boolean[][][][][][] ScryToBottom, int CardOnTop, boolean NewMullRuleActive, boolean NonInteractiveCheck) {
  319.        
  320.         int Turn=0;
  321.         int ManaLeft;
  322.         int TypeOfCardDrawn;
  323.    
  324.         boolean WeHaventWonYet=true;
  325.         boolean LandPlayed=false;
  326.         boolean PestermiteInPlay=false;
  327.         int LandsInPlay=0;
  328.        
  329.         int PestersInHand=openinghand.NumberOf1Cost;
  330.         int TwinsInHand=openinghand.NumberOf2Cost;
  331.         int LandsInHand=openinghand.NumberOfLands;
  332.        
  333.         boolean CardOnTopFixed=false;
  334.         int TypeOfCardOnTop=0;
  335.        
  336.         if (openinghand.NumberOf1Cost+openinghand.NumberOf2Cost+openinghand.NumberOf3Cost+openinghand.NumberOfBolts+openinghand.NumberOfLands<7 && NewMullRuleActive) {
  337.             if (CardOnTop==0){
  338.                 TypeOfCardOnTop=remainingdeck.DrawCard();
  339.             }
  340.             if (CardOnTop>0){
  341.                 TypeOfCardOnTop=CardOnTop;
  342.                 if (CardOnTop==1){remainingdeck.NumberOf1Cost--;}
  343.                 if (CardOnTop==2){remainingdeck.NumberOf2Cost--;}
  344.                 if (CardOnTop==3){remainingdeck.NumberOf3Cost--;}
  345.                 if (CardOnTop==4){remainingdeck.NumberOfBolts--;}
  346.                 if (CardOnTop==5){remainingdeck.NumberOfLands--;}
  347.             }
  348.             if (ScryToBottom[PestersInHand][TwinsInHand][0][0][LandsInHand][TypeOfCardOnTop]==true) {
  349.                 CardOnTopFixed=false;
  350.                 //The drawn card is set aside, we don't do anything with it, which can be interpreted as pushing it to the bottom
  351.             }
  352.             if (ScryToBottom[PestersInHand][TwinsInHand][0][0][LandsInHand][TypeOfCardOnTop]==false) {
  353.                 CardOnTopFixed=true;
  354.                 //The drawn card is set aside to be drawn next turn instead of a random draw
  355.             }
  356.         }
  357.         int Outcome=0;
  358.         do {
  359.            
  360.             Turn++;
  361.            
  362.             if (Turn>1){
  363.                
  364.                 if (Turn==2 && CardOnTopFixed){
  365.                     TypeOfCardDrawn=TypeOfCardOnTop;
  366.                 }
  367.                 else {
  368.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  369.                 }
  370.                 if (TypeOfCardDrawn==1) {PestersInHand++;}
  371.                 if (TypeOfCardDrawn==2) {TwinsInHand++;}
  372.                 if (TypeOfCardDrawn==5) {LandsInHand++;}
  373.            
  374.             }
  375.            
  376.             LandPlayed=false;
  377.             if (LandsInHand>=1) {LandsInPlay++; LandsInHand--; LandPlayed=true;}
  378.             ManaLeft=LandsInPlay;
  379.             //System.out.println("Situation: ManaLeft="+ManaLeft+", LandsInPlay="+LandsInPlay+", PestermiteInPlay="+PestermiteInPlay+", HaventWonYet="+WeHaventWonYet+", Peeks in hand="+PeeksInHand+", Pesters in hand="+PestersInHand+", TwinsInHand="+TwinsInHand+", LandsInHand="+LandsInHand+". NOW START TURN "+Turn);
  380.  
  381.             if (PestermiteInPlay && TwinsInHand>=1 && ManaLeft>=4) {WeHaventWonYet=false; TwinsInHand--;}
  382.             if (!PestermiteInPlay && PestersInHand>=1 && ManaLeft>=3) {PestermiteInPlay=true; PestersInHand--;}
  383.                      
  384.         } while (WeHaventWonYet);
  385.        
  386.         Outcome=Turn;
  387.        
  388.         return Outcome;
  389.     }//end of TurnKill
  390.     */
  391.    
  392. }//end of OptimalAggroGoldfishDeck
  393.  
  394. class OpeningHand {
  395.     int NumberOf1Cost;
  396.     int NumberOf2Cost;
  397.     int NumberOf3Cost;
  398.     int NumberOfBolts;
  399.     int NumberOfLands;
  400.  
  401.     void ResetHand(){
  402.         NumberOf1Cost=0;
  403.         NumberOf2Cost=0;
  404.         NumberOf3Cost=0;
  405.         NumberOfBolts=0;
  406.         NumberOfLands=0;
  407.     }
  408.            
  409.     void SetHand (int Nr1Cost, int Nr2Cost, int Nr3Cost, int NrBolts, int NrLands) {
  410.         NumberOf1Cost=Nr1Cost;
  411.         NumberOf2Cost=Nr2Cost;
  412.         NumberOf3Cost=Nr3Cost;
  413.         NumberOfBolts=NrBolts;
  414.         NumberOfLands=NrLands;
  415.     }
  416.  
  417. }//end of OpeningHand
  418.  
  419. class Deck {
  420.     int NumberOf1Cost;
  421.     int NumberOf2Cost;
  422.     int NumberOf3Cost;
  423.     int NumberOfBolts;
  424.     int NumberOfLands;
  425.  
  426.     void PrintDeckBrief () {
  427.         if(NumberOf1Cost<10) {System.out.print("0");}
  428.         System.out.print(NumberOf1Cost+" ");
  429.         if(NumberOf2Cost<10) {System.out.print("0");}
  430.         System.out.print(NumberOf2Cost+" ");
  431.         if(NumberOf3Cost<10) {System.out.print("0");}
  432.         System.out.print(NumberOf3Cost+" ");
  433.         if(NumberOfBolts<10) {System.out.print("0");}
  434.         System.out.print(NumberOfBolts+" ");
  435.         if(NumberOfLands<10) {System.out.print("0");}
  436.         System.out.print(NumberOfLands);
  437.         System.out.print(" ");
  438.     }
  439.  
  440.     void SetDeck (int Nr1Cost, int Nr2Cost, int Nr3Cost, int NrBolts, int NrLands) {
  441.         NumberOf1Cost=Nr1Cost;
  442.         NumberOf2Cost=Nr2Cost;
  443.         NumberOf3Cost=Nr3Cost;
  444.         NumberOfBolts=NrBolts;
  445.         NumberOfLands=NrLands;
  446.     }
  447.    
  448.     int NrOfCards(){
  449.         return NumberOf1Cost+NumberOf2Cost+NumberOf3Cost+NumberOfBolts+NumberOfLands;
  450.     }
  451.    
  452.     int DrawCard (){
  453.             Random generator = new Random();
  454.             int RandomIntegerBetweenOneAndDeckSize=generator.nextInt( this.NrOfCards() )+1;
  455.             int CardType=0;
  456.             int OneCostCutoff=NumberOf1Cost;
  457.             int TwoCostCutoff=OneCostCutoff+NumberOf2Cost;
  458.             int ThreeCostCutoff=TwoCostCutoff+NumberOf3Cost;
  459.             int BoltCutoff=ThreeCostCutoff+NumberOfBolts;
  460.             int LandCutoff=BoltCutoff+NumberOfLands;
  461.            
  462.             if (RandomIntegerBetweenOneAndDeckSize<=OneCostCutoff) {CardType=1; this.NumberOf1Cost--;}
  463.             if (RandomIntegerBetweenOneAndDeckSize>OneCostCutoff && RandomIntegerBetweenOneAndDeckSize<=TwoCostCutoff) {CardType=2; this.NumberOf2Cost--;}
  464.             if (RandomIntegerBetweenOneAndDeckSize>TwoCostCutoff && RandomIntegerBetweenOneAndDeckSize<=ThreeCostCutoff) {CardType=3; this.NumberOf3Cost--;}
  465.             if (RandomIntegerBetweenOneAndDeckSize>ThreeCostCutoff && RandomIntegerBetweenOneAndDeckSize<=BoltCutoff) {CardType=4; this.NumberOfBolts--;}
  466.             if (RandomIntegerBetweenOneAndDeckSize>BoltCutoff && RandomIntegerBetweenOneAndDeckSize<=LandCutoff) {CardType=5; this.NumberOfLands--;}
  467.             return CardType;
  468.     }
  469.    
  470. }//end of Deck
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement