Re: PHP P O K E R...... and JAVA (convert)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.java>class 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 <tijnema@xxxxxxxxx> wrote:

On 6/27/07, Stephen <stephen-d@xxxxxxxxxx> wrote:
> Tijnema <tijnema@xxxxxxxxx> 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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux