Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package griselbrand;
- import java.util.Random;
- public class Griselbrand {
- public static void main(String[] args) {
- Deck deck=new Deck();
- int NrSims=10000000;
- //CardType1=Nourishing Shoal
- //CardType2=Worldspine Wurm
- //CardType3=other
- double TotalDrawDeck=0;
- double TotalDrawTill21=0;
- int Outcome;
- for (int i=1; i<=NrSims; i++){
- deck.SetDeck(4,4,47,0,0,0);
- //Deck size is 55 because the first 5 cards were fixed to be Faithless Looting, Goryo's Vengeance, Griselbrand, Mountain, Swamp
- Outcome=Simulate(deck);
- if (Outcome==1){TotalDrawTill21++;}
- if (Outcome==2){TotalDrawTill21++; TotalDrawDeck++;}
- }
- System.out.println("P[able to draw till 21]="+TotalDrawTill21/NrSims);
- System.out.println("P[able to draw entire deck]="+TotalDrawDeck/NrSims);
- }//end of main
- static int Simulate(Deck remainingdeck) {
- int Outcome=42; //What other number could we use to initialize
- int TypeOfCardDrawn;
- boolean DrawPair=false;
- int NrShoalsFound=0;
- int NrWurmsFound=0;
- //Griselbrand activation 1 and 2, plus 6 additional non-combo cards from opening hand, draw steps, and Lootings. This means we have 20 cards to find the first life-gain pair.
- for (int i=1; i<=20; i++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {NrShoalsFound++;}
- if (TypeOfCardDrawn==2) {NrWurmsFound++;}
- }
- if (NrShoalsFound==0 || NrWurmsFound==0) {Outcome=0;}
- if (NrShoalsFound>0 && NrWurmsFound>0) {
- //Griselbrand activation 3 and 4.
- for (int i=1; i<=14; i++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {NrShoalsFound++;}
- if (TypeOfCardDrawn==2) {NrWurmsFound++;}
- }
- if (NrShoalsFound<=1 || NrWurmsFound<=1) {Outcome=1;}
- if (NrShoalsFound>1 && NrWurmsFound>1) {
- //Griselbrand activation 5.
- for (int i=1; i<=7; i++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {NrShoalsFound++;}
- if (TypeOfCardDrawn==2) {NrWurmsFound++;}
- }
- if (NrShoalsFound<=2 || NrWurmsFound<=2) {Outcome=1;}
- if (NrShoalsFound>2 && NrWurmsFound>2) {Outcome=2;}
- }
- }
- return Outcome;
- }
- static class Deck {
- int NrCardType1;
- int NrCardType2;
- int NrCardType3;
- int NrCardType4;
- int NrCardType5;
- int NrCardType6;
- void PrintDeckBrief () {
- if(NrCardType1<10) {System.out.print("0");}
- System.out.print(NrCardType1+" ");
- if(NrCardType2<10) {System.out.print("0");}
- System.out.print(NrCardType2+" ");
- if(NrCardType3<10) {System.out.print("0");}
- System.out.print(NrCardType3+" ");
- if(NrCardType4<10) {System.out.print("0");}
- System.out.print(NrCardType4+" ");
- if(NrCardType5<10) {System.out.print("0");}
- System.out.print(NrCardType5+" ");
- if(NrCardType6<10) {System.out.print("0");}
- System.out.print(NrCardType6);
- System.out.print(" ");
- }
- void SetDeck (int Nr1, int Nr2, int Nr3, int Nr4, int Nr5, int Nr6) {
- NrCardType1=Nr1;
- NrCardType2=Nr2;
- NrCardType3=Nr3;
- NrCardType4=Nr4;
- NrCardType5=Nr5;
- NrCardType6=Nr6;
- }
- int NrOfCards(){
- return NrCardType1+NrCardType2+NrCardType3+NrCardType4+NrCardType5+NrCardType6;
- }
- int DrawCard (){
- Random generator = new Random();
- int RandomIntegerBetweenOneAndDeckSize=generator.nextInt( this.NrOfCards() )+1;
- int CardType=0;
- int OneCutoff=NrCardType1;
- int TwoCutoff=OneCutoff+NrCardType2;
- int ThreeCutoff=TwoCutoff+NrCardType3;
- int FourCutoff=ThreeCutoff+NrCardType4;
- int FiveCutoff=FourCutoff+NrCardType5;
- int SixCutoff=FiveCutoff+NrCardType6;
- if (RandomIntegerBetweenOneAndDeckSize<=OneCutoff) {CardType=1; this.NrCardType1--;}
- if (RandomIntegerBetweenOneAndDeckSize>OneCutoff && RandomIntegerBetweenOneAndDeckSize<=TwoCutoff) {CardType=2; this.NrCardType2--;}
- if (RandomIntegerBetweenOneAndDeckSize>TwoCutoff && RandomIntegerBetweenOneAndDeckSize<=ThreeCutoff) {CardType=3; this.NrCardType3--;}
- if (RandomIntegerBetweenOneAndDeckSize>ThreeCutoff && RandomIntegerBetweenOneAndDeckSize<=FourCutoff) {CardType=4; this.NrCardType4--;}
- if (RandomIntegerBetweenOneAndDeckSize>FourCutoff && RandomIntegerBetweenOneAndDeckSize<=FiveCutoff) {CardType=5; this.NrCardType5--;}
- if (RandomIntegerBetweenOneAndDeckSize>FiveCutoff) {CardType=6; this.NrCardType6--;}
- return CardType;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement