Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hollowone;
- import java.util.Arrays.*;
- import java.util.Random;
- public class HollowOne {
- public static void main(String[] args) {
- Deck deck=new Deck();
- //CardType 1 is a Mountain
- //CardType 2 is a Burning Inquiry
- //CardType 3 is a Faithless Looting
- //CardType 4 is a Goblin Lore
- //CardType 5 is a Street Wraith
- //CardType 6 is a Hollow One
- //CardType 7 is another, irrelevant card
- deck.SetDeck(18,4,4,4,4,4,22);
- Deck remainingdeck=new Deck();
- double NumberOfGamesWith1HollowTurn1=0;
- double NumberOfGamesWith2HollowTurn1=0;
- double NumberOfGamesWith3HollowTurn1=0;
- double NumberOfGamesWith4HollowTurn1=0;
- double NumberOfGamesWith1HollowTurn2=0;
- double NumberOfGamesWith2HollowTurn2=0;
- double NumberOfGamesWith3HollowTurn2=0;
- double NumberOfGamesWith4HollowTurn2=0;
- double NumberOfGamesFailures=0;
- int NumberOfIterations=10000000;
- for (int IterationCounter=1; IterationCounter<=NumberOfIterations; IterationCounter++){
- OpeningHand openinghand=GiveOpeningHandAfterMulls(deck, 7);
- remainingdeck.SetDeck(deck.NumberOfLands-openinghand.NumberOfLands,deck.NumberOfCardType2-openinghand.NumberOfCardType2,deck.NumberOfCardType3-openinghand.NumberOfCardType3,deck.NumberOfCardType4-openinghand.NumberOfCardType4,deck.NumberOfCardType5-openinghand.NumberOfCardType5,deck.NumberOfCardType6-openinghand.NumberOfCardType6,deck.NumberOfSpells-openinghand.NumberOfSpells);
- boolean OnThePlay = false;
- if (IterationCounter % 2 ==0) {OnThePlay=true;}
- int Outcome=SimulateGame(remainingdeck,openinghand,OnThePlay);
- if (Outcome==0) {NumberOfGamesFailures++;}
- if (Outcome==1) {NumberOfGamesWith1HollowTurn1++;}
- if (Outcome==2) {NumberOfGamesWith2HollowTurn1++;}
- if (Outcome==3) {NumberOfGamesWith3HollowTurn1++;}
- if (Outcome==4) {NumberOfGamesWith4HollowTurn1++;}
- if (Outcome==11) {NumberOfGamesWith1HollowTurn2++;}
- if (Outcome==12) {NumberOfGamesWith2HollowTurn2++;}
- if (Outcome==13) {NumberOfGamesWith3HollowTurn2++;}
- if (Outcome==14) {NumberOfGamesWith4HollowTurn2++;}
- }
- System.out.println(Math.round((NumberOfGamesWith1HollowTurn1/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith2HollowTurn1/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith3HollowTurn1/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith4HollowTurn1/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith1HollowTurn2/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith2HollowTurn2/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith3HollowTurn2/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesWith4HollowTurn2/NumberOfIterations)*10000)/100.0);
- System.out.println(Math.round((NumberOfGamesFailures/NumberOfIterations)*10000)/100.0);
- }//end of main
- static OpeningHand GiveOpeningHandAfterMulls (Deck deck, int StartingCards) {
- Deck remainingdeck=new Deck();
- OpeningHand openinghand=new OpeningHand();
- int TypeOfCardDrawn;
- boolean KeepHand=false;
- for (int OpeningHandSize=7; OpeningHandSize>=1; OpeningHandSize--){
- if (KeepHand==false){
- openinghand.SetHand(0,0,0,0,0,0,0);
- remainingdeck.SetDeck(deck.NumberOfLands,deck.NumberOfCardType2,deck.NumberOfCardType3,deck.NumberOfCardType4,deck.NumberOfCardType5,deck.NumberOfCardType6,deck.NumberOfSpells);
- int NumberOfLands=0;
- int NumberOfKeyCards=0;
- for (int CardsDrawn=0; CardsDrawn<OpeningHandSize; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {openinghand.NumberOfLands++; NumberOfLands++;}
- if (TypeOfCardDrawn==2) {openinghand.NumberOfCardType2++; NumberOfKeyCards++;}
- if (TypeOfCardDrawn==3) {openinghand.NumberOfCardType3++; NumberOfKeyCards++;}
- if (TypeOfCardDrawn==4) {openinghand.NumberOfCardType4++; NumberOfKeyCards++;}
- if (TypeOfCardDrawn==5) {openinghand.NumberOfCardType5++; NumberOfKeyCards++;}
- if (TypeOfCardDrawn==6) {openinghand.NumberOfCardType6++; NumberOfKeyCards++;}
- if (TypeOfCardDrawn==7) {openinghand.NumberOfSpells++;}
- }
- KeepHand=true;
- if (OpeningHandSize>1) {
- // We mulligan a hand if it contains 0, 1, 6, or 7 lands
- if (NumberOfLands<=1 || NumberOfLands>=6) {KeepHand=false;}
- // We also mulligan a 6-card or 7-card hand if we have no key card (card-draw spell or cycler)
- if (OpeningHandSize>=5 && NumberOfKeyCards==0) {KeepHand=false;}
- }
- }
- }
- return openinghand;
- }//end of GiveOpeningHandAfterMulls
- static int SimulateGame(Deck remainingdeck, OpeningHand openinghand, boolean OnThePlay) {
- //Initializing
- int TypeOfCardDrawn=0;
- int Outcome=0;
- int MountainInPlay=0;
- boolean LandDrop;
- int NrCardsDiscardedThisTurn;
- int ManaRemaining;
- int HollowOnesPlayed;
- OpeningHand HandForRandomDiscard=new OpeningHand();
- int PossibleLands;
- int MountainInHand=openinghand.NumberOfLands;
- int BurningInquiryInHand=openinghand.NumberOfCardType2;
- int FaithlessLootingInHand=openinghand.NumberOfCardType3;
- int GoblinLoreInHand=openinghand.NumberOfCardType4;
- int StreetWraithInHand=openinghand.NumberOfCardType5;
- int HollowOneInHand=openinghand.NumberOfCardType6;
- int ExtraSpellsInHand=openinghand.NumberOfSpells;
- //Turn 1
- if (OnThePlay==false) {
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- NrCardsDiscardedThisTurn=0;
- LandDrop=false;
- ManaRemaining=0;
- HollowOnesPlayed=0;
- while (StreetWraithInHand>0){
- StreetWraithInHand--;
- NrCardsDiscardedThisTurn++;
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- if (NrCardsDiscardedThisTurn>=3) {
- HollowOnesPlayed=HollowOneInHand;
- HollowOneInHand=0;
- }
- if (MountainInHand>0) {MountainInHand--; MountainInPlay++; ManaRemaining++; LandDrop=true;}
- if (ManaRemaining>=1 && FaithlessLootingInHand>=1 && BurningInquiryInHand==0) {
- FaithlessLootingInHand--;
- ManaRemaining--;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+2;
- for (int CardsDrawn=1; CardsDrawn<=2; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- int CardsToDiscardToLooting=2;
- //Try to discard irrelevant cards if possible
- int SpellsThatCanBeDiscarded=Math.min(ExtraSpellsInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-SpellsThatCanBeDiscarded;
- ExtraSpellsInHand=ExtraSpellsInHand-SpellsThatCanBeDiscarded;
- int LandsOverSecondThatCanBeDiscarded=Math.min(Math.max(MountainInHand-1,0),CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-LandsOverSecondThatCanBeDiscarded;
- MountainInHand=MountainInHand-LandsOverSecondThatCanBeDiscarded;
- int GoblinLoresThatCanBeDiscarded=Math.min(GoblinLoreInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-GoblinLoresThatCanBeDiscarded;
- GoblinLoreInHand=GoblinLoreInHand-GoblinLoresThatCanBeDiscarded;
- int FaithlessLootingThatCanBeDiscarded=Math.min(FaithlessLootingInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-FaithlessLootingThatCanBeDiscarded;
- FaithlessLootingInHand=FaithlessLootingInHand-FaithlessLootingThatCanBeDiscarded;
- //It is extremely unlikely that we aren't done discarding to Faithless Looting by now, but let's catch all the corner cases
- int PossibleSecondLandToDiscard=Math.min(MountainInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-PossibleSecondLandToDiscard;
- MountainInHand=MountainInHand-PossibleSecondLandToDiscard;
- int BurningInquiryThatCanBeDiscarded=Math.min(BurningInquiryInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-BurningInquiryThatCanBeDiscarded;
- BurningInquiryInHand=BurningInquiryInHand-BurningInquiryThatCanBeDiscarded;
- int StreetWraithThatCanBeDiscarded=Math.min(StreetWraithInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-StreetWraithThatCanBeDiscarded;
- StreetWraithInHand=StreetWraithInHand-StreetWraithThatCanBeDiscarded;
- int HollowOneToSadlyDiscard=Math.min(HollowOneInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-HollowOneToSadlyDiscard;
- HollowOneInHand=HollowOneInHand-HollowOneToSadlyDiscard;
- //We have now resolved Faithless Looting
- }
- if (ManaRemaining>0 && BurningInquiryInHand>=1) {
- BurningInquiryInHand--;
- ManaRemaining--;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
- for (int CardsDrawn=1; CardsDrawn<=3; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
- HandForRandomDiscard.DeleteThreeCardsAtRandom();
- MountainInHand=HandForRandomDiscard.NumberOfLands;
- BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
- FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
- GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
- StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
- HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
- ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
- }
- while (StreetWraithInHand>0){
- StreetWraithInHand--;
- NrCardsDiscardedThisTurn++;
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- // Cast turn-one Hollow Ones
- if (NrCardsDiscardedThisTurn>=3) {
- Outcome=HollowOneInHand+HollowOnesPlayed;
- HollowOneInHand=0;
- }
- if (NrCardsDiscardedThisTurn>=2 && ManaRemaining==1 && HollowOneInHand>=1) {
- Outcome=1;
- HollowOneInHand=HollowOneInHand-1;
- }
- //Turn 2 (if we cast 0 Hollow Ones on turn 1)
- if (Outcome == 0 ){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- NrCardsDiscardedThisTurn=0;
- LandDrop=false;
- ManaRemaining=0;
- HollowOnesPlayed=0;
- while (StreetWraithInHand>0){
- StreetWraithInHand--;
- NrCardsDiscardedThisTurn++;
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- if (NrCardsDiscardedThisTurn>=3) {
- HollowOnesPlayed=HollowOneInHand;
- HollowOneInHand=0;
- }
- PossibleLands=MountainInPlay+MountainInHand;
- if (MountainInPlay==0 && MountainInHand>0) {MountainInHand--; MountainInPlay++; LandDrop=true;}
- ManaRemaining=MountainInPlay;
- // Turn 2 logic:
- // If you have [ >=2 lands between hand/battlefield and { >=2 Looting/Inquiry OR ( >=1 Looting/Inquiry and no Goblin Lore) } ] OR [ one land between hand/battlefield and >=1 Looting/Inquiry]:
- // First (Inquiry if possible, else Looting), then Wraiths, then Hollow Ones, then another land if possible, then (Inquiry if possible, else Looting if possible), then Wraiths.
- // If you have two lands between hand/battlefield and ( < Looting/Inquiry AND >=1 Goblin Lore):
- // Drop land, cast Goblin Lore, then Wraiths.
- if ((PossibleLands>=2 && ( FaithlessLootingInHand+BurningInquiryInHand>=2 || (FaithlessLootingInHand+BurningInquiryInHand>=1 && GoblinLoreInHand==0))) || ( PossibleLands==1 && FaithlessLootingInHand+BurningInquiryInHand>=1) ) {
- if (BurningInquiryInHand>=1 && ManaRemaining>=1){
- BurningInquiryInHand--;
- ManaRemaining--;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
- for (int CardsDrawn=1; CardsDrawn<=3; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
- HandForRandomDiscard.DeleteThreeCardsAtRandom();
- MountainInHand=HandForRandomDiscard.NumberOfLands;
- BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
- FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
- GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
- StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
- HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
- ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
- }
- if (FaithlessLootingInHand>=1 && ManaRemaining>=1){
- FaithlessLootingInHand--;
- ManaRemaining--;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+2;
- for (int CardsDrawn=1; CardsDrawn<=2; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- int CardsToDiscardToLooting=2;
- //Try to discard irrelevant cards if possible
- int SpellsThatCanBeDiscarded=Math.min(ExtraSpellsInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-SpellsThatCanBeDiscarded;
- ExtraSpellsInHand=ExtraSpellsInHand-SpellsThatCanBeDiscarded;
- int LandsOverSecondThatCanBeDiscarded=Math.min(Math.max(MountainInHand-1,0),CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-LandsOverSecondThatCanBeDiscarded;
- MountainInHand=MountainInHand-LandsOverSecondThatCanBeDiscarded;
- int GoblinLoresThatCanBeDiscarded=Math.min(GoblinLoreInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-GoblinLoresThatCanBeDiscarded;
- GoblinLoreInHand=GoblinLoreInHand-GoblinLoresThatCanBeDiscarded;
- int FaithlessLootingThatCanBeDiscarded=Math.min(FaithlessLootingInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-FaithlessLootingThatCanBeDiscarded;
- FaithlessLootingInHand=FaithlessLootingInHand-FaithlessLootingThatCanBeDiscarded;
- //It is extremely unlikely that we aren't done discarding to Faithless Looting by now, but let's catch all the corner cases
- int PossibleSecondLandToDiscard=Math.min(MountainInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-PossibleSecondLandToDiscard;
- MountainInHand=MountainInHand-PossibleSecondLandToDiscard;
- int BurningInquiryThatCanBeDiscarded=Math.min(BurningInquiryInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-BurningInquiryThatCanBeDiscarded;
- BurningInquiryInHand=BurningInquiryInHand-BurningInquiryThatCanBeDiscarded;
- int StreetWraithThatCanBeDiscarded=Math.min(StreetWraithInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-StreetWraithThatCanBeDiscarded;
- StreetWraithInHand=StreetWraithInHand-StreetWraithThatCanBeDiscarded;
- int HollowOneToSadlyDiscard=Math.min(HollowOneInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-HollowOneToSadlyDiscard;
- HollowOneInHand=HollowOneInHand-HollowOneToSadlyDiscard;
- //We have now resolved Faithless Looting
- }
- while (StreetWraithInHand>0){
- StreetWraithInHand--;
- NrCardsDiscardedThisTurn++;
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- if (NrCardsDiscardedThisTurn>=3) {
- HollowOnesPlayed=HollowOnesPlayed+HollowOneInHand;
- HollowOneInHand=0;
- }
- if (MountainInHand>=1 && LandDrop==false) {
- MountainInHand--; MountainInPlay++; LandDrop=true; ManaRemaining++;
- }
- if (BurningInquiryInHand>=1 && ManaRemaining>=1){
- BurningInquiryInHand--;
- ManaRemaining--;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
- for (int CardsDrawn=1; CardsDrawn<=3; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
- HandForRandomDiscard.DeleteThreeCardsAtRandom();
- MountainInHand=HandForRandomDiscard.NumberOfLands;
- BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
- FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
- GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
- StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
- HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
- ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
- }
- if (FaithlessLootingInHand>=1 && ManaRemaining>=1){
- FaithlessLootingInHand--;
- ManaRemaining--;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+2;
- for (int CardsDrawn=1; CardsDrawn<=2; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- int CardsToDiscardToLooting=2;
- //Try to discard irrelevant cards if possible
- int SpellsThatCanBeDiscarded=Math.min(ExtraSpellsInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-SpellsThatCanBeDiscarded;
- ExtraSpellsInHand=ExtraSpellsInHand-SpellsThatCanBeDiscarded;
- int LandsOverSecondThatCanBeDiscarded=Math.min(Math.max(MountainInHand-1,0),CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-LandsOverSecondThatCanBeDiscarded;
- MountainInHand=MountainInHand-LandsOverSecondThatCanBeDiscarded;
- int GoblinLoresThatCanBeDiscarded=Math.min(GoblinLoreInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-GoblinLoresThatCanBeDiscarded;
- GoblinLoreInHand=GoblinLoreInHand-GoblinLoresThatCanBeDiscarded;
- int FaithlessLootingThatCanBeDiscarded=Math.min(FaithlessLootingInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-FaithlessLootingThatCanBeDiscarded;
- FaithlessLootingInHand=FaithlessLootingInHand-FaithlessLootingThatCanBeDiscarded;
- //It is extremely unlikely that we aren't done discarding to Faithless Looting by now, but let's catch all the corner cases
- int PossibleSecondLandToDiscard=Math.min(MountainInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-PossibleSecondLandToDiscard;
- MountainInHand=MountainInHand-PossibleSecondLandToDiscard;
- int BurningInquiryThatCanBeDiscarded=Math.min(BurningInquiryInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-BurningInquiryThatCanBeDiscarded;
- BurningInquiryInHand=BurningInquiryInHand-BurningInquiryThatCanBeDiscarded;
- int StreetWraithThatCanBeDiscarded=Math.min(StreetWraithInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-StreetWraithThatCanBeDiscarded;
- StreetWraithInHand=StreetWraithInHand-StreetWraithThatCanBeDiscarded;
- int HollowOneToSadlyDiscard=Math.min(HollowOneInHand,CardsToDiscardToLooting);
- CardsToDiscardToLooting=CardsToDiscardToLooting-HollowOneToSadlyDiscard;
- HollowOneInHand=HollowOneInHand-HollowOneToSadlyDiscard;
- //We have now resolved Faithless Looting
- }
- }
- if (MountainInHand>=1 && LandDrop==false) {
- MountainInHand--; MountainInPlay++; LandDrop=true; ManaRemaining++;
- }
- if (NrCardsDiscardedThisTurn==2 && HollowOneInHand>=2 && ManaRemaining>=2) {
- HollowOnesPlayed=HollowOnesPlayed+2;
- HollowOneInHand=HollowOneInHand-2;
- ManaRemaining=0;
- }
- if (NrCardsDiscardedThisTurn==2 && HollowOneInHand>=1 && ManaRemaining>=1 && GoblinLoreInHand==0) {
- HollowOnesPlayed=HollowOnesPlayed+Math.min(HollowOneInHand,ManaRemaining);
- HollowOneInHand=HollowOneInHand-Math.min(HollowOneInHand,ManaRemaining);
- ManaRemaining=ManaRemaining-Math.min(HollowOneInHand,ManaRemaining);
- }
- if (ManaRemaining>=2 && GoblinLoreInHand>=1) {
- GoblinLoreInHand--;
- ManaRemaining=ManaRemaining-2;
- NrCardsDiscardedThisTurn=NrCardsDiscardedThisTurn+3;
- for (int CardsDrawn=1; CardsDrawn<=4; CardsDrawn++){
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- HandForRandomDiscard.SetHand(MountainInHand, BurningInquiryInHand, FaithlessLootingInHand, GoblinLoreInHand, StreetWraithInHand, HollowOneInHand, ExtraSpellsInHand);
- HandForRandomDiscard.DeleteThreeCardsAtRandom();
- MountainInHand=HandForRandomDiscard.NumberOfLands;
- BurningInquiryInHand=HandForRandomDiscard.NumberOfCardType2;
- FaithlessLootingInHand=HandForRandomDiscard.NumberOfCardType3;
- GoblinLoreInHand=HandForRandomDiscard.NumberOfCardType4;
- StreetWraithInHand=HandForRandomDiscard.NumberOfCardType5;
- HollowOneInHand=HandForRandomDiscard.NumberOfCardType6;
- ExtraSpellsInHand=HandForRandomDiscard.NumberOfSpells;
- }
- //If all else fails, cycle Hollow One and hope
- if (ManaRemaining>=2 && HollowOneInHand>=1) {
- HollowOneInHand--;
- ManaRemaining=ManaRemaining-2;
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- while (StreetWraithInHand>0){
- StreetWraithInHand--;
- NrCardsDiscardedThisTurn++;
- TypeOfCardDrawn=remainingdeck.DrawCard();
- if (TypeOfCardDrawn==1) {MountainInHand++;}
- if (TypeOfCardDrawn==2) {BurningInquiryInHand++;}
- if (TypeOfCardDrawn==3) {FaithlessLootingInHand++;}
- if (TypeOfCardDrawn==4) {GoblinLoreInHand++;}
- if (TypeOfCardDrawn==5) {StreetWraithInHand++;}
- if (TypeOfCardDrawn==6) {HollowOneInHand++;}
- if (TypeOfCardDrawn==7) {ExtraSpellsInHand++;}
- }
- // Cast turn-two Hollow Ones
- if (NrCardsDiscardedThisTurn>=3 && HollowOneInHand+HollowOnesPlayed>0) {
- Outcome=10+HollowOneInHand+HollowOnesPlayed;
- HollowOneInHand=0;
- }
- if (NrCardsDiscardedThisTurn==2 && HollowOnesPlayed>0) {
- Outcome=10+HollowOnesPlayed;
- }
- }
- return Outcome;
- }//end of SimulateGame
- }
- class OpeningHand {
- int NumberOfLands;
- int NumberOfCardType2;
- int NumberOfCardType3;
- int NumberOfCardType4;
- int NumberOfCardType5;
- int NumberOfCardType6;
- int NumberOfSpells;
- int NrOfCards(){
- return NumberOfLands+NumberOfCardType2+NumberOfCardType3+NumberOfCardType4+NumberOfCardType5+NumberOfCardType6+NumberOfSpells;
- }
- void SetHand (int Nr1, int Nr2, int Nr3, int Nr4, int Nr5, int Nr6, int Nr7) {
- NumberOfLands=Nr1;
- NumberOfCardType2=Nr2;
- NumberOfCardType3=Nr3;
- NumberOfCardType4=Nr4;
- NumberOfCardType5=Nr5;
- NumberOfCardType6=Nr6;
- NumberOfSpells=Nr7;
- }
- void DeleteThreeCardsAtRandom () {
- Random generator = new Random();
- int CardType=0;
- for (int RandomDiscard=1; RandomDiscard<=3; RandomDiscard++){
- int RandomIntegerBetweenOneAndHandSize=generator.nextInt( this.NrOfCards() )+1;
- int OneCutoff=NumberOfLands;
- int TwoCutoff=OneCutoff+NumberOfCardType2;
- int ThreeCutoff=TwoCutoff+NumberOfCardType3;
- int FourCutoff=ThreeCutoff+NumberOfCardType4;
- int FiveCutoff=FourCutoff+NumberOfCardType5;
- int SixCutoff=FiveCutoff+NumberOfCardType6;
- int SevenCutoff=SixCutoff+NumberOfSpells;
- if (RandomIntegerBetweenOneAndHandSize<=OneCutoff) {this.NumberOfLands--;}
- if (RandomIntegerBetweenOneAndHandSize>OneCutoff && RandomIntegerBetweenOneAndHandSize<=TwoCutoff) {CardType=2; this.NumberOfCardType2--;}
- if (RandomIntegerBetweenOneAndHandSize>TwoCutoff && RandomIntegerBetweenOneAndHandSize<=ThreeCutoff) {CardType=3; this.NumberOfCardType3--;}
- if (RandomIntegerBetweenOneAndHandSize>ThreeCutoff && RandomIntegerBetweenOneAndHandSize<=FourCutoff) {CardType=4; this.NumberOfCardType4--;}
- if (RandomIntegerBetweenOneAndHandSize>FourCutoff && RandomIntegerBetweenOneAndHandSize<=FiveCutoff) {CardType=5; this.NumberOfCardType5--;}
- if (RandomIntegerBetweenOneAndHandSize>FiveCutoff && RandomIntegerBetweenOneAndHandSize<=SixCutoff) {CardType=6; this.NumberOfCardType6--;}
- if (RandomIntegerBetweenOneAndHandSize>SixCutoff && RandomIntegerBetweenOneAndHandSize<=SevenCutoff) {CardType=7; this.NumberOfSpells--;}
- }
- }
- }//end of OpeningHand
- class Deck {
- int NumberOfLands;
- int NumberOfCardType2;
- int NumberOfCardType3;
- int NumberOfCardType4;
- int NumberOfCardType5;
- int NumberOfCardType6;
- int NumberOfSpells;
- void SetDeck (int Nr1, int Nr2, int Nr3, int Nr4, int Nr5, int Nr6, int Nr7) {
- NumberOfLands=Nr1;
- NumberOfCardType2=Nr2;
- NumberOfCardType3=Nr3;
- NumberOfCardType4=Nr4;
- NumberOfCardType5=Nr5;
- NumberOfCardType6=Nr6;
- NumberOfSpells=Nr7;
- }
- int NrOfCards(){
- return NumberOfLands+NumberOfCardType2+NumberOfCardType3+NumberOfCardType4+NumberOfCardType5+NumberOfCardType6+NumberOfSpells;
- }
- int DrawCard (){
- Random generator = new Random();
- int CardType=0;
- int RandomIntegerBetweenOneAndDeckSize=generator.nextInt( this.NrOfCards() )+1;
- int OneCutoff=NumberOfLands;
- int TwoCutoff=OneCutoff+NumberOfCardType2;
- int ThreeCutoff=TwoCutoff+NumberOfCardType3;
- int FourCutoff=ThreeCutoff+NumberOfCardType4;
- int FiveCutoff=FourCutoff+NumberOfCardType5;
- int SixCutoff=FiveCutoff+NumberOfCardType6;
- int SevenCutoff=SixCutoff+NumberOfSpells;
- if (RandomIntegerBetweenOneAndDeckSize<=OneCutoff) {CardType=1; this.NumberOfLands--;}
- if (RandomIntegerBetweenOneAndDeckSize>OneCutoff && RandomIntegerBetweenOneAndDeckSize<=TwoCutoff) {CardType=2; this.NumberOfCardType2--;}
- if (RandomIntegerBetweenOneAndDeckSize>TwoCutoff && RandomIntegerBetweenOneAndDeckSize<=ThreeCutoff) {CardType=3; this.NumberOfCardType3--;}
- if (RandomIntegerBetweenOneAndDeckSize>ThreeCutoff && RandomIntegerBetweenOneAndDeckSize<=FourCutoff) {CardType=4; this.NumberOfCardType4--;}
- if (RandomIntegerBetweenOneAndDeckSize>FourCutoff && RandomIntegerBetweenOneAndDeckSize<=FiveCutoff) {CardType=5; this.NumberOfCardType5--;}
- if (RandomIntegerBetweenOneAndDeckSize>FiveCutoff && RandomIntegerBetweenOneAndDeckSize<=SixCutoff) {CardType=6; this.NumberOfCardType6--;}
- if (RandomIntegerBetweenOneAndDeckSize>SixCutoff && RandomIntegerBetweenOneAndDeckSize<=SevenCutoff) {CardType=7; this.NumberOfSpells--;}
- return CardType;
- }
- }//end of Deck
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement