Beispiel #1
0
        private PkResult PkV2(HoldingHoles heroHoles, PlayerRangePkGrid villainGrid, List <Card> fullBoard)
        {
            var      pkResult = new PkResult();
            SuitEnum suit;
            int      suitedCount;
            var      boardSuited = FullBoardHasThreeSuitedCards(fullBoard, out suit, out suitedCount);

            IHand bestHeroHand = boardSuited ? FindBestHand(heroHoles, fullBoard, suit) : FindBestOffsuitHand(heroHoles, fullBoard);

            foreach (var villainHoles in _holesEnumerator(villainGrid))
            {
                IHand bestVillainHand = boardSuited
                    ? FindBestHand(villainHoles, fullBoard, suit)
                    : FindBestOffsuitHand(villainHoles, fullBoard);

                var pk = bestHeroHand.CompareTo(bestVillainHand);
                if (pk == 0)
                {
                    pkResult.TiedScenariosCount++;
                }
                else if (pk < 0)
                {
                    pkResult.VillainWinScenariosCount++;
                }
                else if (pk > 0)
                {
                    pkResult.HeroWinScenariosCount++;
                }
            }

            return(pkResult);
        }
Beispiel #2
0
        /// <summary>
        /// BlackjackWinChecker, checks for the win condition
        /// </summary>



        /// <summary>
        /// Check if the hand total equals a win condition
        /// </summary>
        /// <param name="hand1">The Dealer hand</param>
        /// <param name="hand2">The HumanPlayer hand</param>
        /// <returns></returns>
        public WinState IsWin(IHand hand1, IHand hand2)
        {
            //Compare the total values for win,draw or lose condition
            if (hand2.CompareTo(hand1) > 0)
            {
                WinState = WinState.win;
            }
            else if (hand2.CompareTo(hand1) == 0)
            {
                WinState = WinState.draw;
            }
            else
            {
                WinState = WinState.lose;
            }

            return(WinState);
        }
Beispiel #3
0
        private PkResult PkHeroHandWithOffsuitHand(IHand heroBestHand,
                                                   PlayerRangePkGrid villainGrid, IHand villainOffsuitHand)
        {
            int pk = heroBestHand.CompareTo(villainOffsuitHand);

            if (pk > 0)
            {
                return(new PkResult(villainGrid.Grid.AvailableRankCombCount, 0, 0, 0));
            }
            else if (pk == 0)
            {
                return(new PkResult(0, 0, villainGrid.Grid.AvailableRankCombCount, 0));
            }
            else
            {
                return(new PkResult(0, villainGrid.Grid.AvailableRankCombCount, 0, 0));
            }
        }
Beispiel #4
0
        private PkResult PkHeroHandOnSuitedBoard(IHand heroBestHand,
                                                 PlayerRangePkGrid villainGrid, List <Card> fullBoard, SuitEnum suit)
        {
            var villainOffsuitRanks = fullBoard.Select(c => c.Rank).ToList();

            villainOffsuitRanks.Add(villainGrid.Grid.HighRank);
            villainOffsuitRanks.Add(villainGrid.Grid.LowRank);
            var villainOffsuitHand = _offsuitHandFinder.FindBestHand(villainOffsuitRanks);
            var pkResult           = PkHeroHandWithOffsuitHand(heroBestHand, villainGrid, villainOffsuitHand);

            if (pkResult.HeroWinScenariosCount == 0 && pkResult.TiedScenariosCount == 0 &&
                pkResult.TiedScenariosCount == 0)
            {
                //villain already won, no need to compare anymore
                return(pkResult);
            }

            bool tied = pkResult.TiedScenariosCount != 0;

            foreach (var villainSuitedHand in FindBetterSuitedHandsFromOffsuitGrid(villainGrid, villainOffsuitHand, fullBoard, suit))
            {
                var pk = heroBestHand.CompareTo(villainSuitedHand);

                if (pk == 0)
                {
                    pkResult.TiedScenariosCount++;
                }
                else if (pk < 0)
                {
                    pkResult.VillainWinScenariosCount++;
                }

                if (tied)
                {
                    pkResult.TiedScenariosCount--;
                }
                else
                {
                    pkResult.HeroWinScenariosCount--;
                }
            }

            return(pkResult);
        }