|
|
Comments and Discussions
|
|
 |

|
I wrote a very fast Poker Hand Evaluator using bit and mathematical operations. I don't think it could be done faster other than with look-up tables (as others have done). I wrote an article on how this works [here]
using System;
using System.Diagnostics;
namespace Poker.Examples
{
public class PokerAnalyzer
{
public readonly static string[] Hands = new string[]
{"4 of a Kind","Straight Flush","Straight","Flush", "High Card",
"1 Pair", "2 Pair", "Royal Flush", "3 of a Kind", "Full House"};
public static void Main(string[] args)
{
showRank(new int[] { 10, 11, 12, 13, 14 }, new int[] { 1, 1, 1, 1, 1 }); showRank(new int[] { 4, 5, 6, 7, 8 }, new int[] { 1, 1, 1, 1, 1 }); showRank(new int[] { 2, 3, 4, 5, 14 }, new int[] { 1, 1, 1, 1, 1 }); showRank(new int[] { 8, 8, 8, 8, 9 }, new int[] { 1, 2, 4, 8, 1 }); showRank(new int[] { 7, 7, 7, 9, 9 }, new int[] { 1, 2, 4, 8, 1 }); showRank(new int[] { 10, 11, 6, 13, 9 }, new int[] { 2, 2, 2, 2, 2 }); showRank(new int[] { 10, 11, 12, 13, 9 }, new int[] { 2, 2, 4, 2, 1 }); showRank(new int[] { 2, 3, 4, 5, 14 }, new int[] { 1, 2, 4, 8, 1 }); showRank(new int[] { 4, 4, 4, 8, 9 }, new int[] { 1, 2, 4, 8, 1 }); showRank(new int[] { 8, 8, 11, 9, 9 }, new int[] { 1, 2, 4, 8, 1 }); showRank(new int[] { 8, 8, 3, 5, 9 }, new int[] { 1, 2, 4, 8, 1 }); showRank(new int[] { 10, 5, 4, 7, 9 }, new int[] { 1, 2, 4, 8, 1 }); }
public static long getRankIndex(int[] cs, int[] ss)
{
long v;
return (v = (v = (v = (v = (v = 1L << cs[0] * 4) | (v + (1L << cs[1] * 4))) |
(v + (1L << cs[2] * 4))) | (v + (1L << cs[3] * 4))) | (v + (1L << cs[4] * 4))) % 15
-(ss[0] == (ss[1]|ss[2]|ss[3]|ss[4]) ? 1 : 0)*((v == (0x11111L << 40)) ? -5 : 1)
-((v / (v & -v) == 0x11111) || (v == (0x111100 + (1L << 56))) ? 3 : 1);
}
public static void showRank(int[] cs, int[] ss)
{
Trace.WriteLine("Hand: " + Hands[getRankIndex(cs, ss)]);
}
}
}
modified 15 May '13 - 21:00.
|
|
|
|

|
You have provided hand ranging for two players.its working fine if iam using that for 10 players what should i do.Is there a way to use this code in this way.I need the button click event for calculating the hank ranking.
|
|
|
|

|
string board = "4d 5d 6c 3c 2d";
Hand player1 = new Hand("ac as", board);
Console.WriteLine("Player1 Hand: {0}", player1.Description);
I
hope that the description of the largest card type list, such as “A straight, 2d 3c 4d 5d 6c”
|
|
|
|

|
Great job! It is possible to know which cards from the board were contained in the winning combination?
|
|
|
|

|
As you know vb.net is not supporting Iterators.
Is it possible to convert your library to vb.net !?
specially "yield return" commands in HandIterator.cs!?
|
|
|
|

|
Great work.
I just noticed that you use readonly for constant integers.
If you use const instead of static readonly you will get a speed improvement , also if you won't be able to initialize fields like this public static readonly int SPADE_OFFSET = 13 * Spades; , and you will have to specify a const value to initialize the field public const int SPADE_OFFSET = 39;
A fourther improvement but trickyer could be to use fixed buffers inside a struct for the lookup tables. Fixed buffers are faster than arrays but to access them you need to use the fixed() statement to acquire a pin pointer , this introduce overhead. So to be actually faster this method requires to acquire the pointer to the struct before the loop starts, and pass it as a parameter to the Evaluate funcion.
Using these 2 methods i got an improvement of 40%.
|
|
|
|

|
very very fast code and algorithms. congratulations and thank you!
|
|
|
|

|
Such an amazing library! Thank you very much for the article!
I have managed to run it in Ubuntu Linux 10.04 (64 bit) with mono v2.8. I would like to ask you to remove HiResTimer.cs and use standard System.Diagnostics.Stopwatch timer instead. I am pretty sure that it's resolution is the same as WinAPI P/Invokes you have used.
Also I have observed, that in Benchmark inlined functions are always 20-40% slower, then standard enumerations.
For example:
5-card hand Type (Hands iterator): 13,260,000 hands per second
5-card hand type (Inlined iteration): 9,625,778 hands per second
Best regards!
|
|
|
|

|
I’ve found your article extremely useful and easy to follow; but I’ve got one question. Tracing the code I’ve noticed that you have an array with some probabilities pre-computed. Can you tell me how you’ve computed them? I’m searching to find formulae that will produce these probabilities at runtime.
I know it will take a lot of time, but if the results are stored in a file after the first run of the program the end result will be the same.
Thank you in advance.
Iosif
|
|
|
|

|
What a interesting article! good job Keith!
I wonder if I can test it with real poker games.
In I found a couple of good poker portals.
There are online casinos with poker games in too.
|
|
|
|

|
When you have a flush draw, your chances are 19.6% and not 30%+ as your app outputs.
when you have a flush draw it means that only 9 cards can help you out of 46 cards (52 in a deck - 2 that you have and - 4 that are already open is 46).
so your chances are 9 to 37 (9 that can help you win against 37 that will loose), which is 9/(37+9) = 19.6%.
modified on Wednesday, April 2, 2008 4:51 AM
|
|
|
|

|
First, thanks so much for providing this library - very, very helpful.
I'm wondering about the pPot calculation. Darse Billings (the originator of the algorithm you are using) defines pPot as:
"The Positive Potential, or PPot, is the probability that our hand will improve after a new card is dealt. In general, improvement is measured by counting each situation where we are currently behind and will end up ahead or tied. Likewise, Negative potential, or NPot, is the count of hands where we are currently ahead, but will end up behind."
For most of my sample data, the values seem appropriate. But I can't figure this one out:
JsTs flop: 9s8s2h
The pPot value seems low (pPot = .269), versus this hand:
AsKs flop: 8s7c4s (pPot = .088) - really, really low
The JsTs is actually a better hand versus random hands in this situation (and is in fact a favorite against most hands) due to the drawing strength (flush+straight). So this makes sense... but then try this:
JhTh flop 9h8h2s (pPot = .401)
This situation is identical to the JsTs above, how can the pPot value be so dramatically different?
modified on Monday, March 31, 2008 5:55 PM
|
|
|
|

|
If I wanted to use this lib from another language, how would I go about it?
Is it possible to create a COM dll for this lib.
I'm a total C newb , I don't really understand how to use the .cs files this comes with.
A link to something would be great...
|
|
|
|

|
I love your work here.
I have just used a combination of all your examples to work out a solution for casino holdem.
The Video poker helper was especially useful for this.
|
|
|
|

|
Keith, I have the following code which I took from the poker for programmers site. When running this code the opp1mask call hangs and does not return a value. This is most likely due to the fact that the board mask has the available cards from the query and no cards can be returned. I have many situations that this happens when trying to pass a query and return a hand. Also, if you use the code in section "Using Pocket Queries in Code" and move the line ulong[] player2 = PocketHands.Query("Axs",player1mask); into the for loop the PocketHands.Query takes way to long to process for each iteration. Is their something I am missing here to make this work when setting pocket queries (ranges) for opponents?
<code>using System; using HoldemHand; // This example calculates the win odds for a player having "As Ks" against // five random players namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // Calculate win odds using example code double w1 = WinOddsFivePlayerMonteCarlo(Hand.ParseHand("as ks"), 0UL, 5.0); Console.WriteLine("win: {0 .00}%, time {1 .0000}", w1 * 100.0, 5.0); // Calcluate win odds using Hand.WinOdds() w1 = Hand.WinOdds(Hand.ParseHand("as ks"), 0UL, 5, 5.0); Console.WriteLine("win: {0 .00}%, time {1 .0000}", w1 * 100.0, 5.0); Console.ReadLine(); } // An example of how to calculate win odds for five players static double WinOddsFivePlayerMonteCarlo(ulong pocket, ulong board, double duration) { // Keep track of stats long win = 0, lose = 0, tie = 0; // Loop through random boards foreach (ulong boardmask in Hand.RandomHands(board, pocket, 5, duration)) { // Get random opponent hands ulong opp1mask = Hand.RandomHand("(AA|KK)",boardmask | pocket, 2); ulong opp2mask = Hand.RandomHand(boardmask | pocket | opp1mask, 2); ulong opp3mask = Hand.RandomHand(boardmask | pocket | opp1mask | opp2mask, 2); ulong opp4mask = Hand.RandomHand(boardmask | pocket | opp1mask | opp2mask | opp3mask, 2); ulong opp5mask = Hand.RandomHand(boardmask | pocket | opp1mask | opp2mask | opp3mask | opp4mask, 2); // Get hand value for player and opponents uint playerHandVal = Hand.Evaluate(pocket | boardmask); uint opp1HandVal = Hand.Evaluate(opp1mask | boardmask); uint opp2HandVal = Hand.Evaluate(opp2mask | boardmask); uint opp3HandVal = Hand.Evaluate(opp3mask | boardmask); uint opp4HandVal = Hand.Evaluate(opp4mask | boardmask); uint opp5HandVal = Hand.Evaluate(opp5mask | boardmask); // Tally results if (playerHandVal > opp1HandVal && playerHandVal > opp2HandVal && playerHandVal > opp3HandVal && playerHandVal > opp4HandVal && playerHandVal > opp5HandVal) { win++; } else if (playerHandVal >= opp1HandVal && playerHandVal >= opp2HandVal && playerHandVal >= opp3HandVal && playerHandVal >= opp4HandVal && playerHandVal >= opp5HandVal) { tie++; } else { lose++; } } // Return stats return ((double)(win + tie / 2.0)) / ((double)(win + tie + lose)); } } } </code>
|
|
|
|

|
Hi Keith Rule,
i read our article, and i`m verry impressed. I was even more when i saw your code. I tryed to use it for my projekt to create a evaluator for 7Card Stud. I modiefied your code in some places, and after a lot of work i thought finally i´d would work. But I get %-numbers that can´t be right (they change the right way when i modifie the pokets, but they are not calibrated).
I telling you this because I hope you will help me.
Maybe you find some time to look over my (maybe more YOUR modyfied code.
Tell me what you think about.
Greetings
Stefan Keim
(Germany)
|
|
|
|

|
Hi there,
I just wanted to see if the updated article was near release. I haven't heard anything about it in a few months. Looking forward to it!
|
|
|
|

|
In the functions HandPotential and HandPotentialOpp a uint is used for the card mask, for instance:
HandAnalysis.cs line 790
...
foreach (uint oppPocket in Hands(0UL, dead_cards, 2)) {
...
These need a ulong like the other card masks or else you lose a lot of important bits . Otherwise great job your library has been really useful.
-James
|
|
|
|

|
I have this code:
ulong contain = Hand.ParseHand("ac");
ulong dead = Hand.ParseHand("as kc");
foreach (uint cards in Hand.Hands(contain, dead, 2))
{
Trace.WriteLine("Cards: " + Hand.BitCount(cards) + " " + Hand.MaskToString(cards));
}
As I understand, that should print out all 2-card combinations with Ac X where X is any other card except As or Kc (and obviously Ac), right?
Well, I'm getting this kind of output:
Cards: 2 Ac 2c
Cards: 2 Ac 3c
Cards: 2 Ac 4c
Cards: 2 Ac 5c
Cards: 2 Ac 6c
Cards: 2 Ac 7c
Cards: 2 Ac 8c
Cards: 2 Ac 9c
Cards: 2 Ac Tc
Cards: 2 Ac Jc
Cards: 2 Ac Qc
Cards: 2 2d Ac
Cards: 2 3d Ac
Cards: 2 4d Ac
Cards: 2 5d Ac
Cards: 2 6d Ac
Cards: 2 7d Ac
Cards: 2 8d Ac
Cards: 2 9d Ac
Cards: 2 Td Ac
Cards: 2 Jd Ac
Cards: 2 Qd Ac
Cards: 2 Kd Ac
Cards: 2 Ad Ac
Cards: 2 2h Ac
Cards: 2 3h Ac
Cards: 2 4h Ac
Cards: 2 5h Ac
Cards: 2 6h Ac
Cards: 2 7h Ac (all good so far)
Cards: 1 Ac (where did the 8h go???)
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
Cards: 1 Ac
What could be the problem?
|
|
|
|

|
I really appreciate this code, and am looking forward to the update. Because an update is rumored, I want to point out a very minor nitpick. For the card masks the suit order is clubs, diamonds, hearts, spades. I believe this is defined by the CardTable array of HandEvaluator.cs. For the CardType enumeration of the images, the order is hearts, diamonds, clubs, spades.
Dave
|
|
|
|

|
It needs some cleanup work done on it, but on my core 2 duo, it nearly doubles the performance of the evaluator as expected. Let me know if interested. More cpus, more cores, more performance
|
|
|
|

|
Please scratch my previous message, I tested the code and it sucked, didn't work and was totally out of line...
So to make it up I made two Omaha Hi/Lo classes that doesn't suck that bad and also works, please comment it:
class OmahaEvaluator
{
List fourcards = new List(270725);
int[] validbits = new int[249];
int[,] lowhands = new int[182, 241];
public OmahaEvaluator()
{
for (int a = 0; a < 49; a++)
for (int b = a + 1; b < 50; b++)
for (int c = b + 1; c < 51; c++)
for (int d = c + 1; d < 52; d++)
fourcards.Add(new OmahaHand((1UL << a), (1UL << b), (1UL << c), (1UL << d)));
fourcards.Sort();
int cnt = 0;
for (ulong i = 0; i < 249; i++)
if (Hand.BitCount(i) >= 3 && Hand.BitCount(i) < 6)
{
validbits[i] = cnt;
for (ulong j = 0; j <= 240; j++)
{
if (Hand.BitCount(j) <= 4 && Hand.BitCount(j) >= 2 && Hand.BitCount(j | i) >= 5)
{
ulong h = j, t = i, b = 128;
while (Hand.BitCount(t | h) != 5)
{
if ((h & b) == b)
h -= b;
b >>= 1;
}
lowhands[cnt, (int)j] = (int)(t | h);
}
else
lowhands[cnt, (int)j] = -1;
}
cnt++;
}
else
validbits[i] = -1;
}
public string DescriptionFromMask(ulong hand, ulong table)
{
OmahaHand h = fourcards[(fourcards.BinarySearch(new OmahaHand(hand)))];
uint besthand = 0;
int idx = -1;
for (int i = 0; i < 6; i++)
{
uint currenthand = Hand.Evaluate(h.hands[i] | table);
if (currenthand > besthand)
{
idx = i;
besthand = currenthand;
}
}
return Hand.DescriptionFromMask(h.hands[idx] | table);
}
public uint EvaluateHigh(ulong hand, ulong table)
{
OmahaHand h = fourcards[(fourcards.BinarySearch(new OmahaHand(hand)))];
uint besthand = 0;
for (int i = 0; i < 6; i++)
{
uint currenthand = Hand.Evaluate(h.hands[i] | table);
if (currenthand > besthand)
besthand = currenthand;
}
return besthand;
}
public int EvaluateLow(ulong hand, ulong table)
{
// Move down all aces to bit 0 and 2... up to bit 1
hand = (((hand >> 13) | (hand >> 26) | (hand >> 39) | hand) & 4223) << 1;
hand = ((hand & 254) | (hand >> 13)) & 255;
table = (((table >> 13) | (table >> 26) | (table >> 39) | table) & 4223) << 1;
table = ((table & 254) | (table >> 13)) & 255;
// Get valid bitmasks for low hand
int validbitmask = validbits[table];
// Less than three lows,no possible combo of a low hand
if (validbitmask == -1) return -1;
// Get the low cards on hand
return lowhands[validbitmask, (int) hand];
}
}
///
/// Represents a omaha-hand
///
class OmahaHand : IComparable
{
public ulong cards;
public ulong[] hands;
public OmahaHand(ulong crds)
{
cards = crds;
hands = new ulong[6];
}
public OmahaHand(ulong c1, ulong c2, ulong c3, ulong c4)
{
hands = new ulong[6];
cards = c1 | c2 | c3 | c4;
hands[0] = c1 | c2;
hands[1] = c1 | c3;
hands[2] = c1 | c4;
hands[3] = c2 | c3;
hands[4] = c2 | c4;
hands[5] = c3 | c4;
}
#region IComparable Members
public int CompareTo(OmahaHand other)
{
if (cards > other.cards)
return 1;
if (cards == other.cards)
return 0;
// if (cards < other.cards)
return -1;
}
#endregion
}
Usage:
OmahaEvaluator ev = new OmahaEvaluator();
ulong hand = Hand.ParseHand("ac kc 2h ah");
ulong table = Hand.ParseHand("6c 4c 3c");
// Lower value means better hand
int lo = ev.EvaluateLow(hand, table);
if (lo == -1)
Console.WriteLine("No low hand");
Console.WriteLine(ev.DescriptionFromMask(hand, table));
|
|
|
|

|
For those of you needing to calculate lowhands, for Hi / Lo games like Stud and Omaha) I've come up with the following (NOT EVER COMPILED,POSSIBLY NOT WORKING,ASSUMES THAT ACES ARE THE LOWEST BIT,easy to modify though) piece of code. The idea is simple:
Get the lowest unique cards from the table (A - 8)
ulong validbitmask = validbits[((table >> 13) | (table >> 26) | (table >> 39) | table) & 511];
Check if it is possible to form a low hand
if (validbitmask == -1) return -1;
Find a reference to possible hands with those cards.
return lowhands[validbits][((hand >> 13) | (hand >> 26) | (hand >> 39) | hand) & 511];
Pick the lowest unique cards from the hand,use it to pick the value from the reference found in the previous step.
return lowhands[validbits][((hand >> 13) | (hand >> 26) | (hand >> 39) | hand) & 511];
Lower return-value means lower hand,-1 means no low hand.
I just wanted to share this idea,if anyone has ha fast routine for picking the best Omaha hand using this code please share it...
// Extract the best low hand from the table and pocketcards
public static int lowhand(ulong table,ulong hand)
{
// Get valid bitmasks for low hand
int validbitmask = validbits[((table >> 13) | (table >> 26) | (table >> 39) | table) & 511];
// Less than three lows,no possible combo of a low hand
if (validbitmask == -1) return -1;
// Get the low cards on hand
return lowhands[validbits][((hand >> 13) | (hand >> 26) | (hand >> 39) | hand) & 511]};
}
Since I couldn't post my tables I'll post the psuedocode needed to create the tables:
int cnt = 0, lhcnt = -1;
for (int i = 0; i < 511; i++)
{
lhcnt++;
int table = 511 ^ i;
int q = bitcount(table);
if (q < 3 || q > 5)
validbits[i] = -1;
else
{
// We got three to five cards below or equal to eight on the table
validbits[i] = cnt++;
for (int j = 0; j <= 480; j++)
{
bool found = false;
thand = table;
if (bitcount(j) >= 2 && bitcount(j) <= 4 && bitcount(j | table) >= 5)
{
// We have a possible hand here
for (int l = 3; l <= j; l++)
{
if (bitcount(l) = 2 && bitcount(l & j) = 2 And bitcount(v | l) >= 5)
{
// We have a hand, remove unoptimal bits to create the lowest hand
for (int uu = 0; uu <= thand; uu++)
if (bitcount(uu) = 3 && bitcount(thand & uu) = 3) && (bitcount(uu | l) = 5)
{
// Best hand for theese cards is found
found = true;
tv = uu Or l
break;
}
if (found)
{
// Store the hand
lowhands[lhcnt][j] = thand;
break;
}
}
}
if (!found)
lowhands[lhcnt][j] = -1;
}
}
}
}
|
|
|
|

|
This is exactly what I've been looking for, you're a lifesaver!
You may want to point out in your Hands Odds app that the percentages displayed are for Wins and Ties... I got a little confused when I compared what I thought were Win percentages with poker-eval results.
Again, this is great stuff.
Chris
|
|
|
|

|
Hand.WinOdds("2h4d", "Qh6h2dQd7d", 1)
This is returning 100% sometimes and returning 0% other times.
Not sure why it should be returning either number with that hand.
Any othere interesting changes that you are currently working on?
Thanks
|
|
|
|

|
It'd be much appreciated if someone could at least point me to area of code i would need to begin my modifications?
|
|
|
|

|
Any idea when that update is coming? =)
|
|
|
|

|
I have an analyzer using Keith's Hand Odds code. It screen scrapes all the table info and can even press Fold, Call, Bet and Raise buttons based on the odds. The problem is strategy. It's not winning as much as I know it can if I had the right strategies. How can I improve the strategy over just using the odds? pokerbotcoder@yahoo.com
|
|
|
|

|
Ok here is a problem I am seeing
Board Cards
9h8h7cKh5s
Players Cards
7h7d
9 players
This is returning 6 percent
I have trips not sure why it is showing such a low %.
Only thing that should really worry this hand that I can see would be a Flush but still with trips i don't see this being a reason to return 6 %. Let me know what you find.
|
|
|
|

|
Hi,
does anyone know a formula to calculate the pre-flop percentages?
Would be great, because atm i have to write some kind of "skilled work" (don't know the right translation from german: "Facharbeit") to get my high school graduation.
thx in advance
Thomas
|
|
|
|

|
i'm not sure but im guessing that the hand odds app take the player hole cards and face them against every 7 cards combination . and then u got
the odds of your hole cards .
how can i know my odds if i sit in 10 players table and i got AA's ?
does the HoldemHand have any method that can provide that ? or combination
of few method ???
one more thing i reading book about c# for 2 month , and i about to finish the book , but the code in this Lib was really hard to understand for my
programming level all the Int the decalred as 0X000314 , WTF ???
i will very thankful if some one can give me names of book for more advance
concepts for c# programming so i can understand this Lib .
Thanks alot
|
|
|
|

|
Hi , there is a way to see the code ? not just using him ? Thanks
i want to see how the methods works to make some new methods
and to parctice my programming skill .
Thnaks .
|
|
|
|

|
I have added a code project for a visual hand tester. I am no where near done with it but should give an idea of where I am heading. It is also a good way to see how Foldem hand evaluation acts.
http://www.codeproject.com/useritems/Hand_Tester.asp
|
|
|
|

|
I am very concerned with this example. As you will see player 8
already has a pair of 8's
Thanks
FLOP: Th6h8d
Player 8 Pair KdTc
Win % 13.24
Outs 5
Ks Ts Kh Td Kc
Discounted Outs 4
Player 9 NoPair 4h7d
Win % 13.68
Outs 14
9s 7s 5s 4s 9h 7h 5h 9d 5d 4d 9c 7c 5c 4c
Discounted Outs 6
|
|
|
|

|
Is there a way to use the new discounted outs function with the WinOdds function?
So far I am very happy with the discoutned outs function good work.
|
|
|
|

|
Is there an explanation of the contents of the nBitsAndStrTable. There are over 17000 entries here.
The equivalent table in poker-eval is 8172 long and has the bits set with the folling code:
uint32
n_bits_func( uint32 n )
{
int retval;
retval = 0;
while (n) {
if (n & 1)
++retval;
n >>= 1;
}
return retval;
}
This table is generated as a file to be given to the compiler with the following comment embedded:
#define NBS_COMMENT_STRING \
"nBitsAndStrTable[]. Maps 13-bit rank masks onto an 8 bit quantity,\n" \
"packed with both the number of bits set in the mask (nBitsTable) and\n" \
"a value indicating if a straight is present (straightTable). \n" \
"It is possible, using just this table and bit masking operations, \n" \
"to determine the type of hand. Since this table is only 8K it should\n" \
"in L1 cache on some processors.\n " \
"The layout of the result is as follows: \n"\
" Bit 0: (nBits >= 5)\n"\
" Bit 1: is-straight\n"\
" Bits 2-6: nBits\n"
This doesn't seem to match the table contents in your nBitsAndStrTable so I can't figure out the logic of the bits set in either of the tables.
Is there a fuller explanation?
Ed
Edward E.L. Mitchell
Web: www.racesail.org
Phone: (239)415-7039
6707 Daniel Court
Fort Myers, FL 33908
|
|
|
|

|
Not sure that this is correct
The hands that its printing out in the for statement are not even including the board cards.
Hand AcAh
Board KhKcKs
txtResult.Text += "Hand Distance " + Hand.HandDistance(handMask, boardMask).ToString() + Environment.NewLine;
static public long HandDistance(ulong pocket, ulong board)
{
#if DEBUG
if (BitCount(pocket) != 2) throw new ArgumentException("player must have exactly 2 cards");
if (BitCount(board) != 3 && BitCount(board) != 4) throw new ArgumentException("board must contain 3 or 4 cards");
#endif
SortedDictionary dict = new SortedDictionary();
// Current Hand
uint pocketHandVal = Hand.Evaluate(pocket | board);
// Build a List of unique hands
foreach (ulong p in Hand.Hands(0UL, board, 2))
{
Debug.WriteLine("Board " + Hand.MaskToString(board));
Debug.WriteLine("P " + Hand.MaskToString(p));
uint hv = Hand.Evaluate(p | board);
if (!dict.ContainsKey(hv))
dict.Add(hv, 1);
}
// Find current hand in the sorted list
long count = dict.Count-1;
foreach (uint hv in dict.Keys)
{
Debug.WriteLine(Hand.MaskToString(hv));
if (hv == pocketHandVal)
{
return count;
}
System.Diagnostics.Debug.Assert(count >= 0);
count--;
}
System.Diagnostics.Debug.Assert(false);
return -1;
}
|
|
|
|

|
Looking for some explination on these outs.
Not sure how these are equallying 6 outs.
Hand 2s 7c
Board 6h Qc 6c
Outs 6
Hand 9s 6h
Board 8h Qd 3d
Outs 6
Hand 3h 8c
Board 8s Jh Ac
Outs 5
Hand Qd Tc
Board Jh 9c 3c
Outs 14
Ks Qs Ts 8s Kh Qh Th 8h Kd Td 8d Kc Qc 8c
Last three outs because they be counted since they could make a flush possible. Should they be discounted and is OutsEx doing any discounting?
Hand Kd 2d
Board Qs 4d 4c
Outs 6
Ks 2s Kh 2h Kc 2c
Should the 2's be discounted since hitting a 2 is probably not going to win the hand?
|
|
|
|

|
Is there a function in hand evaluator for bets possible hand based off of the board? Maybe I am missing it but I was hoping there was something for this.
Thanks
|
|
|
|

|
So lets take a flush draw only example wiht 9 outs.
to find your win % on the flop should you be doing
(9 / 47) * 100 = 19.15%
or
(9 / 47) * 100 = 19.15%
+
(9 / 46 * 100) = 19.56%
= 38.71%
Thanks
|
|
|
|

|
Is this the correct calculation for pot odds?
(Calling Amount / ( Pot Amount + Calling Amount )) + 100
so in a .05/.10 limit game
(.10 / (.80 +.10)) * 100 os 11% correct?
|
|
|
|

|
Based off of the win percent that the hand evaluator project is giving does anyone have any code or formula that they are using to base there action on based on that value?
Thanks
|
|
|
|

|
I am having issues with the odds calculator.
Why is this returning 23 outs? I only think it should be giving 9 outs
7d 8d
Ad Qd 2c
Why is this returning 23 outs? I only think it should be giving
10d Jh
Qc Kc 5s
Please let me know if you can help me out thanks.
|
|
|
|

|
I am having issues with the odds calculator.
Why is this returning 23 outs? I only think it should be giving 9 outs
7d 8d
Ad Qd 2c
Why is this returning 23 outs? I only think it should be giving
10d Jh
Qc Kc 5s
|
|
|
|

|
(i'm form argentina, so my native language is spanish, and you have to make an effort to understand my not very good english...)
Hi, it seems to be a great algorithm to evaluate poker hands, but... i don't know exactly how to use it.
I have made a program that reads the information from everest poker, and it also make a preflop and post flop game, but it doesn´t play well, in fact, it loose money...
so, how can i make your algorithm work with my program? and how can i use in the hands selection in preflop?
you will be very nice if you answer to me, and sorry if i am asking something stupid...
thanx!
eduardo.
|
|
|
|

|
I would like to add DeadCard textbox to OddsGridApp, so that I can enter cards from people which are folding, because I know theirs cards.
Can you tell me how can what function must I change, and how, so that calculator will work when I enter DeadCard.
|
|
|
|

|
Is there a way to use this Library with C++?
|
|
|
|

|
I would like to add some advices (like bet/call/raise/fold) to your example, according to the winning odds.
What is the easiest method to retrieve the cards from a given mask ?
User input : As Ks, i want to retrieve the 2 individual cards. I know how to do it but isn't it any available function/method that does it ? I didn't find one.
Thanks in advance !
|
|
|
|

|
I would like to add some advices (like bet/call/raise/fold) to your example, according to the winning odds.
What is the easiest method to retrieve the cards from a given mask ?
User input : As Ks, i want to retrieve the 2 individual cards. I know it's a shift that has to be done but i am a bit lazy
Thanks in advance !
|
|
|
|

|
Hi and thanks for a fantastic library, I have made a small application to evaluate hands and an option to play against opponents. My question is if anyone knows if there are any good examples written in C# to read information from online poker rooms (I play at Party Poker room). The functionality I most want is to automatic read my own cards and the cards from the table, and get my opponents status, ex if the fold raise or checking. I've been looking around the web but still no luck.
stha64
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A C# native, fast Texas Holdem Hand Evaluator.
| Type | Article |
| Licence | GPL3 |
| First Posted | 1 Dec 2005 |
| Views | 385,760 |
| Bookmarked | 147 times |
|
|