Re: [PHP] PHP P O K E R...... and JAVA (convert)
Thanks! Dont know if it will help but its nice of you to share becausei always feel good reading someone elses ways of doing things. Might help if I get bogged down somewhere. Cheers! R Guillaume Theoret [EMAIL PROTECTED] wrote: This isn't exactly what was asked for but when I TA'd the principles of programming languages course, an assignment I gave was to write a simple poker game in Haskell. If anyone's interested here's the sample solution I gave: http://smokinn.tengun.net/comp348/poker.hs It's all console based of course. You'll need either ghc or hugs installed to run it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - It's here! Your new message! Get new email alerts with the free Yahoo! Toolbar.
Re: [PHP] PHP P O K E R...... and JAVA (convert)
Hey Nathan, Cool! Thanks for taking the time to find and fix that error and your suggestions below... Will give you a buzz if I run into a programming stonewall. Cheers! R Nathan Nobbe [EMAIL PROTECTED] wrote: Ryan, if you want to port the java code to php it wouldnt be very difficult since this code doesnt rely heavily on much besides core language constructs. really you could just save it as a php file and start making changes where needed; it wouldnt take too long to port. as for the compilation issue i took a look at this myself and discovered some broken logic in the flush method. for (int i=0; i= 0 sorted[i] = 12) suitA++; else if (sorted[i] = 13 sorted[i] = 25) suit i converted this to for (int i=0; i fv.length; i++) { if(i = 0 sorted[i] = 12) suitA++; though im not sure if that is correct (spent about 5 minutes on it) a quick guess tells me it should be. The HandRanker class is dependent upon another proprietary class HandRankwhich is burried in a link (not in blue text) on the page you provided us. There are actually links in the statement. This HandRanker class is used to calculate the rank of a poker hand. It uses the HandRank class to store the rank of the poker hand. So if you just make 2 files HandRanker.java HandRank.java Place the respective class definitions in those files (put them in the same directory for simplicity). Apply the patch i provided above to HandRanker.java (lines 123, 124) then issue (at command prompt) javac HandRanker.java and you should have the compiled code :) -nathan On 6/27/07, Tijnema wrote: On 6/27/07, Stephen wrote: Tijnema wrote: 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 You need to add logic to ensure that the same card is not dealt twice! An initial routine to shuffle the deck is the approach that I would take. Stephen Yes, I fixed that in a second reply ;) 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 -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.
Re: [PHP] PHP P O K E R...... and JAVA (convert)
So you expect PHP ppl to do your job and test a JAVA class to tell u if it's worth porting it to php? Nice thoughts... Andy Ryan A wrote: Hey all! Was looking at trying some stuff with php and p oker (texas hold'em). After searching the net for some clues as to how i can do this, i came accross the class on the php classes site (but that codes to bruteforce-ish) so continued looking and came accross some valuable suggestions on how to do this... just as i was about to start i found a dude who wrote something like this in Java... which works pretty good according to him (tried and well tested to quote him) Can someone with a java background mind testing his class? and then hopefully help me convert his script to php? The address to his java class: http://www.greenbridge.net/index.php/p_handranker.php What do you think? Comments, suggestions and links are most welcome! Cheers! R -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Expecting? Get great news right away with email Auto-Check. Try the Yahoo! Mail Beta. . -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP P O K E R...... and JAVA (convert)
On 6/27/07, Ryan A [EMAIL PROTECTED] wrote: Hey all! Was looking at trying some stuff with php and p oker (texas hold'em). After searching the net for some clues as to how i can do this, i came accross the class on the php classes site (but that codes to bruteforce-ish) so continued looking and came accross some valuable suggestions on how to do this... just as i was about to start i found a dude who wrote something like this in Java... which works pretty good according to him (tried and well tested to quote him) Can someone with a java background mind testing his class? and then hopefully help me convert his script to php? The address to his java class: http://www.greenbridge.net/index.php/p_handranker.php What do you think? Comments, suggestions and links are most welcome! Cheers! R Well, first of all, I tried to compile the Java code you gave on my linux box with JDK-1.5.0_09, and it gives 3 errors... So, I can't even test his class ;) Also, you need to keep in mind that Java runs on the client side, while PHP runs on server side. Meaning that you will end up with either a page that refreshes for each card that comes up on the table, or updating with use of AJAX. The logic used in the Java code can be easily converted to PHP, that's not a big deal, but you'll need to recreate the interface... 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
Re: [PHP] PHP P O K E R...... and JAVA (convert)
Hey all! So you expect PHP ppl to do your job and test a JAVA class to tell u if it's worth porting it to php? Nice thoughts... Andy... why be a moron? I just wanted someone with java knowledge to have a look at the code and see if it ran properly.. something that should take an experienced java person less than 5 minutes of their time. I have been on this list for years, and since i have not seen you very often until lately I will assume you have kind of recently joined... my point is, in the years that i have been on and off the list I have seen time and again people willing to help by sparing few minutes (heck in some instances even a few hours trying to help newbies)... if you dont want to help, dont reply to the thread instead of acting like a moron. 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 -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
Re: [PHP] PHP P O K E R...... and JAVA (convert)
On 6/27/07, Ryan A [EMAIL PROTECTED] 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
Re: [PHP] PHP P O K E R...... and JAVA (convert)
On Wed, 2007-06-27 at 14:17 +0200, Tijnema wrote: Not too hard to program right? As long as you keep on assuming that you are playing with infinite decks of cards, and not marking cards as dealt as you deal. --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP P O K E R...... and JAVA (convert)
On 6/27/07, Paul Scott [EMAIL PROTECTED] wrote: On Wed, 2007-06-27 at 14:17 +0200, Tijnema wrote: Not too hard to program right? As long as you keep on assuming that you are playing with infinite decks of cards, and not marking cards as dealt as you deal. --Paul Hmm, good point I just forgot ;) Ok, Array containing all cards, shuffle(), array_pop() :) 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
Re: [PHP] PHP P O K E R...... and JAVA (convert)
Paul Scott [EMAIL PROTECTED] wrote: On Wed, 2007-06-27 at 14:17 +0200, Tijnema wrote: Not too hard to program right? As long as you keep on assuming that you are playing with infinite decks of cards, and not marking cards as dealt as you deal. --Paul Hey Paul, Actually, I have already finished that part... I am using a standard deck of 52 cards and marking off each card as i deal it so theres no chance for example to get Ks Ks Ah Ah etc I wrote the address before: webbmatte.se/cards.php Cheers! R -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) - The fish are biting. Get more visitors on your site using Yahoo! Search Marketing.
Re: [PHP] PHP P O K E R...... and JAVA (convert)
Tijnema [EMAIL PROTECTED] wrote: 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 You need to add logic to ensure that the same card is not dealt twice! An initial routine to shuffle the deck is the approach that I would take. Stephen
Re: [PHP] PHP P O K E R...... and JAVA (convert)
On 6/27/07, Stephen [EMAIL PROTECTED] wrote: Tijnema [EMAIL PROTECTED] wrote: 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 You need to add logic to ensure that the same card is not dealt twice! An initial routine to shuffle the deck is the approach that I would take. Stephen Yes, I fixed that in a second reply ;) 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
Re: [PHP] PHP P O K E R...... and JAVA (convert)
Ryan, if you want to port the java code to php it wouldnt be very difficult since this code doesnt rely heavily on much besides core language constructs. really you could just save it as a php file and start making changes where needed; it wouldnt take too long to port. as for the compilation issue i took a look at this myself and discovered some broken logic in the flush method. for (int i=0; i= 0 sorted[i] = 12) suitA++; else if (sorted[i] = 13 sorted[i] = 25) suit i converted this to for (int i=0; i fv.length; i++) { if(i = 0 sorted[i] = 12) suitA++; though im not sure if that is correct (spent about 5 minutes on it) a quick guess tells me it should be. The HandRanker class is dependent upon another proprietary class HandRankwhich is burried in a link (not in blue text) on the page you provided us. There are actually links in the statement. This HandRanker http://www.greenbridge.net/files/HandRanker.javaclass is used to calculate the rank of a poker hand. It uses the HandRank http://www.greenbridge.net/index.php/p_handrank.php class to store the rank of the poker hand. So if you just make 2 files HandRanker.java HandRank.java Place the respective class definitions in those files (put them in the same directory for simplicity). Apply the patch i provided above to HandRanker.java (lines 123, 124) then issue (at command prompt) javac HandRanker.java and you should have the compiled code :) -nathan On 6/27/07, Tijnema [EMAIL PROTECTED] wrote: On 6/27/07, Stephen [EMAIL PROTECTED] wrote: Tijnema [EMAIL PROTECTED] wrote: 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 You need to add logic to ensure that the same card is not dealt twice! An initial routine to shuffle the deck is the approach that I would take. Stephen Yes, I fixed that in a second reply ;) 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
Re: [PHP] PHP P O K E R...... and JAVA (convert)
This isn't exactly what was asked for but when I TA'd the principles of programming languages course, an assignment I gave was to write a simple poker game in Haskell. If anyone's interested here's the sample solution I gave: http://smokinn.tengun.net/comp348/poker.hs It's all console based of course. You'll need either ghc or hugs installed to run it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php