Esempio n. 1
0
        internal static PlayerMove PlayBestScoredMoveUpToLimitConsideringCommunication(
            IReadOnlyCollection <int> cardsInHand, PlayerInformation info)
        {
            var spm   = new ScorePlayerPlays();
            var plays = spm.GetScoredPlays(cardsInHand, info.RowsOfCards);

            if (plays.Count == 0)
            {
                return(new PlayerMove(PlayerMoveDecision.Undecided));
            }

            ConsiderCommunication(info, plays);

            var bestMove = PlayerRulesUtils.GetBestMoveFromPlays(plays);

            if (bestMove.score <= MaxDistanceForSingleScoredMoveWithCommunicationAndTwoCardsToPlay &&
                info.CardsToPlayThisTurn == 2 ||
                bestMove.score <= MaxDistanceForSingleScoredMoveWithCommunicationAndOneCardToPlay &&
                info.CardsToPlayThisTurn == 1)
            {
                return(new PlayerMove(PlayerMoveDecision.WantToPlay, bestMove.placements[0]));
            }

            return(new PlayerMove(PlayerMoveDecision.Undecided));
        }
        internal static PlayerStartDecision MakeStartDecision(IReadOnlyCollection <int> cardsInHand, int startingRound)
        {
            var spm         = new ScorePlayerPlays();
            var rowsAtStart = new Dictionary <RowOfCardsIdentifier, RowOfCards>
            {
                { RowOfCardsIdentifier.FirstRowUp, new RowOfCards(RowOfCardsType.Up) },
                { RowOfCardsIdentifier.SecondRowUp, new RowOfCards(RowOfCardsType.Up) },
                { RowOfCardsIdentifier.FirstRowDown, new RowOfCards(RowOfCardsType.Down) },
                { RowOfCardsIdentifier.SecondRowDown, new RowOfCards(RowOfCardsType.Down) }
            };

            var possibleStartingPlays = spm.GetScoredPlays(cardsInHand, rowsAtStart).Where(x => x.placements.Count > 1);

            var bestScore = !possibleStartingPlays.Any()
                                ? 999
                                : PlayerRulesUtils.GetBestMoveFromPlays(spm.GetScoredPlays(cardsInHand, rowsAtStart)
                                                                        .Where(x => x.placements.Count > 1)).score;

            return((bestScore, startingRound) switch
            {
                (< 13, _) => PlayerStartDecision.WantToStart,
                (< 20, 2) => PlayerStartDecision.WantToStart,
                (< 20, _) => PlayerStartDecision.CouldStart,
                (_, < 3) => PlayerStartDecision.DoNotWantToStart,
                (_, _) => PlayerStartDecision.WantToStart
            });
Esempio n. 3
0
        internal static PlayerMove PlayBestScoredMove(IReadOnlyCollection <int> cardsInHand, PlayerInformation info)
        {
            var spm   = new ScorePlayerPlays();
            var plays = spm.GetScoredPlays(cardsInHand, info.RowsOfCards);

            if (plays.Count == 0)
            {
                return(new PlayerMove(PlayerMoveDecision.Undecided));
            }

            var bestMove = PlayerRulesUtils.GetBestMoveFromPlays(plays);

            return(new PlayerMove(PlayerMoveDecision.WantToPlay, bestMove.placements[0]));
        }