コード例 #1
0
        [TestCase(new[] { "A Clubs", "K Clubs", "Q Clubs", "J Clubs", "10 Clubs", "2 Spades", "3 Spades" }, 9)]      // straight flush
        public void Rank_MultipleDataSets(string[] cardStrings, int value)
        {
            var cards    = GetCards(cardStrings);
            var analyzer = new HandAnalyzer();

            Assert.AreEqual(value, analyzer.Analyze(cards, new List <Card>()));
        }
コード例 #2
0
        internal static IEnumerable <EquityRangeSelectorItemViewModel> GetHeroRange(HandHistories.Objects.Hand.HandHistory currentHandHistory, HandHistories.Objects.Cards.Street currentStreet)
        {
            if (currentHandHistory.Hero == null)
            {
                return(null);
            }

            if (init)
            {
                TempConfig.Init();
                HandHistory.Init();
                Card.Init();
                init = false;
            }

            var handAnalyzer = new HandAnalyzer();

            var handHistory = new HandHistory();

            handHistory.ConverToEquityCalculatorFormat(currentHandHistory, currentStreet);

            var heroRange = handAnalyzer.BuildPlayerRange(handHistory, currentHandHistory.Hero.PlayerName);

            return(GroupHands(heroRange));
        }
コード例 #3
0
        public void IsStraight_MultipleDataSets(string[] cardRanks, bool isFlush)
        {
            var analyzer = new HandAnalyzer();
            var cards    = GetCards(cardRanks);

            Assert.AreEqual(isFlush, analyzer.IsStraight(cards));
        }
コード例 #4
0
    public void DrawCards()
    {
        deal = false;
        SetDrawDeal();
        handHandler.ReplaceCards(deck);
        HandType handType = HandAnalyzer.Hand(deck.Hand);

        Bets.PayOffs(handType);
        betsUI.UpdateCredits();
        handHandler.SetHandDisplay(handType);
        ResetGame();
    }
コード例 #5
0
ファイル: HandAnalyzerTests.cs プロジェクト: jdd817/VPSim
 public HandAnalyzerTests()
 {
     _analyzer = new HandAnalyzer(new IHandChecker[]
     {
         new HighCardChecker(),
         new PairChecker(),
         new TwoPairChecker(),
         new ThreeOfAKindChecker(),
         new StraitChecker(),
         new FlushChecker(),
         new FullHouseChecker(),
         new FourOfAKindChecker(),
         new StraitFlushChecker()
     });
 }
コード例 #6
0
        internal static void GetStrongestOpponent(HandHistories.Objects.Hand.HandHistory currentHandHistory, HandHistories.Objects.Cards.Street currentStreet, out string strongestOpponentName, out IEnumerable <EquityRangeSelectorItemViewModel> strongestOpponentHands)
        {
            strongestOpponentName  = null;
            strongestOpponentHands = new List <EquityRangeSelectorItemViewModel>();

            if (init)
            {
                TempConfig.Init();
                HandHistory.Init();
                Card.Init();
                init = false;
            }

            var handAnalyzer = new HandAnalyzer();

            var handHistory = new HandHistory();

            handHistory.ConverToEquityCalculatorFormat(currentHandHistory, currentStreet);

            // analyze preflop ranges
            var hand_range = handAnalyzer.PreflopAnalysis(handHistory);

            var hand_collective = new Hashtable();

            foreach (string key in hand_range.Keys)
            {
                var hand_distribution = new hand_distribution
                {
                    hand_range = (float)Convert.ToDouble(hand_range[key])
                };

                hand_collective.Add(key, hand_distribution);
            }

            if (currentStreet != HandHistories.Objects.Cards.Street.Preflop)
            {
                var street = currentStreet == HandHistories.Objects.Cards.Street.Flop ? 1 :
                             currentStreet == HandHistories.Objects.Cards.Street.Turn ? 2 : 3;

                hand_collective = handAnalyzer.PostflopAnalysis(handHistory, street, hand_collective);
            }

            strongestOpponentHands = GroupHands(handAnalyzer.StrongestOpponentHands);
            strongestOpponentName  = handAnalyzer.StrongestOpponentName;
        }
コード例 #7
0
        public DDBP9898PayoutTests()
        {
            var handAnalyzer = new HandAnalyzer(new IHandChecker[]
            {
                new HighCardChecker(),
                new PairChecker(),
                new TwoPairChecker(),
                new ThreeOfAKindChecker(),
                new StraitChecker(),
                new FlushChecker(),
                new FullHouseChecker(),
                new FourOfAKindChecker(),
                new StraitFlushChecker()
            });

            _payoutCalc = new VideoPokerPayoutCalculator(handAnalyzer);

            _payTable = StandardPayTables.DDB_9898;
        }
コード例 #8
0
    public void DrawCards()
    {
        deal = false;
        for (int i = 0; i < handUI.Length; i++)
        {
            if (handUI[i].hold.enabled == false)
            {
                deck.DiscardCard(handUI[i].card);
                Card card = deck.Draw();
                ChangeCardUI(i, card);
            }
        }
        SetDrawDeal();
        HandType handType = HandAnalyzer.Hand(deck.Hand);

        Bets.PayOffs(handType);
        betsUI.UpdateCredits();
        ResetGame();
    }
コード例 #9
0
        public void BluffToValueTests()
        {
            var board  = "QsAd6d";
            var ranges = new[] { "77", "88", "99", "TT", "JJ", "QQ", "KK", "AA", "A2s", "A3s", "A4s", "A5s", "A6s", "A7s", "A8s", "A9s", "ATs", "AJs", "AQs", "AKs", "K7s", "K8s", "K9s", "KTs", "KJs", "KQs", "Q7s", "Q8s", "Q9s", "QTs", "QJs", "J8s", "J9s", "JTs", "T8s", "T9s", "97s", "98s", "86s", "87s", "76s", "A2o", "A3o", "A4o", "A5o", "A6o", "A7o", "A8o", "A9o", "ATo", "AJo", "AQo", "AKo", "K9o", "KTo", "KJo", "KQo", "QTo", "QJo", "JTo", "T8o", "T9o", "97o", "98o", "86o", "87o", "76o" };

            var handHistory = new HandHistory();

            handHistory.CommunityCards[1] = board;

            var rangeItems = (from range in ranges
                              select new RangeItem
            {
                Caption = range,
                Cards = (from ungroupedHand in HandAnalyzer.UngroupHands(new List <string> {
                    range
                }, handHistory, true)
                         select new RangeItemCard {
                    Caption = ungroupedHand
                }).ToArray()
            }).ToArray();

            var boardCard1 = board.Substring(0, 2);
            var boardCard2 = board.Substring(2, 2);
            var boardCard3 = board.Substring(4, 2);

            var fBoardCard1 = HandHistory.fastCard(boardCard1[0], boardCard1[1]);
            var fBoardCard2 = HandHistory.fastCard(boardCard2[0], boardCard2[1]);
            var fBoardCard3 = HandHistory.fastCard(boardCard3[0], boardCard3[1]);

            var counter = 0;

            // all possible cases
            foreach (var rangeItem in rangeItems)
            {
                foreach (var holeCards in rangeItem.Cards)
                {
                    var holeCard1 = holeCards.Caption.Substring(0, 2);
                    var holeCard2 = holeCards.Caption.Substring(2, 2);

                    var fHoleCard1 = HandHistory.fastCard(holeCard1[0], holeCard1[1]);
                    var fHoleCard2 = HandHistory.fastCard(holeCard2[0], holeCard2[1]);

                    var usedCards = new[] { fBoardCard1, fBoardCard2, fBoardCard3, fHoleCard1, fHoleCard2 };

                    for (var i = 0; i < 52; i++)
                    {
                        var boardCard4 = HandHistory.fastCard(Analyzer.Card.CardName[i], Analyzer.Card.CardSuit[i]);

                        if (usedCards.Contains(boardCard4))
                        {
                            continue;
                        }

                        for (var j = i + 1; j < 52; j++)
                        {
                            var boardCard5 = HandHistory.fastCard(Analyzer.Card.CardName[j], Analyzer.Card.CardSuit[j]);

                            if (usedCards.Contains(boardCard5))
                            {
                                continue;
                            }

                            var weight = FastEvaluator.eval_7hand(usedCards.Concat(new[] { boardCard4, boardCard5 }).ToArray());

                            holeCards.Weights.Add(weight);

                            counter++;
                        }
                    }
                }
            }

            var comparer = new RangeItemComparer();

            //var rangeItem1 = rangeItems.FirstOrDefault(x => x.Caption == "AA");
            //var rangeItem2 = rangeItems.FirstOrDefault(x => x.Caption == "KK");

            //Assert.That(comparer.Compare(rangeItem1, rangeItem2), Is.EqualTo(1));

            //var arr = new ArrayList(rangeItems);
            //arr.Sort(comparer);

            Array.Sort(rangeItems, comparer);

            //rangeItems = rangeItems.OrderByDescending(x => x, comparer).ToArray();

            Debug.WriteLine($"Combos: {rangeItems.Sum(x => x.Cards.Length)}");
            Debug.WriteLine($"Simulations: {counter}");
            Debug.WriteLine($"Ordered range: {string.Join(", ", rangeItems.Reverse().Select(x => x.Caption).ToArray())}");
        }
コード例 #10
0
        internal static Dictionary <MadeHandType, int> GetCombosByHandType(IEnumerable <string> range, string boardCards)
        {
            var result = new Dictionary <MadeHandType, int>();

            if (!range.Any() || string.IsNullOrEmpty(boardCards))
            {
                return(result);
            }

            void AddResult(MadeHandType handType)
            {
                if (!result.ContainsKey(handType))
                {
                    result.Add(handType, 1);
                    return;
                }

                result[handType]++;
            }

            var ungroupedHands = HandAnalyzer.UngroupHands(range, boardCards, null);

            var boardCard1 = boardCards.Length >= 2 ? boardCards.Substring(0, 2) : null;
            var boardCard2 = boardCards.Length >= 4 ? boardCards.Substring(2, 2) : null;
            var boardCard3 = boardCards.Length >= 6 ? boardCards.Substring(4, 2) : null;
            var boardCard4 = boardCards.Length >= 8 ? boardCards.Substring(6, 2) : null;
            var boardCard5 = boardCards.Length >= 10 ? boardCards.Substring(8, 2) : null;

            // flop cards in binary format
            var fBoardCard1 = boardCard1 != null?HandHistory.fastCard(boardCard1[0], boardCard1[1]) : 0;

            var fBoardCard2 = boardCard2 != null?HandHistory.fastCard(boardCard2[0], boardCard2[1]) : 0;

            var fBoardCard3 = boardCard3 != null?HandHistory.fastCard(boardCard3[0], boardCard3[1]) : 0;

            var fBoardCard4 = boardCard4 != null?HandHistory.fastCard(boardCard4[0], boardCard4[1]) : 0;

            var fBoardCard5 = boardCard5 != null?HandHistory.fastCard(boardCard5[0], boardCard5[1]) : 0;

            var board = new[] { fBoardCard1, fBoardCard2, fBoardCard3, fBoardCard4, fBoardCard5 };

            foreach (var holeCards in ungroupedHands)
            {
                var holeCard1 = holeCards.Substring(0, 2);
                var holeCard2 = holeCards.Substring(2, 2);

                var fHoleCard1 = HandHistory.fastCard(holeCard1[0], holeCard1[1]);
                var fHoleCard2 = HandHistory.fastCard(holeCard2[0], holeCard2[1]);

                if (board.Any(x => x == fHoleCard1 || x == fHoleCard2))
                {
                    continue;
                }

                var boardInfo = Jacob.AnalyzeHand(boardCard1, boardCard2, boardCard3, boardCard4, boardCard5, holeCard1, holeCard2);

                var handType = GetHandType(holeCard1, holeCard2, boardInfo, boardCards);

                if (handType == MadeHandType.NoPair)
                {
                    var added = false;

                    if (boardInfo.ifflushdraw)
                    {
                        AddResult(MadeHandType.FlushDraw);
                        added = true;
                    }

                    if (boardInfo.ifstraightdraw)
                    {
                        AddResult(MadeHandType.StraightDraw);
                        added = true;
                    }

                    if (added)
                    {
                        continue;
                    }
                }

                AddResult(handType);
            }

            return(result);
        }