Poker-AI.org Poker AI and Botting Discussion Forum 2014-09-29T17:03:25+00:00 http://poker-ai.org/phpbb/feed.php?f=22&t=2812 2014-09-29T17:03:25+00:00 2014-09-29T17:03:25+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6331#p6331 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> shalako wrote:

Another way to do this quickly is use Timmys evaluator that is available in the archives somewhere. It has a hand state function in which you can just pass the board and your hand and it will tell you if you have a str8 or not. I have used this on all my bots and it works pretty well.



I like writing everything myself, but I think it would be good to incorporate something like this as a way to test the accuracy of it. I'm definitely going to check it out, thank you.

Statistics: Posted by Watts — Mon Sep 29, 2014 5:03 pm


]]>
2014-09-29T17:02:19+00:00 2014-09-29T17:02:19+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6330#p6330 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> algonoob wrote:

see if it works for this case: {2,2,3,4,4,5,6}
a way to solve it is remove duplicates before processing



Wow, thank you! That appears to be the problem! It's detecting that pattern as a two pair. Thank you for the suggestion, and great catch!! :D

Statistics: Posted by Watts — Mon Sep 29, 2014 5:02 pm


]]>
2014-09-29T16:57:40+00:00 2014-09-29T16:57:40+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6329#p6329 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> Statistics: Posted by shalako — Mon Sep 29, 2014 4:57 pm


]]>
2014-09-27T21:50:23+00:00 2014-09-27T21:50:23+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6319#p6319 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> a way to solve it is remove duplicates before processing

Statistics: Posted by algonoob — Sat Sep 27, 2014 9:50 pm


]]>
2014-09-26T06:14:52+00:00 2014-09-26T06:14:52+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6317#p6317 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> http://poker-ai.org/archive/www.pokerai ... ?f=3&t=353 or http://www.codeproject.com/Articles/122 ... d-Analysis

Statistics: Posted by spears — Fri Sep 26, 2014 6:14 am


]]>
2014-09-26T01:47:52+00:00 2014-09-26T01:47:52+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6316#p6316 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> Statistics: Posted by Watts — Fri Sep 26, 2014 1:47 am


]]>
2014-09-26T00:12:07+00:00 2014-09-26T00:12:07+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6315#p6315 <![CDATA[Re: I have a bug detecting a straight but I can't find it. H]]> Statistics: Posted by proud2bBot — Fri Sep 26, 2014 12:12 am


]]>
2014-09-25T23:50:13+00:00 2014-09-25T23:50:13+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2812&p=6314#p6314 <![CDATA[I have a bug detecting a straight but I can't find it. Help?]]>
I've verified that the wheel is detected, so I don't think it's that. But who knows. The code is in C#, and I would really appreciate it if someone could look through it and let me know if they see anything wrong, or if there are better ways to do it. Thanks!

The general idea is that I sort the cards in ascending order by value, then I count sequential orders up to 5. Values are from 0 - 12, 12 being an ace. Here's the code:

Code:
        static bool isStraight(List<Card> cards, out List<Card> bestHand)
        {
            bestHand = null;
            int straightCount = 1,
                lastIndex = -1;
            bool isWheel = false;
            var sorted = (from x in cards orderby x.Value ascending select x).ToList();
            for (int i = 0; i < sorted.Count; i++)
            {
                Card card = sorted[i];
                if (i > 0) // Skip first card because we're starting straight count at 1 already
                {
                    if (card.Value == sorted[i - 1].Value + 1) // Check the previous card to see if we add 1 to it, it matches the current value
                    {
                        if (++straightCount >= 5)
                        {
                            lastIndex = i;
                        }
                    }
                    else
                    {
                        straightCount = 1;
                    }
                }
                if (straightCount == 5)
                {
                    break;
                }
            }
            // Check for wheel
            if (straightCount < 5)
            {
                if (sorted.Last().Value == 12)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        Card card = sorted[i];
                        if (i == 0)
                        {
                            if (card.Value == 0)
                            {
                                if (++straightCount >= 5)
                                {
                                    lastIndex = i;
                                }
                            }
                        }
                        else if (card.Value == sorted[i - 1].Value + 1)
                        {
                            if (++straightCount >= 5)
                            {
                                lastIndex = i;
                            }
                        }
                        else
                        {
                            straightCount = 1;
                        }
                    }
                    if (straightCount >= 5) { isWheel = true; }
                }
            }
            bool result = straightCount >= 5;
            if (result)
            {
                bestHand = new List<Card>();
                if (isWheel)
                {
                    bestHand.Add(cards.Where(x => x.Value == 12).First()); // add the ace
                    bestHand.AddRange(sorted.GetRange(lastIndex - 3, 4));
                }
                else
                {
                    bestHand.AddRange(sorted.GetRange(lastIndex - 4, 5));
                }
            }
            return result;
        }

Statistics: Posted by Watts — Thu Sep 25, 2014 11:50 pm


]]>