Advertisement
AnacondaHL

New TurnKill Subroutine for Frank Karsten

Sep 30th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.04 KB | None | 0 0
  1.         static int TurnKill(Deck remainingdeck, OpeningHand openinghand) {
  2.            
  3.             int OneCostPower=2;
  4.             int TwoCostPower=3;
  5.             int ThreeCostPower=4;
  6.             int BoltDamage=2;
  7.            
  8.         int OneDropCMC = 1;
  9.         int TwoDropCMC = 2;
  10.         int ThreeDropCMC = 3;
  11.         int BoltCMC = 2;
  12.  
  13.             int Turn=0;
  14.             int OppLife=20;
  15.             int ManaLeft;
  16.             int TypeOfCardDrawn;
  17.        
  18.             int OneDropsInPlay=0;
  19.             int TwoDropsInPlay=0;
  20.             int ThreeDropsInPlay=0;
  21.             int LandsInPlay=0;
  22.            
  23.             int OneDropsInHand=openinghand.NumberOf1Cost;
  24.             int TwoDropsInHand=openinghand.NumberOf2Cost;
  25.             int ThreeDropsInHand=openinghand.NumberOf3Cost;
  26.             int BoltsInHand=openinghand.NumberOfBolts;
  27.             int LandsInHand=openinghand.NumberOfLands;
  28.            
  29.             do {
  30.  
  31.                 Turn++;
  32.  
  33.         //
  34.         //  Attempt at flexible Turn management!
  35.         //
  36.        
  37.         //  Initialize vars
  38.         int CastableBolts=0;
  39.  
  40.  
  41.         //  Untap, Upkeep, Draw card if Turn>1
  42.                 if (Turn > 1) {
  43.                     TypeOfCardDrawn=remainingdeck.DrawCard();
  44.                     if (TypeOfCardDrawn==1) {OneDropsInHand++;}
  45.                     if (TypeOfCardDrawn==2) {TwoDropsInHand++;}
  46.                     if (TypeOfCardDrawn==3) {ThreeDropsInHand++;}
  47.                     if (TypeOfCardDrawn==4) {BoltsInHand++;}
  48.                     if (TypeOfCardDrawn==5) {LandsInHand++;}
  49.         }      
  50.  
  51.         //  Main Phase, No matter what, play land              
  52.         if (LandsInHand>=1) {LandsInPlay++; LandsInHand--;}
  53.         ManaLeft=LandsInPlay;
  54.  
  55.         //  Combat Phase, adjust if doing Goblin Guide sims
  56.         if (Turn > 1) {
  57.                     OppLife=OppLife-OneCostPower*OneDropsInPlay;
  58.                     OppLife=OppLife-TwoCostPower*TwoDropsInPlay;
  59.                     OppLife=OppLife-ThreeCostPower*ThreeDropsInPlay;
  60.         }
  61.  
  62.         //  Second Main Phase, first go for the Bolt win
  63.         CastableBolts=Math.min(BoltsInHand, ManaLeft/BoltCMC);
  64.         if (OppLife<=CastableBolts*BoltDamage) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  65.  
  66.         //  Solve for max damage
  67.         int PossibleDamageNextTurn=0;
  68.         int ManaNeededForThisPlay=0;
  69.         int NewPowerOnField=0;
  70.         int NewOneDropsOnField=0;
  71.         int NewTwoDropsOnField=0;
  72.         int NewThreeDropsOnField=0;
  73.    
  74.                 for (int OneDropCount=0; OneDropCount<=OneDropsInHand; OneDropCount++){
  75.                     for (int TwoDropCount=0; TwoDropCount<=TwoDropsInHand; TwoDropCount++){
  76.                         for  (int ThreeDropCount=0; ThreeDropCount<=ThreeDropsInHand; ThreeDropCount++){
  77.                 PossibleDamageNextTurn = OneDropCount*OneCostPower + TwoDropCount*TwoCostPower + ThreeDropCount*ThreeCostPower;
  78.                 ManaNeededForThisPlay = OneDropCMC*OneDropCount + TwoDropCMC*TwoDropCount + ThreeDropCMC*ThreeDropCount;
  79.                 if (ManaNeededForThisPlay <= ManaLeft && PossibleDamageNextTurn > NewPowerOnField) {
  80.                 NewPowerOnField = PossibleDamageNextTurn;
  81.                 NewOneDropsOnField = OneDropCount;
  82.                 NewTwoDropsOnField = TwoDropCount;
  83.                 NewThreeDropsOnField = ThreeDropCount;
  84.                 }
  85.             }
  86.             }
  87.         }
  88.         OneDropsInPlay = OneDropsInPlay + NewOneDropsOnField;
  89.         OneDropsInHand = OneDropsInHand - NewOneDropsOnField;
  90.         ManaLeft = ManaLeft - OneDropCMC*NewOneDropsOnField;
  91.         TwoDropsInPlay = TwoDropsInPlay + NewTwoDropsOnField;
  92.         TwoDropsInHand = TwoDropsInHand - NewTwoDropsOnField;
  93.         ManaLeft = ManaLeft - TwoDropCMC*NewTwoDropsOnField;
  94.         ThreeDropsInPlay = ThreeDropsInPlay + NewThreeDropsOnField;
  95.         ThreeDropsInHand = ThreeDropsInHand - NewThreeDropsOnField;
  96.         ManaLeft = ManaLeft - ThreeDropCMC*NewThreeDropsOnField;
  97.  
  98.         //  Bolts to end the turn
  99.         CastableBolts=Math.min(BoltsInHand, ManaLeft/BoltCMC);
  100.         if (CastableBolts>=1) {OppLife=OppLife-CastableBolts*BoltDamage; ManaLeft=ManaLeft-CastableBolts; BoltsInHand=BoltsInHand-CastableBolts;}
  101.      
  102.             } while (OppLife>0 && Turn<=50);
  103.            
  104.             return Turn;
  105.         }//end of TurnKill
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement