コード例 #1
0
        public void TestCardCombo()
        {
            PokerPlayer pl1    = new FakePokerPlayer();
            PokerPlayer pl2    = new FakePokerPlayer();
            ICardDealer dealer = new DefaultCardDealer();

            dealer.ShuffleAndDealDeck(pl1, pl2);
            List <OrderedCardSet> p1PossHands = HoldemHand.GetOpponentCombinationOfHandCards(dealer.FullDeck, pl2.HandCards, dealer.CommunityCards);
            List <OrderedCardSet> p2PossHands = HoldemHand.GetOpponentCombinationOfHandCards(dealer.FullDeck, pl1.HandCards, dealer.CommunityCards);

            List <PlayingCard> totalCards = new List <PlayingCard>();

            totalCards.AddRange(pl1.HandCards);
            totalCards.AddRange(dealer.CommunityCards);
            Assert.AreEqual(7, totalCards.Count);

            int len   = 7;
            int count = 0;

            for (int t1 = 0; t1 < len; t1 += 1)
            {
                for (int t2 = t1 + 1; t2 < len; t2 += 1)
                {
                    for (int t3 = t2 + 1; t3 < len; t3 += 1)
                    {
                        for (int t4 = t3 + 1; t4 < len; t4 += 1)
                        {
                            for (int t5 = t4 + 1; t5 < len; t5 += 1)
                            {
                                count += 1;
                            }
                        }
                    }
                }
            }

            Assert.AreEqual(21, count);

            List <OrderedCardSet> p1PokerHands = HoldemHand.GetCombinationOfPokerHands(pl1.HandCards, dealer.CommunityCards);
            List <OrderedCardSet> p2PokerHands = HoldemHand.GetCombinationOfPokerHands(pl2.HandCards, dealer.CommunityCards);

            Assert.AreEqual(990, p1PossHands.Count);
            Assert.AreEqual(990, p2PossHands.Count);
            Assert.AreEqual(21, p1PokerHands.Count);
            Assert.AreEqual(21, p2PokerHands.Count);

            pl1.Hand = HoldemHand.ChooseBestHand(pl1.HandCards, dealer.CommunityCards);
            pl2.Hand = HoldemHand.ChooseBestHand(pl2.HandCards, dealer.CommunityCards);

            //  OrderedCardSet set = CardChances.GetOtherCards(dealer.FullDeck, pl2.HandCards, dealer.CommunityCards);

            HoldemHand.HandPlayResult result = HoldemHand.TestHandChances(pl1.Hand, pl1.HandCards, dealer);

            Assert.AreEqual(990, result.Wins + result.Losses + result.Ties);
        }
コード例 #2
0
        private void writePlayerChances(HoldemHand.HandPlayResult results)
        {
            double total         = (double)results.Wins + (double)results.Losses + (double)results.Ties;
            double winChances    = results.Wins / total;
            double tiesChances   = results.Ties / total;
            double lossesChances = results.Losses / total;

            PlayerChancesLoseLabel.Content = $"Player Lose: %{lossesChances* 100 :F1}";
            PlayerChancesWinLabel.Content  = $"Player Win: %{winChances * 100:F1}";
            PlayerChancesTieLabel.Content  = $"Player Tie: %{tiesChances * 100:F1}";
        }
コード例 #3
0
        private void writeCpuChances(HoldemHand.HandPlayResult results)
        {
            double total         = (double)results.Wins + (double)results.Losses + (double)results.Ties;
            double winChances    = results.Wins / total;
            double tiesChances   = results.Ties / total;
            double lossesChances = results.Losses / total;

            OpChancesLoseLabel.Content    = $"CPU Lose: %{lossesChances * 100:F1}";
            OpChancesWinLabel.Content     = $"CPU Win: %{winChances * 100:F1}";
            OpChancesTieLabel.Content     = $"CPU Tie: %{tiesChances * 100:F1}";
            OpChancesLoseLabel.Visibility = Visibility.Visible;
            OpChancesWinLabel.Visibility  = Visibility.Visible;
            OpChancesTieLabel.Visibility  = Visibility.Visible;
        }
コード例 #4
0
 public void NotifyOnTurn(int id)
 {
     if (game.Stage == PokerGame.GameStage.OPPONENT_TURN)
     {
         HoldemHand.HandPlayResult result = HandChances;
         if (result.Wins * 2 > result.SampleCount)
         {
             RaiseHand();
         }
         else
         {
             FoldHand();
         }
     }
 }