Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Poker Tools

0.00/5 (No votes)
2 May 2004 2  
A utility program to help poker players.

Introduction

This is a set of tools for people who play poker. I tested the application with the Windows desktop and with the emulators that are built into VS.NET. I am amazed by the fact that the same executable will run on both platforms without modification. The application was written to run at different screen sizes.

The zip file contains all the source and executables required. One of my pet peeves is downloading a project and then not being able to use it immediately. You should be able to unzip the file, load the solution and be ready to edit the code. OR, get the executable from the bin/debug directory and run it right from there.

I'm not as sure about whether the CAB file distributions will work. I don't have any way to test them. I just created them and included them in the zip file.

Background

This application was written as an entry to the Code Project Compact Framework contest. I also used it as a way to learn about C# / .NET / Compact Framework. I'm primarily a C++ / Win32 tools programmer, so this project proved somewhat challenging.

Card Images

For the big card images, I used the images that are in the Cards.dll for Win2K. and added them to a .NET Compact Framework compatible resx file. The Resourcer program helped me, but it doesn't work with the .NET Compact Framework compatible resx files, so I had to edit the XML directly.

I fixed the Jack of Diamonds card to have 2 eyes, so, now there are only 2 one eyed jacks instead of 3.

I also added a set of cards that look nice when viewed small.

Hand Evaluator

I found some public domain C source code on Steve Brecher's website that evaluates poker hands. I definitely wanted to use this code. So, I put it into a C++ DLL and tried it. I could use the DLL in windows, but not inside the emulator.

So, I downloaded the embedded VC++ V4 compiler and tried to create platform specific DLLs. I had no luck with this either.

If anyone is interested, the source code zip file has a subdirectory in it called Save. I included the DLL source in that subdirectory. If anyone could get the emulator to link to one of those DLL's, I would be interested in the results.

In the end, I just translated one of the C source files to C# and went on. The translation of the HandEval.cpp file was straight forward.

Using the application

When the application is started you will see this screen of three buttons.

Sample Image - maximum width is 600 pixels

Hand Rankings display

If you press the first button, "Hand Rankings", you will see the following screen.

Sample Image - maximum width is 600 pixels

This is a poker hand rankings list. You can resize it to your liking. Print it out if you like, or, display it on your computer screens so that newbie poker players can view it.

Chip Splitter

The second button on the main menu brings up the Chip Splitter. The first thing to note is that there is a toolbar on the top of this screen. The buttons are: "Load", "Save", "Split", "Even Money", and "BuyIn".

The first step would be to setup the values and quantities of your chips and save them to a file.

Sample Image - maximum width is 600 pixels

This screen is intended to help people who are having poker games or tournaments at their houses. I bought a set of 450 chips for home use. It can be complicated to figure out how to split up the chips in different situations.

The chip spliiter can be used in several situations: Tournaments, Dealers Choice, Cashing out and Game continuations.

Tournaments - When playing tournament style poker you want to evenly split all of your chips up between the players. So, first, you would setup the chip values and quantities on the first two lines. Then you click in the number of players in the tournament (up to ten). Then press the "Split" button. This will evenly split up the chips between all the players. At this point you will likely have some chips left over. If you are really wanting to use all of your chips for this tournament, you can press the "Even Money" button. This will use all chips that are left and split them up so that everyone has even money. The chip counts won't be identical, but the dollar value will be the same for everyone.

Dealers Choice - When playing dealers choice games you can have users "BuyIn" to receive their chips. So first setup the chip values and quantities. Make sure you are starting with a clear table (unclick all players). For example in the games that I play in, we have about 5 players and everyone likes to play nickel ante and wants to play with about $10-$20 cash. Knowing this, I would have to value my chips in such a way as to support about $100. With denominations from .05$ to $1.

At this point I would hit the "BuyIn" button and see the following screen.

Sample Image - maximum width is 600 pixels

So, player 1 is going to give me $10 and wants a good distribution of chips and 50 chips total. On this screen I would enter Player #1, Amount $10, Total Chips 50, then hit the "Calc" button. When the "Calc" button is hit the listview will be filled with various ways to achieve this distribution. I would look through the list and choose a combination that I like and then select it.

With the right combination selected, I then press the "Apply" button to add this combination of chips to Player 1. If I hit "Apply" twice, then I've given him $20. You can then change to player 2 and give him a set of chips for the $15 that he has.

Note that due to a rounding error, sometimes the buyin algorithm will give 1 cent less than asked for, so make sure to check the results.

When all players have their "Buyins", press the "Done" button.

Cashing out - When a player at a dealers choice game is done you can use the chip splitter to quickly figure out how much money their chips are worth.

Make sure the chip values are correct and then, count the chips that the player has and enter the counts into a clear row of the chip spliiter. Their total value will be displayed on the right hand side. It will also show you the number of chips they have as a quick sanity check.

Game continuations - If you are having a Hold'em tournament, but it's getting too late for eveyone, you can use the chip splitter to enter in all of the counts of chips for each player. Save the file. And maybe do a screen print. When you continue the tournament later, you can load the file and distribute the chips as the file says.

Remember that since this application runs on both the Windows desktop and on a Pocket PC, you can do some of your preliminary setup on your desktop and save the file and move it to the Pocket PC to take it with you to the poker game.

Video Poker Game

Clicking the last button on the main menu will pop up a video poker game.

Sample Image - maximum width is 600 pixels

This is a standard Jacks or better game. It's here to help you waste some time and to practice your poker strategies.

Future tools

Hold'em Showdown odds

I had intended to use the Showdown.cpp file from Steve Brecher site to create a Hold'em Showdown screen. As I said before, I couldn't get the DLL to work and the CPP file had lots of pointers and structs and is very complicated to translate. At some point I would like to complete the Showdown tool.

Code details

I produced alot of code for this project. Fill free to browse and comment on it. I think the most interesting code that I wrote deals with painting bitmaps, resizing forms and creating arrays of controls.

Here is an example of code that paints the large card bitmaps from the resource file:< /P>

Image newImage;
int x = 0, y = 0;
GraphicsUnit units = GraphicsUnit.Pixel;
ImageAttributes imageAttr = new ImageAttributes();

if (shown == false)
  newImage = Resources.GetImage("backside.bmp");
else
  newImage = image;

if (w<0) w = (int)cardSize.Width;
if (h<0) h = (int)cardSize.Height;

Rectangle destRect = new Rectangle(xPos, yPos, w, h);
drawingSurface.DrawImage(newImage, destRect, x, y, 
    newImage.Width, newImage.Height, units, imageAttr);

Font drawFont = new Font("Courier New", 8, 
  System.Drawing.FontStyle.Bold);
SolidBrush drawBrush = new SolidBrush(Color.Black);

SizeF sizeString = drawingSurface.MeasureString(
  "HOLD", drawFont);
x = (int)(xPos + cardSize.Width/2 - sizeString.Width/2);
if (x<xPos) x = xPos;

if (hold)
  drawingSurface.DrawString("HOLD", drawFont, 
    drawBrush, x, yPos+h);
else
  drawingSurface.DrawString("     ", drawFont, 
    drawBrush, x, yPos+h);

Points of Interest

Overall this project has been lots of fun. It was fun to work with C# and the IDE. My appreciation for C++ pointers and typedefs also grew as a result of this project.

The .NET compact framework was somewhat frustrating because it is a subset of the total .NET framework. But since it lets you produce executables that can be used on PDAs and Desktops, I think it is worth your consideration as a target platform. Again, remember that since this application runs on both the Windows desktop and on a Pocket PC, you can do some of your preliminary setup on your desktop and save the file and move it to the Pocket PC to take it with you to the poker game.

Ugh, it's always hard for a programmer to put down a project and move on to other areas.

Please feel free to make suggestions or error reports. Depending on the feedback I get, I will try to improve the Poker Tools set.

History

  • May 1, 2004 - Initial Release.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here