Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (109)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Poker  (Read 2458 times)
0 Members and 1 Guest are viewing this topic.
Offline umairmehmood

Junior Newbie





« Posted 2006-06-19 12:24:55 »

Hello,
Is there any Poker game written in Java that has source code along with for analysis.

Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2006-06-19 13:27:33 »

google -> 2nd hit -> sourcecode

For your amusement: My Poker4k sourcecode (screens: click click click click, JAR, JNLP)

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline umairmehmood

Junior Newbie





« Reply #2 - Posted 2006-06-19 16:10:41 »

Not bad though...!! Grin
but still the example is quiet simple.
I was looking for a combination of a complex codes and a little bit of Shuffling + Distribution Algorithm to go along with.

Help required.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #3 - Posted 2006-07-04 22:54:53 »

This should probably bein clueless newbies but....

Quick deck shuffling algorithym:

1  
2  
3  
4  
5  
6  
7  
8  
(1)Allocate an integer array with length 52.
(2) Loop from 0 to 51 adn set deck[i] = i
(3) Loop for some number of times (say 50) and do the following (swap pairs of cards):
   x = random from 0  to 51
   y=  random from 0 to 51
   temp = deck[x]
   deck[x]=deck[y]
   deck[y]=temp

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Online Riven
« League of Dukes »

JGO Overlord


Medals: 757
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #4 - Posted 2006-07-04 23:07:38 »

Well, it could be much more efficient:

1  
2  
3  
4  
5  
6  
7  
8  
Random r = new Random();
for(int i=0; i<52; i++)
{
    int from = i;
    int to = (i + 1) + r.nextInt(52 - i - 1);

    swap(from, to);
}


It handles the remaining cards as a pool to take cards from.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline purpleguitar

Junior Member





« Reply #5 - Posted 2006-07-05 14:57:49 »

If you are only drawing cards, not peeking ahead or inserting any, then an easy option is to implement the deck as a list of cards and yield a random one on draw.  E.g.:

1  
2  
3  
4  
5  
6  
7  
8  
class Deck {
  private List<Card> theDeck;
 
  public Card draw() {
    if (theDeck.size()==0) throw NoSuchElementException();
    else return theDeck.remove(Math.random() * theDeck.size());
  }
}


From the client's point of view (that is, according to the object's interface), the deck is shuffled, and in an OO system, that's all that matters Smiley
Offline Jeff

JGO Coder




Got any cats?


« Reply #6 - Posted 2006-07-06 21:53:47 »

Well, it could be much more efficient:

heh by quick I meant "im dashing this off quick."

Im sure there are more efficient means. Im not sure its worth a lot of effort to find them  Cool

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Mr_Light

Senior Member




shiny.


« Reply #7 - Posted 2006-07-06 22:35:13 »

1  
Collections.shuffle(deck);


try reading from page 17 for the whole shabang.

http://64.233.183.104/search?q=cache:Wq1IsrnfDNsJ:developers.sun.com/learning/javaoneonline/2004/corej2se/TS-2569.pdf+Java+5.0+deck&hl=en&ct=clnk&cd=3
http://developers.sun.com/learning/javaoneonline/2004/corej2se/TS-2569.pdf


It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CogWheelz (18 views)
2014-07-30 21:08:39

Riven (26 views)
2014-07-29 18:09:19

Riven (15 views)
2014-07-29 18:08:52

Dwinin (13 views)
2014-07-29 10:59:34

E.R. Fleming (34 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (44 views)
2014-07-24 01:59:36

Riven (44 views)
2014-07-23 21:16:32

Riven (30 views)
2014-07-23 21:07:15

Riven (31 views)
2014-07-23 20:56:16
List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!