Open Side Menu Go to the Top
Register
Programatically determine winning hand in Hold Em Programatically determine winning hand in Hold Em

07-20-2009 , 10:00 AM
Been searching for info on this, but can't seem to find any. I'm sure someone knows the answer to this though....

I have put together a very rough web based heads up poker client using ASP (vbscript) and SQL backend. I generate a random sequence of the numbers 1 to 52 and write out those numbers to SQL in order of cards dealt, the ASP page then converts that number to a text card (eg. Ac), and play is very primitive, bets/calls/folds are all made, another table in SQL keeps track of current bets, what stage the hand is at, whose turn it is to act, and only that player gets to see the betting functions. The web pages refresh every 10 seconds and if the other player has acted the page will update accordingly. Its primitive and slow, but it works. I only have one problem. At a showdown, I have no way of determining winning hand so we are presented with a Win / lose button, and the winner hits win. Of course there is so much room for human error but as we're just playing for fun at work (keep the client as discrete as possible) we're not too fussed,but I would like to know how to get the logic into this for scoring the hands.

Am I right in thinking I need to make 21 hands and test all those (the possible 5 card combinations from 7?) or is there a simpler method, perhaps starting at the topand working down would be easier (ie. checking for a royal flush shouldn't be too hard, I'm not sure how I can arrange an array in order, but I imagine as my cards are really just numbers, i could check back one card at a time and if the total of the difference of five cards if 5, then we have a straight flush... I have always had the ace as card 1..maybe I should make it card 13 so if the above statement is true, and the fifth card / 13 is an integer, then we have a royal flush....

I am not really a programmer I just managed to fudge this web client together using some dreamweaver functions and other bits of code I know....if the above makes sense to anyone and they can enlighten me, please let it be known!
Programatically determine winning hand in Hold Em Quote
07-20-2009 , 02:32 PM
This project might give you some ideas:
http://www.codeproject.com/KB/cs/pok...otchallan.aspx
(maybe you need an account to read the article.)

But basically it iterate through all possible combinations of the cards and map the hand strength in to a 32bit integer, which makes it very easy to compare different hands.
Programatically determine winning hand in Hold Em Quote
07-22-2009 , 11:39 AM
Thanks, certainly some ideas in there, need to give it a decent read one weekend. Being in C I may run into some problems with not having equivilent functions in VB..... anyone work primarly in VB and been able to solve this? Does anyoe know the likes of pokernews odds calculator works? As it flashed base, is there any freesource code (actionscript) for determining a winning hand?
Programatically determine winning hand in Hold Em Quote

      
m