package manabase; /** * * @author Frank Karsten 2013, adapted by Brian Burley July 2017 */ import java.util.Arrays.*; import java.util.Random; public class Manabase { public static void main(String[] args) { Deck deck=new Deck(); int NrIterations=1000000; //number of test runs int NrGoodLandsNeeded=3; //number of lands considered a success int TurnAllowed=3; //turn number we want our sources by int NrCards=75; //deck size int NrLands=33; //number of total lands int CardType; //card type identifier int LandsInHand; //land count in hand int GoodLandsInHand; //land count success in hand boolean Mulligan; for (int NrGoodLands=19; NrGoodLands<=23; NrGoodLands++){ // double CountOK=0.0; double CountConditional=0.0; for (int i=1; i<=NrIterations; i++){ //NrIteration sample draws deck.SetDeck(NrLands, NrGoodLands, NrCards); //set parameters for our deck LandsInHand=0; //reset parameters GoodLandsInHand=0; //reset parameters for (int j=1; j<=7; j++){ CardType=deck.DrawCard(); //draw card if (CardType<3) {LandsInHand++;} //if card is a land increment land counter if (CardType==1) {GoodLandsInHand++;} //if card is appropriate land increment good land counter } Mulligan=false; //assume no mulligan if (LandsInHand<2) {Mulligan=true;} //mull 0 and 1 landers if (LandsInHand>5) {Mulligan=true;} //mull 6 and 7 landers //Mulligan if (Mulligan){ //we are guaranteed to draw exactly 2, 3, or 4 lands on an eternal mulligan with equal probability of each Random rnjesus = new Random(); int mulliganLandCount = rnjesus.nextInt(2)+2; deck.SetDeck(NrLands, NrGoodLands, NrCards); LandsInHand=0; GoodLandsInHand=0; for (int k=1;k<=mulliganLandCount;k++){ //draw our guranteed lands CardType = deck.DrawLand(); //draw land if (CardType<3) {LandsInHand++;} //minor success if (CardType==1) {GoodLandsInHand++;} //super success } for (int j=1; j<=(7-mulliganLandCount); j++){ //draw remainder of hand deck.DrawNonLand(); } Mulligan=false; } //Draw cards for the number of turns available for (int turn=1; turn<=TurnAllowed-1; turn++){ CardType=deck.DrawCard(); //draw card if (CardType<3) {LandsInHand++;} //if card is a land increment land counter if (CardType==1) {GoodLandsInHand++;} //if card is appropriate land increment good land counter } if (GoodLandsInHand>=NrGoodLandsNeeded) {CountOK++;} //success if (LandsInHand>=NrGoodLandsNeeded) {CountConditional++;} //conditional success } // end of NrIterations iterations System.out.println("With "+NrGoodLands+" good sources: Prob="+CountOK/CountConditional); } } } class Deck { int NumberOfLands; int NumberOfGoodLands; int NumberOfCards; void SetDeck (int NrLands, int NrGoodLands, int NrCards) { NumberOfLands=NrLands; NumberOfGoodLands=NrGoodLands; NumberOfCards=NrCards; } int DrawCard (){ Random generator = new Random(); int RandomIntegerBetweenOneAndDeckSize=generator.nextInt( this.NumberOfCards)+1; int CardType=0; int GoodLandCutoff=NumberOfGoodLands; //set cutoff to # of good lands remaining int LandCutoff=NumberOfLands; //set cutoff to # of lands total remaining if (RandomIntegerBetweenOneAndDeckSize<=GoodLandCutoff) {CardType=1; this.NumberOfGoodLands--; this.NumberOfLands--; this.NumberOfCards--;} //drawn a good land if (RandomIntegerBetweenOneAndDeckSize>GoodLandCutoff && RandomIntegerBetweenOneAndDeckSize<=LandCutoff) {CardType=2; this.NumberOfLands--; this.NumberOfCards--;} //drawn a non-good land if (RandomIntegerBetweenOneAndDeckSize>LandCutoff) {CardType=3; this.NumberOfCards--;} //drawn a non-land return CardType; } int DrawLand (){ Random generator = new Random(); int RandomIntegerBetweenOneAndLandSize = generator.nextInt(this.NumberOfLands)+1; //on mulligans in eternal we are guaranteed lands in our hand int CardType=0; int GoodLandCutoff=NumberOfGoodLands; //set cutoff to # of good lands remaining int LandCutoff=NumberOfLands; //set cutoff to # of lands total remaining if (RandomIntegerBetweenOneAndLandSize<=GoodLandCutoff) {CardType=1; this.NumberOfGoodLands--; this.NumberOfLands--; this.NumberOfCards--;} //drawn a good land if (RandomIntegerBetweenOneAndLandSize>GoodLandCutoff && RandomIntegerBetweenOneAndLandSize<=LandCutoff) {CardType=2; this.NumberOfLands--; this.NumberOfCards--;} //drawn a non-good land return CardType; } void DrawNonLand(){ NumberOfCards--; } } //end class Manabase