Poker Simulator in javaSpring 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.
Here are the test programs I wrote
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
Here is a zip file that has all of these files.
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
[In the works]
[TV mount] [Diffusion] [N-body] [Vote Montana] [Climate Model] [Portfolio]
[Quantum Computers] [Poker] [Triviabot] [Website Creator] [Movies]
Site Last Updated February 02, 2010