Friday, August 29, 2008

Addition of Hand types / Declaring a Winner

Well work is going well on this Silverlight project. There are only two hand types that the application does not properly check right now, a straight and a straight flush. Correction, it does check a straight, but it doesn't assign a score or a high card associated with it so the application would not be able to tell who won the hand if both hands had a straight.

I expect to have both of these algorythyms (straight flush and straight) completed soon, and have already tried adding a player to the board and my logic seems to work good for 3 players. I will try adding 4 - 10 hopefully soon as well.

I wanted to post a code update for everyone so that they can see the progress so far. Projects like this have a tendency to suck up a lot more time than they initially feel like they should take. This project is no exception to the rule.

If you find any places where the code seems to be acting in a way that it shouldn't then let me know. Please be very descriptive as to how to replicate the problem/error (step by step process).

Monday, August 25, 2008

Work Continues

I have added all the basic types of hands now, but am missing high card, and there is only calculation for kicker done currently on two pairs.

The maximum value a given hand for score is now 141,414,141,414. I've gone over the logic many times and I think that this system for score will cover all the possiblities. If not I may have to rework the way score works at a later date.

Determining which hands wins the hand will be done as such. First, the types of hands are ranked from top to bottom, with straight flush being the highest valued hand, and high card being the lowest.

The logic works as such: All hands face off, the highest type hand wins outright, if there are two or more hands with the same hand type, that is the point that it goes to the score.

I was going to incorporate the hand type into the score, but looking at it I think I would require too long of a integer, also this sort of locks me into always combining those two values into score, and there may be some reason to split them in the future.

Each card is assigned a value equal to its Rank 2=2points, 3=3points, .. King=13points, Ace=14 points.

If two or more hands have the same hand type (ie: Two Pair) then we go to a showdown based upon score. Every hand has a top card which is always worth more than the bottom card. In the case of two pair, the top (highest) card is multiplied by 10,000,000,000 and is added to the score. So if someone had 4's versus someone else's 3's, they would have a score of 40,000,000,000 versus 30,000,000,000.

Lets say they both have 2's as their second card, since 2's is the low card in the two pair scenario, we only multiply it by 100,000,000.
This leaves us with 40,200,000,000 and 30,200,000,000 for scores.

Aces and Queens versus Aces and Kings. 141,200,000,000 < 141,300,000,000

When we go to add the first kicker, the first kicker will occupy the 5th, and 6th position of our 141,414,141,414 numbers.

Ace/King with a Jack Kicker versus Ace/King with a 10 Kicker.
141,311,000,000 > 141,310,000,000

I think this works for all scenarios of two pair.

Things are going well so far, many more things need to be done but the algorythyms for determining the score value of hands, which will be used to determine the winner of the hands are well underway.

Wednesday, August 20, 2008

Check for Quads, Full house

I am re-working some of the code, and I created a couple new classes to help me determine if someone has some of the rank based hands. Checking for four of a kind was relatively easy, checking for a full house was a little tricky.
I expect checking for three of a kind to be easy, and two pair to be a bit tricky.

Regardless, four of a kind and full house are now being checked for. You will also notice a score that has been attached to each hand.

The score will be used, in combination with the type of hand to determine how good the hand is. So a four of a kind with a score of 13 would still beat a full house of score 1013. Four of a kind with a score of 13 should be 4 kings, full house of score 1013 shoudl be 10's over kings 1310 would be kings over 10's.

The app is coming along nicely, comments are welcome.

Wednesday, August 13, 2008

Turn and River

I decided the next thing to get working would be to get the turn and river working. Also I put in some smart enabling/disabling of the buttons to help focus the user on what he/she should be allowed to do from that point on.

I have managed to write this application in such a way that it should (*fingers crossed) be relatively simple to start adding logic to test for the other hand types, also I made it so that it should (*) be easy to add more players as well.

My goal is to have it so that you can run a bunch of test hands to see how often one will will win over another hand. You can change any of the user's hands to whatever you want, and you can run simulations to see what the result will be.

Tuesday, August 12, 2008

First Pre-demo release

Welcome to the Silverlight Texas Holdem Hand Analyzer project. Eventually I hope to have a better name for the project :).

I started this project as a way to learn the Silverlight architecture, and while playing around with Silverlight I thought that maybe it would be a good idea to build something that people could use.

It is a ways away from completion, but the basic engine is working, it currently checks for straights, and single pairs. And it will deal out hands to 2 players, and also deal the flop.

Clicking on a card will move up to the next ranking card, unless a player already has that card.

What is the purpose of this project?

I'd like to create a easy to use web application that will allow a user to quickly and easily determine their odds in a given Texas Holdem situation, either before it happens or retroactively when looking back at something that happened, eventually it would be nice to have this application available on a hand-held internet ready device.

I would love to read your comments, your comments will greatly influence which direction this project heads.

You can see the very first version of the Hand Analyzer HERE