On 6/27/07, Ryan A <genphp@xxxxxxxxx> wrote: <...>
Tijnema, thanks for giving it a go... Sorry it didnt compile,with my limited (and old) rusty knowledge of java 1.1 i couldnt make out too much and i dont have any java server to run this on to check it. I pretty much left Java years back once i started using php.... I used to use servlets and JSPs back then. Actually, I'm only interested in the logic... it does present quite a challenge to find out the best hand (and second best etc) from 2 hole cards (into x players) and 5 community cards. I did create a little script to deal the cards (http://webbmatte.se/cards.php if you would like to see the code just tell me) next i would just like to print out which is the strongest etc. Any ideas or suggestions are most welcome. Thanks! R
Well, I find this a very interesting thing ;) I have played quite a lot poker, and I still play it sometimes, and this doesn't seems too hard for me :) My approach would be this: 1) Deal cards, rand(1,13) for the numbers(1-> Ace, 11->Jack, 12->Queen, 13->King), and rand (1,4) for color(1-> spades, 2-> clubs, 3-> diamonds, 4->hearts) 2) Betting, with some buttons and AJAX to update pot etc. 3) Turn 4) Step 2 5) River 6) Step 2 7) Looping through all players and check what their highest combination is, take the 2 best combinations, and see if they are equal.If not, the highest wins of course, but if they are equal, check if number 3 has also same combination, and if so, check number 4, ... Now you have some players with same combination, and you need to sort the guys by highest cards in combination. If one has higher cards than all others, he won. If not, get only those guys that have the same highest cards in the combination, and check those guys for their kicker (only for Pair, Two pair, Three of a Kind, Four of a Kind). If their kicker is equal, or there combination isn't the one I noted, it's a split pot :) Not too hard to program right? Tijnema -- Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php