University of Montana Homepage The E-Folio of Daniel Wedul

 

Home

about_me

My projects

My resume

In the works

online diary

 

Poker Simulator in java

Spring 2002

Background:

I started enjoying playing poker on the free online poker sites. The accessibility of these poker sites and the fact that they were on the computer made me want a program that would allow me to input what I know about a round and get the odds on me winning.

The Problem:

In Texas Hold'em each player is dealt two cards, the 'hole'. Five 'community' cards are then dealt. Each players hand is then the best possible five card hand that can be made with the two hole cards and the five community cards. The winning player is the that has a better hand than all the other players. I wanted to know, at any point in a round, "when to hold'em," and "when to fold'em."

The solution:

I started with the basics. I created a card class. Then using that I created a deck class and a hand class. The card and deck classes could be used to write any card game. They are not specific to poker. The hand class is the poker specific class. I then wrote many test programs to check these classes. After verifying that the classes function properly I wrote several poker simulation programs.

These are the three main classes needed to run the simulations
card.java
deck.java
hand.java

Here are the test programs I wrote
dealhands.java - Deals hands and prints cards dealt
headsup.java - Takes two sets of hole cards and simulates a number of rounds to see which hand wins the most.
rank.java - Takes seven cards from the command line and outputs all possible ranks for the hand.
test.java - Plays a lot of unrestricted hands and outputs results
test2.java - Deals a round and outputs all hands and ranks
test3.java - Used to test a specific hand

Here are the main programs I used to simulate the rounds.
play.java - Given known cards tells how often a hand wins
jplay.java - Same as play.java except a joker is thrown in the deck

After I finished the program I figured it would be a good program to use to figure out how to use Message Passing Interface (MPI) with java. It ends up all I had to do was put some MPI code into a main(). I came up with these two programs
MPIodds.java - parallel version of test.java from above
MPIpoker.java - same as MPIodds.java except output is to the screen

Here is a zip file that has all of these files.
dannys_java_poker.zip

What I learned:

This program was fun because it was something that I just decided to do. I learned that I fully understand (and can think in) object oriented programming. It was very fun to try and figure out a "simple" way to rank hands.

The part of the program that I spent the most time programming (and testing) was the testing and ranking of hands. I was very proud of finding the formula I found for ranking the hands. I realize, however, that the method I have for testing the hands is probably not very optimized. On the other hand, it works and on my AMD Athlon XP 1800+, it took about 5 seconds to run 10,000 hands. This was acceptable.

Yet another thing I learned was how to implement MPI in java. This is the most exciting thing learned during this project.

 

P.S. Fold the 2, 7 offsuit.

 

page last updated July 2004

http://www.google.com

www.google.com

index.html

[Home]  [About me]  [My projects]  [Resume]  [In the works]  [online diary
[TV mount]  [Diffusion]  [N-body]  [Vote Montana]  [Climate Model]  [Portfolio
[Quantum Computers]  [Poker]  [Triviabot]  [Website Creator]  [Movies

Site Last Updated February 02, 2010