当前位置: 首页>>代码示例>>C#>>正文


C# Card.GetValue方法代码示例

本文整理汇总了C#中Santase.Logic.Cards.Card.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# Card.GetValue方法的具体用法?C# Card.GetValue怎么用?C# Card.GetValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Santase.Logic.Cards.Card的用法示例。


在下文中一共展示了Card.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CardWorth

        private int CardWorth(Card card, ICollection<Card> hand, PlayerTurnContext context)
        {
            var possibleTakes = this.cardTracker.AllCards[card.Suit]
                .Where(x => (x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown)
                            && x.Key < card.GetValue())
                .ToList();

            if (possibleTakes.Count == 0)
            {
                return card.GetValue();
            }

            var value = card.GetValue() + possibleTakes.Max(x => x.Key);
            return value;
        }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:15,代码来源:CardStatisticsGenerator.cs

示例2: PointAndSuitCountParameter

 private float PointAndSuitCountParameter(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
 {
     var cardSuit = card.Suit;
     float cardValue = card.GetValue();
     float coutOfSuitInHand = allowedCards.Count(x => x.Suit == cardSuit);
     return (11f - cardValue) * coutOfSuitInHand;
 }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:7,代码来源:CardEvaluatorFirstPlayer.cs

示例3: CalculateProbabilityCardToBeTaken

        public double CalculateProbabilityCardToBeTaken(Card card, ICollection<Card> myCards, ICollection<Card> playedCards)
        {
            ICollection<Card> opponentCards = this.opponentsCardProvider.GetOpponentCards(myCards, playedCards, this.context.TrumpCard, card.Suit);
            ICollection<Card> trumpOpponentCard = this.opponentsCardProvider.GetOpponentCards(myCards, playedCards, this.context.TrumpCard, this.context.TrumpCard.Suit);
            int biggestThanCardCount = 0;
            foreach (var opponentCard in opponentCards)
            {
                if (opponentCard.Suit == this.context.TrumpCard.Suit && card.Suit != opponentCard.Suit)
                {
                    biggestThanCardCount++;
                }
                else if (opponentCard.GetValue() > card.GetValue())
                {
                    biggestThanCardCount++;
                }
            }

            if (card.Suit != this.context.TrumpCard.Suit)
            {
                biggestThanCardCount += trumpOpponentCard.Count;
            }

            int lesserThanCardCount = 24 - playedCards.Count - biggestThanCardCount - 6;
            if (lesserThanCardCount < 6)
            {
                return 1;
            }

            double result = CalculateFactoriel(lesserThanCardCount) / SixFactoriel * CalculateFactoriel(lesserThanCardCount - 6);
            return 1 - result;
        }
开发者ID:KingSharkPower,项目名称:MyFirstAndOnlyRepository,代码行数:31,代码来源:ProbabilityCalculator.cs

示例4: MaxHandValue

        private float MaxHandValue(Card card, PlayerTurnContext context)
        {
            var suit = card.Suit;
            var value = card.GetValue();
            var isTrump = context.TrumpCard.Suit == suit;

            var result = 0f;

            var cardsToTake = this.cardtracker
                .AllCards[suit]
                .Where(x => x.Key < value &&
                    (x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown))
                .ToList();

            if (isTrump)
            {
                cardsToTake
                    .AddRange(this.cardtracker
                        .AllCards
                        .Where(s => s.Key != suit)
                        .SelectMany(c => c.Value)
                        .Where(x => x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown));
            }

            var high = cardsToTake.Count > 0 ? cardsToTake.Max(x => x.Key) : 0;

            result += high;

            if (isTrump)
            {
                result += 10;
            }

            return result / (this.MaxTakeCases(value, suit) - cardsToTake.Count());
        }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:35,代码来源:CardEvaluatorWorthBased.cs

示例5: NumberOfHandsCardCanTake

        private int NumberOfHandsCardCanTake(Card card, PlayerTurnContext context)
        {
            var count = this.cardTracker.AllCards[card.Suit]
                   .Where(x => (x.Value == CardTracerState.InOpponentHand || x.Value == CardTracerState.Unknown)
                               && x.Key < card.GetValue())
                   .Count();

            return count;
        }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:9,代码来源:CardStatisticsGenerator.cs

示例6: CardMaxWorthCalculator

        private int CardMaxWorthCalculator(Card player, ICardTracker cardTracker)
        {
            var worth = 0;

            worth += player.GetValue();

            var maxCardCanTake = cardTracker.AllCards[player.Suit].Where(x => x.Key > player.GetValue()
                && (x.Value == CardTracerState.Unknown || x.Value == CardTracerState.InOpponentHand)).ToList();

            if (maxCardCanTake.Count == 0)
            {
                return worth;
            }

            worth += maxCardCanTake.Max(x => x.Key);

            return worth;
        }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:18,代码来源:GameAction.cs

示例7: GameAction

 public GameAction(Card opponent, Card player, PlayerTurnContext context, ICardTracker cardTracker)
 {
     this.OpponetCard = opponent;
     this.PlayerCard = player;
     this.PlayerTakes = this.CheckIfPlayerTakes(opponent, player, context);
     this.HandValue = opponent.GetValue() + player.GetValue();
     this.CardMaxWorth = this.CardMaxWorthCalculator(player, cardTracker);
     this.OpponentPoints = context.FirstPlayerRoundPoints;
     this.PlayerPoints = context.SecondPlayerRoundPoints;
 }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:10,代码来源:GameAction.cs

示例8: BiggestGainParameter

        private float BiggestGainParameter(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
        {
            var suit = card.Suit;
            float value = card.GetValue();

            var allOfSuit = this.cardtracker.AllCards[suit];
            var maxAvailableForTaking = allOfSuit.Where(x => x.Value != CardTracerState.TakenByOpponent ||
                                                            x.Value != CardTracerState.TakenByPlayer).Max(x => x.Key);
            return (value + maxAvailableForTaking) / BiggestGainDivisor;
        }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:10,代码来源:CardEvaluatorFirstPlayer.cs

示例9: Winner

        public PlayerPosition Winner(Card firstPlayerCard, Card secondPlayerCard, CardSuit trumpSuit)
        {
            if (firstPlayerCard.Suit == secondPlayerCard.Suit)
            {
                // If both players play the same suit, the higher card wins.
                return firstPlayerCard.GetValue() > secondPlayerCard.GetValue()
                           ? PlayerPosition.FirstPlayer
                           : PlayerPosition.SecondPlayer;
            }

            // If just one player plays a trump, the trump wins.
            if (secondPlayerCard.Suit == trumpSuit)
            {
                return PlayerPosition.SecondPlayer;
            }

            // If the players play non-trumps of different suits the card played by the first player wins.
            return PlayerPosition.FirstPlayer;
        }
开发者ID:NotDemons,项目名称:NotDemonsRepo,代码行数:19,代码来源:CardWinnerLogic.cs

示例10: Winner

        public PlayerPosition Winner(Card firstPlayerCard, Card secondPlayerCard, CardSuit trumpSuit)
        {
            if (firstPlayerCard.Suit == secondPlayerCard.Suit)
            {
                if (firstPlayerCard.GetValue() > secondPlayerCard.GetValue())
                {
                    return PlayerPosition.FirstPlayer;
                }
                else
                {
                    return PlayerPosition.SecondPlayer;
                }
            }

            if (secondPlayerCard.Suit == trumpSuit)
            {
                return PlayerPosition.SecondPlayer;
            }
            return PlayerPosition.FirstPlayer;
        }
开发者ID:ValentinAlexandrovGeorgiev,项目名称:SantaseGameEngine,代码行数:20,代码来源:CardWinner.cs

示例11: CurrentCardWorth

        private float CurrentCardWorth(Card card, PlayerTurnContext context, ICollection<Card> allowedCards)
        {
            var result = 0f;

            var cardValue = card.GetValue();

            if (cardValue == 0)
            {
                result = this.NineEvaluation(card, context);
            }
            else if (cardValue == QueenValue || cardValue == KingValue)
            {
                result = this.QueenKingEvaluation(card, context, allowedCards);
            }
            else
            {
                result = this.MaxHandValue(card, context);
            }

            return result;
        }
开发者ID:KonstantinSimeonov,项目名称:Zatvoreno,代码行数:21,代码来源:CardEvaluatorWorthBased.cs

示例12: PlaySecondOpen

        public Card PlaySecondOpen(IList<Card> firstPlayerHandThisTurn, IList<Card> secondPlayerHandThisTurn, int pointsFirstPlayer, int pointsSecondPlayer, PlayerTurnContext context, Card firstPlayerCard)
        {
            Card secondPlayerCard;

            ////play th second player choice
            var secondPlayerSameSuit = secondPlayerHandThisTurn.Where(x => x.Suit == firstPlayerCard.Suit).Where(x => x.GetValue() > firstPlayerCard.GetValue());
            if (secondPlayerSameSuit.Count() > 0)
            {
                secondPlayerCard = secondPlayerSameSuit.FirstOrDefault();
            }
            else if (firstPlayerCard.GetValue() > 4)
            {
                ////CHECK for trump to take the other card
                ////TODO
                secondPlayerCard = secondPlayerHandThisTurn.FirstOrDefault();
            }
            else
            {
                secondPlayerCard = secondPlayerHandThisTurn.FirstOrDefault();
            }

            return secondPlayerCard;
        }
开发者ID:mimirerelala,项目名称:ElRumDrinkingCapitan,代码行数:23,代码来源:GameSimulation.cs

示例13: IfFirstPlayerIsWinner

        public bool IfFirstPlayerIsWinner(Card first, Card second, PlayerTurnContext context)
        {
            if (first.Suit == second.Suit)
            {
                return first.GetValue() > second.GetValue();
            }
            else
            {
                if (second.Suit == context.TrumpCard.Suit)
                {
                    return false;
                }

                return true;
            }
        }
开发者ID:mimirerelala,项目名称:ElRumDrinkingCapitan,代码行数:16,代码来源:GameSimulation.cs

示例14: PlaySecondClosed

        public Card PlaySecondClosed(IList<Card> firstPlayerHandThisTurn, IList<Card> secondPlayerHandThisTurn, int pointsFirstPlayer, int pointsSecondPlayer, PlayerTurnContext context, Card firstPlayerCard)
        {
            Card secondPlayerCard;

            ////play th second player choice
            IList<Card> secondPlayerSameSuit = secondPlayerHandThisTurn.Where(x => x.Suit == firstPlayerCard.Suit).ToList();

            if (secondPlayerSameSuit.Count() > 0)
            {
                secondPlayerSameSuit.OrderByDescending(x => x.GetValue());
                if (secondPlayerSameSuit.First().GetValue() > firstPlayerCard.GetValue())
                {
                    secondPlayerCard = secondPlayerSameSuit.First();
                }
                else
                {
                    secondPlayerCard = secondPlayerSameSuit.Last();
                }
            }
            else
            {
                ////us trumps
                var trumps = secondPlayerHandThisTurn.Where(x => x.Suit == context.TrumpCard.Suit);
                if (trumps.Count() > 0)
                {
                    secondPlayerCard = trumps.OrderBy(x => x.GetValue()).ElementAt(0);
                }
                else
                {
                    secondPlayerCard = secondPlayerHandThisTurn.FirstOrDefault();
                }
            }

            return secondPlayerCard;
        }
开发者ID:mimirerelala,项目名称:ElRumDrinkingCapitan,代码行数:35,代码来源:GameSimulation.cs

示例15: ChooseCardWhenPlayingFirstAndRulesDoNotApply

        private PlayerAction ChooseCardWhenPlayingFirstAndRulesDoNotApply(PlayerTurnContext context, ICollection<Card> possibleCardsToPlay)
        {
            var action = this.TryToAnnounce20Or40(context, possibleCardsToPlay);
            if (action != null)
            {
                return action;
            }

            int points = 0;
            int secondPlayerPoints = 0;
            if (context.IsFirstPlayerTurn)
            {
                points = context.FirstPlayerRoundPoints;
                secondPlayerPoints = context.SecondPlayerRoundPoints;
            }
            else
            {
                points = context.SecondPlayerRoundPoints;
                secondPlayerPoints = context.FirstPlayerRoundPoints;
            }

            if (points < 33 && secondPlayerPoints >= 50)
            {
                List<Card> cardsBiggerThanTen = this.Cards.Where(c => c.Suit == context.TrumpCard.Suit && c.GetValue() >= 10).ToList();
                if (cardsBiggerThanTen.Count() == 1 && cardsBiggerThanTen[0].GetValue() == 10)
                {
                    this.calculator = new ProbabilityCalculator(context, this.opponentSuitCardsProvider);
                    double probabilityTenToBeTaken = this.calculator.CalculateProbabilityCardToBeTaken(cardsBiggerThanTen[0], this.Cards, this.playedCards);

                    if (probabilityTenToBeTaken <= 0.5)
                    {
                        if (cardsBiggerThanTen[0] == null || !this.Cards.Contains(cardsBiggerThanTen[0]))
                        {
                            cardsBiggerThanTen[0] = this.Cards.First();
                        }

                        return this.PlayCard(cardsBiggerThanTen[0]);
                    }
                }
            }

            Card cardToPlay = new Card(context.TrumpCard.Suit, CardType.Ace);
            foreach (var card in possibleCardsToPlay)
            {
                if (card.GetValue() < cardToPlay.GetValue() && card.Suit != context.TrumpCard.Suit)
                {
                    if ((card.Type == CardType.King && !this.playedCards.Any(p => p.Type == CardType.Queen && p.Suit == card.Suit))
                        || (card.Type == CardType.Queen && !this.playedCards.Any(p => p.Type == CardType.King && p.Suit == card.Suit)))
                    {
                        continue;
                    }

                    cardToPlay = card;
                }
            }

            if (cardToPlay == null || !this.Cards.Contains(cardToPlay))
            {
                cardToPlay = this.Cards.First();
            }

            return this.PlayCard(cardToPlay);
        }
开发者ID:KingSharkPower,项目名称:MyFirstAndOnlyRepository,代码行数:63,代码来源:SmartPlayer.cs


注:本文中的Santase.Logic.Cards.Card.GetValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。