private static bool DoesHandHaveCombinationToTrash(GameState gameState)
            {
                int countToTrash = CountInHandFrom(TrashOrder(), gameState);
                int countInHand = gameState.Self.Hand.Count;

                return (countInHand - countToTrash <= 2);
            }
        private static bool ShouldGainHermit(GameState gameState)
        {
            if (PlayBigHermit(gameState))
                return CountHermitsEverGained(gameState) < 9 && CountAllOwned(Cards.MarketSquare, gameState) == 0;

            return CountHermitsEverGained(gameState) < 7 && CountAllOwned(Cards.MarketSquare, gameState) == 0;
        }
Пример #3
0
 private static bool ShouldPlayRebuild(GameState gameState)
 {
     return !(gameState.players.CurrentPlayer.ExpectedCoinValueAtEndOfTurn >= 8 && CountOfPile(Cards.Province, gameState) == 1)
            && !(CountOfPile(Cards.Duchy, gameState) == 0
            && CountInDeckAndDiscard(Cards.Duchy, gameState) == 0 && PlayersPointLead(gameState) < 0)
            && CountOfPile(Cards.Province, gameState) > 0;
 }
Пример #4
0
        private static bool ShouldGainCopper(GameState gameState, ICardPicker gainOrder)
        {
            PlayerState self = gameState.Self;

            int minValue = self.ExpectedCoinValueAtEndOfTurn;
            int maxValue = minValue + Strategy.CountInHand(Dominion.Cards.IllGottenGains, gameState);

            if (maxValue == minValue)
                return false;

            CardPredicate shouldGainCard = delegate(Card card)
            {
                int currentCardCost = card.CurrentCoinCost(self);

                return currentCardCost >= minValue &&
                        currentCardCost <= maxValue;
            };

            Card cardType = gainOrder.GetPreferredCard(gameState, shouldGainCard);
            if (cardType == null)
                return false;

            int coppersToGain = DefaultPlayerAction.CostOfCard(cardType, gameState) - minValue;

            return (coppersToGain > 0);
        }
Пример #5
0
        public bool GameStatePredicate(GameState gameState)
        {
            int countOfTheSource;

            switch (countSource)
            {
                case CountSource.Pile:
                    countOfTheSource = Strategies.CountOfPile(this.cardType, gameState);
                    break;
                case CountSource.AllOwned:
                    countOfTheSource = Strategies.CountAllOwned(this.cardType, gameState);
                    break;
                case CountSource.InHand:
                    countOfTheSource = Strategies.CountInHand(this.cardType, gameState);
                    break;
                case CountSource.None:
                    return true;
                default:
                    throw new Exception("Unhandled source case");
            }

            switch (this.comparison)
            {
                case Comparison.GreaterThan:
                    {
                        return countOfTheSource > this.countThreshHold;
                    }
                case Comparison.LessThan:
                    {
                        return countOfTheSource < this.countThreshHold;
                    }
                default:
                    throw new Exception("Unhandled comparison case");
            }
        }
        public Card GetPreferredCardReverse(GameState gameState, CardPredicate cardPredicate)
        {
            if (predicate(gameState))
                return this.picker.GetPreferredCardReverse(gameState, cardPredicate);

            return null;
        }
 public override void EndGame(GameState gameState)
 {
     if (this.textWriter != null)
     {
         Write(this.textWriter, gameState.players.OriginalPlayerOrder);
     }
 }
Пример #8
0
        public override Card GetCardFromHandToReveal(GameState gameState, CardPredicate acceptableCard)
        {
            if (gameState.Self.Hand.HasCard(gameState.BaneCard))
                return gameState.BaneCard;

            return null;
        }
        public int AmountWillingtoOverPayFor(Card card, GameState gameState)
        {
            if (predicate(gameState))
                return this.picker.AmountWillingtoOverPayFor(card, gameState);

            return 0;
        }
Пример #10
0
        public override bool ShouldPutCardOnTopOfDeck(Card card, GameState gameState)
        {
            if (this.playerAction.discardOrder.DoesCardPickerMatch(gameState, card))
                return false;

            return true;
        }
Пример #11
0
        private static bool ShouldPlayTrader(GameState gameState)
        {
            if (gameState.Self.Hand.HasCard(Cards.Estate))
            {
                return !ShouldGainEstate(gameState);
            }

            if (gameState.Self.ExpectedCoinValueAtEndOfTurn >= 8)
                return false;
            /*
            if (gameState.Self.Actions.ShouldGainCard(gameState, Cards.Duchy) && gameState.Self.ExpectedCoinValueAtEndOfTurn >= 5)
                return false;
            */
            if (gameState.Self.ExpectedCoinValueAtEndOfTurn <= 4)
                return true;

            /*
            if (gameState.Self.Actions.ShouldGainCard(gameState, Cards.Province))
                return false;*/

            if (gameState.Self.ExpectedCoinValueAtEndOfTurn <= 3 && !gameState.Self.Hand.HasCard(Cards.Silver))
                return false;

            return true;
        }
            public override PlayerActionChoice ChooseBetween(GameState gameState, IsValidChoice acceptableChoice)
            {
                if (gameState.CurrentContext.CurrentCard == Cards.Governor)
                    return PlayerActionChoice.GainCard;

                return base.ChooseBetween(gameState, acceptableChoice);
            }
        private static bool ShouldTrashPotion(GameState gameState)
        {
            if (!gameState.Self.Actions.ShouldGainCard(gameState, Cards.ScryingPool))
                return true;

            return false;
        }
Пример #14
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card revealedCard = currentPlayer.RequestPlayerRevealCardFromHand(acceptableCard => true, gameState);
            PlayerState.AttackAction attackAction = this.DoEmptyAttack;

            if (revealedCard != null && !revealedCard.isShelter)
            {
                int maxReturnCount = Math.Max(currentPlayer.Hand.CountOf(revealedCard), 2);

                int returnCount = currentPlayer.actions.GetCountToReturnToSupply(revealedCard, gameState);
                returnCount = Math.Min(returnCount, maxReturnCount);
                returnCount = Math.Max(returnCount, 0);

                for (int i = 0; i < returnCount; ++i)
                {
                    if (currentPlayer.hand.HasCard(revealedCard))
                    {
                        currentPlayer.ReturnCardFromHandToSupply(revealedCard, gameState);
                    }
                }

                attackAction = delegate(PlayerState currentPlayer2, PlayerState otherPlayer, GameState gameState2)
                {
                    otherPlayer.GainCardFromSupply(gameState, revealedCard);
                };
            }

            currentPlayer.AttackOtherPlayers(gameState, attackAction);
        }
Пример #15
0
            private static bool ShouldByLastCard(Card card, GameState gameState)
            {
                if (CountOfPile(card, gameState) != 1)
                    return true;

                return CountOfPile(Cards.Province, gameState) == 1;
            }
Пример #16
0
        private static bool CountOfPileLessthanEqual(Card cardType, GameState gameState, int count)
        {
            if (gameState.GetSupplyPile(cardType) == null)
                return true;

            return CountOfPile(cardType, gameState) <= count;
        }
Пример #17
0
        public void EndGame(GameState gameState)
        {
            this.textWriter.WriteLine("Game ended in {0} turns.", this.roundNumber);

            PlayerState[] winners = gameState.WinningPlayers;

            if (winners.Length == 1)
            {
                this.textWriter.WriteLine("{0} Won!", winners[0].actions.PlayerName);
            }
            else
            {
                this.textWriter.Write("There was a tie between: ");
                foreach (PlayerState player in winners)
                {
                    this.textWriter.Write("{0}, ", player.actions.PlayerName);
                }
                this.textWriter.WriteLine();
            }

            foreach (PlayerState player in gameState.players.AllPlayers)
            {
                this.textWriter.WriteLine("{0} total score: {1}", player.actions.PlayerName, player.TotalScore());
                this.PushScope();
                this.WriteAllCards(player);
                this.PopScope();
            }

            this.textWriter.Write("Trash contains: ");
            this.WriteAllCards(gameState.trash);

            this.textWriter.WriteLine();
        }
Пример #18
0
        private static bool DoesHandHaveCombinationToTrash(DefaultPlayerAction playerAction, GameState gameState)
        {
            int countToTrash = Strategy.CountInHandFrom(playerAction.trashOrder, gameState);
            int countInHand = gameState.Self.Hand.Count;

            return (countInHand - countToTrash <= 2);
        }
 private static bool HasChainingDeck(GameState gameState)
 {
     return CountAllOwned(Cards.Chapel, gameState) +
            CountAllOwned(Cards.IronWorks, gameState) +
            CountAllOwned(Cards.Copper, gameState) +
            CountAllOwned(Cards.Estate, gameState) <= 4;
 }
Пример #20
0
        public override void DoSpecializedAction(PlayerState currentPlayer, GameState gameState)
        {
            Card revealedCard = currentPlayer.RequestPlayerRevealCardFromHand(acceptableCard => true, gameState);
            if (revealedCard == null)
            {
                return;
            }

            currentPlayer.MoveRevealedCardToHand(revealedCard);

            int maxReturnCount = 1;
            if (currentPlayer.Hand.CountWhere(card => card.Equals(revealedCard)) > 1)
            {
                maxReturnCount++;
            }

            int returnCount = currentPlayer.actions.GetCountToReturnToSupply(revealedCard, gameState);
            returnCount = Math.Min(returnCount, maxReturnCount);
            returnCount = Math.Max(returnCount, 0);

            for (int i = 0; i < returnCount; ++i)
            {
                currentPlayer.ReturnCardFromHandToSupply(revealedCard, gameState);
            }

            foreach (PlayerState otherPlayer in gameState.players.OtherPlayers)
            {
                if (!otherPlayer.IsAffectedByAttacks(gameState))
                {
                    otherPlayer.GainCardFromSupply(gameState, revealedCard);
                }
            }
        }
Пример #21
0
 public override PlayerActionChoice ChooseBetween(GameState gameState, IsValidChoice acceptableChoice)
 {
     if (acceptableChoice(PlayerActionChoice.Trash))
     {
         bool wantToTrash = WillPlayCountCardForTrash(this.playerAction, gameState);
         if (wantToTrash)
         {
             return PlayerActionChoice.Trash;
         }
         else if (PreferMoneyOverDuchy(this.playerAction, gameState))
         {
             return PlayerActionChoice.PlusCoin;
         }
         else
         {
             return PlayerActionChoice.GainCard;
         }
     }
     else
     {
         if (Strategy.HasExactlyOneActionInHand(gameState))
         {
             return PlayerActionChoice.TopDeck;
         }
         else if (ShouldGainCopper(gameState))
         {
             return PlayerActionChoice.GainCard;
         }
         else
         {
             return PlayerActionChoice.Discard;
         }
     }
 }
            public override PlayerActionChoice ChooseBetween(GameState gameState, IsValidChoice acceptableChoice)
            {
                if (CardBeingPlayedIs(Cards.Graverobber, gameState))
                {
                    // always prefer trashing cards that might get convertd to victory points
                    if (gameState.Self.Hand.AnyWhere(card => CardTypes.Graverobber.CardValidToTrash(card) &&
                                                                card.CurrentCoinCost(gameState.Self) >= 5 &&
                                                                HasCardIn(card, this.trashOrder, gameState)))
                        return PlayerActionChoice.Trash;

                    // otherwise prefer to gain a card from trash if you are trying to gain it
                    if (gameState.trash.HasCard(c => CardTypes.Graverobber.CardValidToGainFromTrash(c, gameState.Self) &&
                                                        HasCardIn(c, this.purchaseOrder, gameState)))
                    {
                        return PlayerActionChoice.GainCard;
                    }

                    // otherwise, you really want to do nothing

                    // otherwise gain whatever u can from the trash
                    return PlayerActionChoice.GainCard;
                }
                else if (CardBeingPlayedIs(Cards.Squire, gameState))
                {
                    if (gameState.Self.AvailableActions == 0)
                        return PlayerActionChoice.PlusAction;
                    else
                        return PlayerActionChoice.PlusBuy;
                }

                return base.ChooseBetween(gameState, acceptableChoice);
            }
Пример #23
0
 private new void DoSpecializedCleanupAtStartOfCleanup(PlayerState currentPlayer, GameState gameState)
 {
     if (currentPlayer.cardsPlayed.HasCard(Cards.Potion))
     {
         currentPlayer.RequestPlayerTopDeckCardFromCleanup(this, gameState);
     }
 }
            public override PlayerActionChoice ChooseBetween(GameState gameState, IsValidChoice acceptableChoice)
            {
                if (gameState.CurrentContext.CurrentCard == Cards.Minion)
                {
                    if (CountInHand(Cards.Minion, gameState) >= 2)
                        return PlayerActionChoice.PlusCoin;

                    if (HasCardInHand(Cards.Butcher, gameState) && HasCardInHand(Cards.Gold, gameState))
                        return PlayerActionChoice.PlusCoin;

                    if (gameState.Self.ExpectedCoinValueAtEndOfTurn + CountInHand(Cards.Minion, gameState) * 2 >= 6)
                        return PlayerActionChoice.PlusCoin;

                    if (HasCardInHand(Cards.Soothsayer, gameState))
                    {
                        return PlayerActionChoice.PlusCoin;
                    }

                    return PlayerActionChoice.Discard;
                }

                if (gameState.CurrentContext.CurrentCard == Cards.Pawn)
                {
                    if (acceptableChoice(PlayerActionChoice.PlusAction))
                        return PlayerActionChoice.PlusAction;
                    return PlayerActionChoice.PlusCard;
                }

                return base.ChooseBetween(gameState, acceptableChoice);
            }
 public void EndGame(GameState gameState)
 {
     for (int i = 0; i < this.gameLogs.Length; ++i)
     {
         this.gameLogs[i].EndGame(gameState);
     }
 }
Пример #26
0
 public override void DoSpecializedSetupIfInSupply(GameState gameState)
 {
     foreach (PlayerState player in gameState.players.AllPlayers)
     {
         player.AddCoinTokens(1);
     }
 }
Пример #27
0
        public override DeckPlacement ChooseBetweenTrashAndTopDeck(GameState gameState, Card card)
        {
            if (playerAction.gainOrder.DoesCardPickerMatch(gameState, card))
                return DeckPlacement.TopOfDeck;

            return DeckPlacement.Trash;
        }
Пример #28
0
 public override int GetCoinAmountToOverpayForCard(GameState gameState, Card card)
 {
     Card cardToOverpayFor = this.playerAction.purchaseOrder.GetPreferredCard(gameState, c => c.CurrentCoinCost(gameState.Self) <= gameState.Self.AvailableCoins);
     if (cardToOverpayFor == null)
         return 0;
     return cardToOverpayFor.CurrentCoinCost(gameState.Self);
 }
Пример #29
0
 public static int CountMightDraw(Card card, GameState gameState, int maxCount)
 {
     if (gameState.Self.CardsInDeck.Count >= maxCount)
         return CountInDeck(card, gameState);
     else
         return CountInDeckAndDiscard(card, gameState);
 }
 private static bool ShouldBuyPillage(GameState gameState)
 {
     return CountAllOwned(Cards.Pillage, gameState) +
            CountAllOwned(Cards.Gold, gameState) +
            CountAllOwned(Cards.Venture, gameState) +
            CountAllOwned(Cards.Journeyman, gameState) +
            CountAllOwned(Cards.Spoils, gameState) < 2;
 }