Click here to Skip to main content
15,881,938 members
Articles / Mobile Apps

Poker Tools

Rate me:
Please Sign up or sign in to vote.
4.09/5 (23 votes)
2 May 2004CPOL8 min read 314.9K   1K   35   18
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>

C#
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Corpria LLC
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalnice tool Pin
poker tools4-May-11 2:52
poker tools4-May-11 2:52 
GeneralOther Poker Calc Pin
Alex_Poker22-Mar-10 6:56
Alex_Poker22-Mar-10 6:56 
GeneralNice Pin
dexond28-Nov-07 4:22
dexond28-Nov-07 4:22 
QuestionNot able to connect ActiveSync Pin
arinhere28-Aug-07 22:52
arinhere28-Aug-07 22:52 
GeneralPoker Tools Pin
pokeraddict16-Feb-06 5:34
pokeraddict16-Feb-06 5:34 
GeneralDownload link is broken Pin
Stewy21-Dec-04 2:27
Stewy21-Dec-04 2:27 
GeneralRe: Download link is broken Pin
Domi7817-Feb-05 3:09
Domi7817-Feb-05 3:09 
GeneralRe: Download link is broken Pin
Doug Mair17-Feb-05 3:41
Doug Mair17-Feb-05 3:41 
GeneralRe: Download link is broken Pin
blaster_god10-Jul-06 10:31
blaster_god10-Jul-06 10:31 
GeneralGetting top rank and bottom rank back Please help Pin
avuolo19-Oct-04 9:23
avuolo19-Oct-04 9:23 
GeneralRe: Getting top rank and bottom rank back Please help Pin
Doug Mair19-Oct-04 10:57
Doug Mair19-Oct-04 10:57 
You need to Mask off the extra information after you have shifted over to find the rank.

Try code like this:
(res >> 16) && 0xf

This will only keep four bits of information.

Example code:
handLow = (int)(res >> 16) & 0xf;
handHigh = (int)(res >> 20) & 0xf;
lbTest.Text = "Low:" + handLow + " High:" + handHigh + " Res:" + res.ToString("x");

The handLow and handHigh will only have values for certain types of hands:
1 pair - handLow = the rank of the pair
2 pair - handHigh = rank of higher pair, handLow = rank of lower pair
set - handLow = rank of the set
fullboat- handHigh = rank of the set, handLow = rank of the pair
quads - handLow = rank of the quads.

I may have missed some possibilities but this should help. I tested this with the 5 card hand evaulator and it worked fine. I haven't tested it with the 7 card evaluator.

Let me know if this works.


Doug

GeneralRe: Getting top rank and bottom rank back Please help Pin
avuolo19-Oct-04 11:57
avuolo19-Oct-04 11:57 
GeneralSource Implementaton Help Pin
SoonerToucan30-Jul-04 1:45
SoonerToucan30-Jul-04 1:45 
GeneralMaking a DLL from the HandEval code Pin
Steve Brecher12-May-04 14:34
Steve Brecher12-May-04 14:34 
GeneralRe: Making a DLL from the HandEval code Pin
Doug Mair14-May-04 4:54
Doug Mair14-May-04 4:54 
GeneralA Great Help Pin
richiek4-May-04 7:27
richiek4-May-04 7:27 
GeneralRe: A Great Help Pin
Doug Mair14-May-04 4:57
Doug Mair14-May-04 4:57 
GeneralRe: A Great Help Pin
tsurutsuru5-Oct-04 16:20
tsurutsuru5-Oct-04 16:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.