public void CreateFromHeadsUpOmaha_Speed_IsDoable()
        {
            var stopwatch = new Stopwatch();

            var runs = 10000;
            var rnd  = new Random(17);

            for (int i = 0; i < runs; i++)
            {
                var deck  = Cards.GetShuffledDeck(rnd);
                var hand  = deck.Take(4).ToList();
                var table = deck.Skip(4).Take(rnd.Next(3, 6)).ToList();

                stopwatch.Start();
                var score = PokerHand.CreateFromHeadsUpOmaha(table, hand);
                stopwatch.Stop();

                if (score.ScoreType > PokerHandType.FullHouse)
                {
                    Console.WriteLine(score);
                }
            }

            Console.WriteLine("Avarage: {0:#,##0.000.00} Ticks/hand", (double)stopwatch.ElapsedTicks / (double)runs);
        }
        private void SendResult(Dictionary <PlayerType, ConsoleBot> bots, GameState state, int pot, LastGameAction lastaction)
        {
            if (lastaction.Action != GameAction.Fold)
            {
                var hand1   = PokerHand.CreateFromHeadsUpOmaha(state.Table, state.Player1.Hand);
                var hand2   = PokerHand.CreateFromHeadsUpOmaha(state.Table, state.Player2.Hand);
                var compare = PokerHandComparer.Instance.Compare(hand1, hand2);

                if (compare > 0)
                {
                    state.Result = RoundResult.Player1Wins;
                }
                else if (compare < 0)
                {
                    state.Result = RoundResult.Player2Wins;
                }
                else
                {
                    state.Result = RoundResult.Draw;
                }
            }
            else
            {
                state.Result = lastaction.Player == PlayerType.player1 ? RoundResult.Player2Wins : RoundResult.Player1Wins;
            }

            foreach (var kvp in bots)
            {
                kvp.Value.Result(state.Personalize(kvp.Key), pot, lastaction);
            }
        }
Exemple #3
0
        public void CreateFromHeadsUpOmaha_Speed_IsDoable()
        {
            var stopwatch = new Stopwatch();

            var runs = 10000;
            var rnd  = new MT19937Generator(17);

            for (int i = 0; i < runs; i++)
            {
                var deck  = Cards.GetShuffledDeck(rnd);
                var hand  = deck.Take(4).ToList();
                var table = deck.Skip(4).Take(5).ToList();

                stopwatch.Start();
                var score = PokerHand.CreateFromHeadsUpOmaha(table, hand);
                stopwatch.Stop();
            }

            Console.WriteLine("Avarage: {0:#,##0.000.00} ms/hand", (double)stopwatch.ElapsedMilliseconds / (double)runs);
        }