Poker-AI.org Poker AI and Botting Discussion Forum 2017-04-12T12:10:57+00:00 http://poker-ai.org/phpbb/feed.php?f=24&t=2553 2017-04-12T12:10:57+00:00 2017-04-12T12:10:57+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=7158#p7158 <![CDATA[Re: Best hand evaluator for C# bot?]]>
is something new available in the past years?

Sorry for pushing, hope it's fine. I just didn't want to create a new topic regarding the same question. :)

Greets

Statistics: Posted by peterJJJJ — Wed Apr 12, 2017 12:10 pm


]]>
2015-06-14T18:14:37+00:00 2015-06-14T18:14:37+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6713#p6713 <![CDATA[Re: Best hand evaluator for C# bot?]]> Statistics: Posted by cunika — Sun Jun 14, 2015 6:14 pm


]]>
2015-05-28T16:00:10+00:00 2015-05-28T16:00:10+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6686#p6686 <![CDATA[Re: Best hand evaluator for C# bot?]]> Statistics: Posted by AutoFocus — Thu May 28, 2015 4:00 pm


]]>
2015-05-28T15:53:46+00:00 2015-05-28T15:53:46+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6685#p6685 <![CDATA[Re: Best hand evaluator for C# bot?]]> best but certainly useful:
http://www.codeproject.com/Articles/190 ... -in-C-Part

Statistics: Posted by cantina — Thu May 28, 2015 3:53 pm


]]>
2015-02-15T07:54:54+00:00 2015-02-15T07:54:54+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6550#p6550 <![CDATA[Re: Best hand evaluator for C# bot?]]> Statistics: Posted by AutoFocus — Sun Feb 15, 2015 7:54 am


]]>
2015-02-14T23:03:23+00:00 2015-02-14T23:03:23+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6549#p6549 <![CDATA[Re: Best hand evaluator for C# bot?]]>
in c# for example

[DllImport("yourlibrary.dll")]
public static extern void DoSomething(string s);

public static void main() {
DoSomething("dothis");
}

Statistics: Posted by Sharkfacepoker — Sat Feb 14, 2015 11:03 pm


]]>
2014-10-29T15:09:03+00:00 2014-10-29T15:09:03+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6389#p6389 <![CDATA[Re: Best hand evaluator for C# bot?]]> It's important in my case to result into only one assembly to hide this DLL.

My wrapper.cpp file actually contains :

Quote:

#include "wrapper.h"

extern "C" __declspec(dllexport) void __stdcall Calculate(const char* hands, const char* board, const char* dead, __int64* trialCount, double* results, double* player_results, double* opponent_results, double* Tie)
{
memset(results, 0, 23);
memset(player_results, 0, 9);
memset(opponent_results, 0, 9);
*Tie = 0;
HoldemCalculator calc;
calc.Calculate(hands, board, dead, trialCount, results, player_results, opponent_results, Tie);
calc.deletemdists();
}


Thanks if somebody can help.

Statistics: Posted by AutoFocus — Wed Oct 29, 2014 3:09 pm


]]>
2014-10-29T08:35:01+00:00 2014-10-29T08:35:01+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6386#p6386 <![CDATA[Re: Best hand evaluator for C# bot?]]>
A good thing would be to add unit tests with :
A9o-AQo,62s+,62o+
because that's why those tests were missing that the bug wasn't found.
Anyway, happy to have a working ranges calculator now !

Autofocus

Statistics: Posted by AutoFocus — Wed Oct 29, 2014 8:35 am


]]>
2014-10-29T08:26:14+00:00 2014-10-29T08:26:14+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6385#p6385 <![CDATA[Re: Best hand evaluator for C# bot?]]>
Will update mine too.

Statistics: Posted by shadehs — Wed Oct 29, 2014 8:26 am


]]>
2014-10-28T19:10:26+00:00 2014-10-28T19:10:26+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6384#p6384 <![CDATA[Re: Best hand evaluator for C# bot?]]> or ranges like ATo - AQo so the tests will pass without seeing this huge bug.

Statistics: Posted by AutoFocus — Tue Oct 28, 2014 7:10 pm


]]>
2014-10-28T19:06:53+00:00 2014-10-28T19:06:53+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6383#p6383 <![CDATA[Re: Best hand evaluator for C# bot?]]>
I made the correction and it seems to be all working now, could you please pass again your tests
as I removed the Poker.Equity.Test Project ? Ty

Autofocus

Statistics: Posted by AutoFocus — Tue Oct 28, 2014 7:06 pm


]]>
2014-10-28T17:59:56+00:00 2014-10-28T17:59:56+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6381#p6381 <![CDATA[Re: Best hand evaluator for C# bot?]]>
Code:
double expected[23];
   int numberOfTrials = 1000000;

   {
      // 7-way matchup involving 2 specific hands, 2 ranged hands, and 3 random hands, on the flop
      double expected[] = { 37.1, 5.5, 19.2, 5.9, 10.75, 10.75, 10.75  };
      performMatchup("AhKh|Td9s|QQ+,AQs+,AQo+|JJ-88|XxXx|XxXx|XxXx", "Ks7d4d", "", 1000000, false, expected);
   }

   {
      // AA vs. KK of any suits: Monte Carlo + Exhaustive
      double expected[] = { 81.9, 18.1 };
      performMatchup("AA|KK", NULL, NULL, numberOfTrials, true, expected);
   }


   {
      // AA vs. KK of any suits with flop [Th Jc Qs]: Monte Carlo + Exhaustive
      double expected[] = { 75.9, 24.1 };
      performMatchup("AA|KK", "ThJcQs", NULL, numberOfTrials, true, expected);
   }


   {
      // 10-way preflop all-in with AA through 55: Monte Carlo
      double expected[] = { 24.3, 18.8, 14.1, 10.6, 8.1, 6.0, 4.7, 4.2, 4.5, 4.8};
      performMatchup("AA|KK|QQ|JJ|TT|99|88|77|66|55", NULL, NULL, numberOfTrials, false, expected);
   }


   {
      // 10-way preflop all-in with AA through 55 with flop of [2c3s4d]: Monte Carlo
      double expected[] = { 13.5, 10.6, 9.6, 8.6, 7.6, 6.7, 5.7, 5.7, 12.6, 19.5};
      performMatchup("AA|KK|QQ|JJ|TT|99|88|77|66|55", "2c3s4d", NULL, numberOfTrials, false, expected);
   }

   {
      // Aces vs. Kings with shared suits
      double expected[] = { 82.6, 17.4 };
      performMatchup("AsAc|KsKc", NULL, NULL, numberOfTrials, true, expected);
   }

   {
      // Specific hands and hand ranges in the same trial
      double expected[] = { 30.8, 15.5, 38.1, 15.6 };
      performMatchup("AhKh|2d2c|77|A2s+", NULL, NULL, numberOfTrials, false, expected);
   }

   {
      // Aces versus 5 random/uknown hands
      double expected[] = { 82.6, 17.4 };
      performMatchup("AcAs,KcKs|QcQs", NULL, NULL, numberOfTrials, true, expected);
   }


   {
      // Aces versus 5 random/uknown hands
      double expected[] = { 49.2, 10.15, 10.15, 10.15, 10.15, 10.15 };
      performMatchup("AA|XxXx|XxXx|XxXx|XxXx|XxXx", NULL, NULL, numberOfTrials, false, expected);
   }


   {
      // Typical 3-way matchup - pocket pair vs. loose-ish vs. tight-ish
      double expected[] = { 37.1, 19.5, 43.4 };
      performMatchup("TsTc|A2+,22+|QQ+,AQ+", NULL, NULL, numberOfTrials, false, expected);
   }

I corrected the first test but in the second it still fails. Did you check the project "Poker.Equity.Test" ? You should run it in debug mode.

Statistics: Posted by shadehs — Tue Oct 28, 2014 5:59 pm


]]>
2014-10-28T15:48:32+00:00 2014-10-28T15:48:32+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6380#p6380 <![CDATA[Re: Best hand evaluator for C# bot?]]>
Important points :

- You will have to write TT-AA, not anymore AA-TT
- I don't care about K2+, you have to say K2s+ and K2o+
- I don't care about the special rule concerning suited connectors, so QJs+ will be QJ and 98o+ will be equal to 98

If you agree with all of that, there shouln't be bug anymore, I get the good number of combinations each time now.

Statistics: Posted by AutoFocus — Tue Oct 28, 2014 3:48 pm


]]>
2014-10-27T21:49:08+00:00 2014-10-27T21:49:08+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6378#p6378 <![CDATA[Re: Best hand evaluator for C# bot?]]>
I must say that I changed a part, you must now enter TT-AA or ATo-AQo instead of AA-TT,AQo-ATo which is best.
It can provoque a bug, if the order isn't this one.
Please tell me which hands you entered if your bug wasn't because of it, but it's all working for me :)

Statistics: Posted by AutoFocus — Mon Oct 27, 2014 9:49 pm


]]>
2014-10-27T21:05:55+00:00 2014-10-27T21:05:55+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6377#p6377 <![CDATA[Re: Best hand evaluator for C# bot?]]> Got "Vector subscript is out of range".
The code is not mine, is from coding the wheel website (now dead).
http://web.archive.org/web/201301221754 ... in-poker-1

Statistics: Posted by shadehs — Mon Oct 27, 2014 9:05 pm


]]>
2014-10-29T09:21:44+00:00 2014-10-27T17:26:13+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=6376#p6376 <![CDATA[Re: Best hand evaluator for C# bot?]]> I only needed to correct a few things in the ranges generation part, in AgnosticHand.cpp
Incrementing both first card and second card value wasn't correct in the case of KTo+ for example.
KTo+ means KTo, KJo, KQo. Your code was actually returning KTo, AJo that's why it didn't work with ranges.
Why were so many mistakes in such an important function, was it to see if we were enough good to use it ? :)
Here is the rewritten hand range combinations function.

Regards,

Autofocus

Quote:

///////////////////////////////////////////////////////////////////////////////
// Take a given agnostic hand, such as "AA" or "AJs+" or "77-TT", along with
// an optional collection of "dead" cards, and boil it down into its constituent
// specific Hold'em hands, storing these in the 'specificHands' vector passed
// in by the client.
// XxXx means a full range
// You can use the A9o - AQo notation => (A9o, ATo, AJo, AQo) or 77-TT => (77,88,99,TT)
// You can use the QQ+ notation => (QQ,KK,AA) or KTS+ => (KTs,KJs,KQs)
// You must always specify if you are considering suited and/or offsuited so don't forget the s or o suffix for each range except pockets
// There is no special rule regarding connectors, so QJs+ => (QJs) and 98o+ => (98o)
//
// Returns the number of specific hands the agnostic hand contains.
///////////////////////////////////////////////////////////////////////////////
int AgnosticHand::Instantiate(const char* handText, StdDeck_CardMask deadCards, vector<StdDeck_CardMask>& specificHands)
{
if (strcmp(handText, "XxXx") == 0)
{
return InstantiateRandom(deadCards, specificHands);
}

bool isPlus = (NULL != strchr(handText, '+'));
bool isSlice = (NULL != strchr(handText, '-'));
int handRanks[3] = { 0, 0, 0 };
if (isSlice) // TT - AA, ATo - AQo
{
const char* index = strchr(handText, '-');

char handCeil[4];
char handFloor[4];
strncpy(handFloor, handText, index - handText);
strcpy(handCeil, index + 1);

handRanks[0] = Card::CharToRank(handFloor[0]);
handRanks[1] = Card::CharToRank(handFloor[1]);
handRanks[2] = Card::CharToRank(handCeil[1]);
}
else // K2s+ or 32s
{
handRanks[0] = Card::CharToRank(handText[0]);
handRanks[1] = Card::CharToRank(handText[1]);
}

StdDeck_CardMask hand;

int combos = 0;

if (IsPair(handText))
{
StdDeck_CardMask card1, card2;

for (int rank = handRanks[0]; rank <= (isSlice ? handRanks[2] : (isPlus ? Card::Ace : handRanks[1])); rank++)
{
for(int suit1 = StdDeck_Suit_FIRST; suit1 <= StdDeck_Suit_LAST; suit1++)
{
for (int suit2 = suit1 + 1; suit2 <= StdDeck_Suit_LAST; suit2++)
{
card1 = StdDeck_MASK( StdDeck_MAKE_CARD(rank, suit1) );
card2 = StdDeck_MASK( StdDeck_MAKE_CARD(rank, suit2) );
StdDeck_CardMask_OR(hand, card1, card2);
if (!StdDeck_CardMask_ANY_SET(deadCards, hand))
{
specificHands.push_back(hand);
combos++;
}
}
}
}
}
else if (IsSuited(handText))
{
StdDeck_CardMask card1, card2, hand;

for (int rank1 = handRanks[1]; rank1 <= (isSlice ? handRanks[2] : (isPlus ? handRanks[0]-1 : handRanks[1])); rank1++)
{
for(int suit = StdDeck_Suit_FIRST; suit <= StdDeck_Suit_LAST; suit++) // 4 colors
{
card1 = StdDeck_MASK(StdDeck_MAKE_CARD(handRanks[0], suit));
card2 = StdDeck_MASK( StdDeck_MAKE_CARD(rank1, suit) );
StdDeck_CardMask_OR(hand, card1, card2);
if (!StdDeck_CardMask_ANY_SET(deadCards, hand))
{
specificHands.push_back(hand);
combos++;
}
}
}
}
else if (IsOffSuit(handText))
{
StdDeck_CardMask card1, card2, hand;

for (int rank1 = handRanks[1]; rank1 <= (isSlice ? handRanks[2] : (isPlus ? handRanks[0]-1 : handRanks[1])); rank1++)
{
for(int suit1 = StdDeck_Suit_FIRST; suit1 <= StdDeck_Suit_LAST; suit1++)
{
for (int suit2 = StdDeck_Suit_FIRST; suit2 <= StdDeck_Suit_LAST; suit2++)
{
if (suit1 == suit2)
continue;

card1 = StdDeck_MASK(StdDeck_MAKE_CARD(handRanks[0], suit1));
card2 = StdDeck_MASK( StdDeck_MAKE_CARD(rank1, suit2) );
StdDeck_CardMask_OR(hand, card1, card2);
if (!StdDeck_CardMask_ANY_SET(deadCards, hand))
{
specificHands.push_back(hand);
combos++;
}
}
}
}
}

return combos;
}

Statistics: Posted by AutoFocus — Mon Oct 27, 2014 5:26 pm


]]>
2013-08-30T21:00:46+00:00 2013-08-30T21:00:46+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4767#p4767 <![CDATA[Re: Best hand evaluator for C# bot?]]> Seikez wrote:

Quote:
This is an example of how to use XPokerEquity with C#;

Thanks shadehs!
I have tried it out and it works great. I can also extend your wrapper to call other functions in XPokerEquity from C#.


There is a serious bug that i forgot to remove in the files that i uploaded:
in HoldemCalculator.cpp row 48, you have to sobstitute Calculate method with this one:
Code:
///////////////////////////////////////////////////////////////////////////////
// Calculate equities for the specified matchup using either Monte Carlo
// or Exhaustive Enumeration.
///////////////////////////////////////////////////////////////////////////////
int HoldemCalculator::Calculate(const char* hands, const char* board, const char* dead, __int64 trialCount, double* outResults)
{
   PreCalculate(hands, board, dead, trialCount, outResults);

   
      CalculateMonteCarlo();
   

   return PostCalculate();
}

Or you will not be able to calculate the river for some hands.

Statistics: Posted by shadehs — Fri Aug 30, 2013 9:00 pm


]]>
2013-08-27T12:57:26+00:00 2013-08-27T12:57:26+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4721#p4721 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

This is an example of how to use XPokerEquity with C#;

Thanks shadehs!
I have tried it out and it works great. I can also extend your wrapper to call other functions in XPokerEquity from C#.

Statistics: Posted by Seikez — Tue Aug 27, 2013 12:57 pm


]]>
2013-08-26T23:04:19+00:00 2013-08-26T23:04:19+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4720#p4720 <![CDATA[Re: Best hand evaluator for C# bot?]]>
Maybe it's something you are doing that is making it take more than a second with that code base.

Are you running in release or debug mode ?

I should also clarify what hand or is it hand range that you are doing ?

Statistics: Posted by Sharkfacepoker — Mon Aug 26, 2013 11:04 pm


]]>
2013-08-26T19:18:49+00:00 2013-08-26T19:18:49+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4717#p4717 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

Post flop should be instantaneous given the iterations are so small. The of where you do the equity should be no different to doing it preflop.


Well I must be doing something wrong then because its not fast at all. The only equity that is instantaneous is hand vs random hand which is pretty much useless (such as Timmys) for HU. I think (not positive) that is called absolute equity. For any kind of range equity it seems to take time as winnie and I are having similar problems. I am using the PPT java based command line tool for range equity which is probably most of my problem. Nasher said it might be compiling on each run which would cause a big slowdown. I am not sure if it does that or not so I am trying to build a native solution using the pokerstove code.

I did try using Timmys for each 1326 hand combos to see how it would fair and it did terrible. It took about a minute to complete. Pokerstove blew it away in about 3 seconds.

Statistics: Posted by shalako — Mon Aug 26, 2013 7:18 pm


]]>
2013-08-26T18:43:53+00:00 2013-08-26T18:43:53+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4716#p4716 <![CDATA[Re: Best hand evaluator for C# bot?]]>
It should be in the place where you check for tie and wins. You add a +1 for each win in the iteration and if it's a tie then 1 / number of players who tied on that given iteration.
The sum of those divided by number of outcomes
Will give you the equity.

Statistics: Posted by Sharkfacepoker — Mon Aug 26, 2013 6:43 pm


]]>
2013-08-26T19:05:50+00:00 2013-08-26T18:17:50+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4715#p4715 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

does anybody know or share a postflop lookuptable?
I' using the xpoker equity calculator for doing the ev calculations during runtime -> is very often too slow (especially every hand vs every hand in an range for 2 players)


I am having a similar slowness problem post flop. I currently have to pass each combo to the evaluator and it is around 4-5 seconds for an equity decision which is ok for one table but not for multiple. LUTS will not really work for me as the ranges are all broken up into specific hands postflop. Preflop I guess a LUT would work most of the time but for a 3B or 4B you would still need to range a specific set of hands but I guess you could stove all those for a LUT too. Postflop I do not see a LUT working at all..especially on the turn and river for a calling range. If the villain is leading the whole time you could LUT it I guess.

Right now I am trying to use the pokerstove code that was just released a few months ago. Since it has been highly optimized over the years I am hoping I can get more speed.

Statistics: Posted by shalako — Mon Aug 26, 2013 6:17 pm


]]>
2013-08-26T17:54:06+00:00 2013-08-26T17:54:06+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4714#p4714 <![CDATA[Re: Best hand evaluator for C# bot?]]> I' using the xpoker equity calculator for doing the ev calculations during runtime -> is very often too slow (especially every hand vs every hand in an range for 2 players)

atm I have no clue how to do it myself.


thanks

Statistics: Posted by winnie — Mon Aug 26, 2013 5:54 pm


]]>
2013-08-25T00:34:40+00:00 2013-08-25T00:34:40+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4701#p4701 <![CDATA[Re: Best hand evaluator for C# bot?]]>
I know Pro Poker tools is smoking fast but I believe they are using LUTs and have a nice server I suppose. Could be C or Java implementation.

Does anyone here have an iPad or IPhone or iPod touch, I have some free promo codes and can let you see how fast/slow the app is on a device.

Omaha takes about 3-4 seconds without a board for iPad2 a bit less on iPad3 or iPhone 5.

All the other odds calculations are generally a second or less. Not bad with no major lookups on little mobile processors. This is without community cards of course. With them both hold'em and Omaha are instantaneous.

For Omaha heads up is 1 million + hands but in getting that there are about 120 million iterations since each player has 6 hands from their four cards. On a core I7 with no major lookups I can get it down to about 400ms.

Again LUTS are probably instantaneous but for what I need that will suffice not having LUT.

Again I'm not sure for Bots what is needed.

Statistics: Posted by Sharkfacepoker — Sun Aug 25, 2013 12:34 am


]]>
2013-08-24T21:57:18+00:00 2013-08-24T21:57:18+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4699#p4699 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

The lookup tables are the fastest but you can still get terrific speeds without.

I can't say I've done any benchmarking, but I would say this is not strictly true... By far and away the slowest thing a modern PC does is accessing a disk, and the second slowest thing a modern PC does is accessing RAM. A CPU can perform hundreds of calculations in the same amount of time it takes to read something from uncached memory.

If you somehow create a lookup you can cram into the CPU cache, then yes, it'll be faster. Also, if you perform sequential lookups, then I suspect the lookup table will be faster. For random hands, depending on the PC setup, I'd guess doing the calculations might win the race. Especially as CPU speeds have increased a lot more than RAM speeds over the years.

Maybe I'll do some experimentation sometime.

Quote:

OK guys, I hear what you are saying! Pre-calculation is obviously the best way to speed up hand evaluation.

Could you please tell me how to actually do it with 1 to 9 opponents (all with different hand ranges) and for all betting rounds?

Lookup tables.

Statistics: Posted by OneDayItllWork — Sat Aug 24, 2013 9:57 pm


]]>
2013-08-24T04:31:47+00:00 2013-08-24T04:31:47+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4698#p4698 <![CDATA[Re: Best hand evaluator for C# bot?]]> Seikez wrote:

I need a reliable, easy to use and fast (in that priority order) hand evaluator for my Holdem C# Bot. Preferably with documentation and usage examples.

So for this bot

It should handle preflop, flop, turn and river (2, 5, 6 and 7 cards). It should handle 1 - 9 opponents. I also need functions to calculate win probability, EV and other things my bot might need.

The alternatives I have found are all several years old, which makes me unsure which is the best choice today.

I therefore turn to you guys for some advice, it will be greatly appreciated!


Hi I was reading through this thread and can tell you from personally coding hand evaluators in both C# and then porting my code to c++ is that C++ is faster.

I have two apps that sell in the iTunes app store one is cloud based Windows Azure Single Core processor with C# api engine based a lot of the same approach that Keith Rule did.

The other was converted to c++ and Runs for five HORSE games and uses logic and approach from various libraries and own code, none of which are poker eval, although im sure all the ideas derived from that since its pretty much the grandfather of evaluators. I used similar logic and approach for holdem to Stud and Eight or better. I do not use pinvoke and I do not have lookup tables since I can't have an app in the store that is 150mb :)

Pointers make a huge difference and while you can use unsafe code in c# it still is not as fast as moving to raw c++.

If you use Keith Rules Code base you should get pretty fast times.

If you want to know how equity can be incorporated into it, Here is what I did and its how you could use Keith Rules Library since the if logic is nearly the same for all evaluators.

In Keith's the evaluator code where you see a line like

for(int i = 0; i < playerCount; i++)
{
if(pocketHands[i] == bestpocket)
{
if(bestCount > 1)
{
//Equity numerator is a "1" its always 1 divided by the number of people participating in the tie.
playerEquity[i] += equitynumerator / bestcount;
playerties[i] ++;
}
else
{
playerwins[i]++;
playerEquity[i]++;
}
}
}


I have separate arrays since I want wins, ties and equity. Look at Keith's code and you can add a float or double whichever to get the equity on top of wins or ties.
The key is knowing how many people tie on each iteration. Is there a faster way to do this ? I imagine sure probably many but that worked for me.

Also to make your c# code slightly faster go into the settings and check "allow unsafe code" Your c# will run faster and you will not be jeopardizing anything.

I had originally used some of the code logic from Keith Rules project when I had done the C# version but starting deviating and then by the time I had writing the c++ logic more of it was new new besides assigning values to cards.

I suspect most of the commercial poker software be it, HUDs, odds calculators are using some evolution of poker eval, Two Plus Two etc. The lookup tables are the fastest but you can still get terrific speeds without.

Now do a search for PokerStove evaluator.
The guy recently put all of his source code available for download and most people consider that the best Equity Calculator.

https://github.com/andrewprock/pokerstove

I haven't looked at this yet but bet a lot of his logic is similar to the older libraries.

Feel free to email me [email protected] if you have any other questions I like helping out others when I can since if it wasn't for these open source libraries most
of the software would never exist at least not as widely as it does today :)

Statistics: Posted by Sharkfacepoker — Sat Aug 24, 2013 4:31 am


]]>
2013-08-23T09:53:32+00:00 2013-08-23T09:53:32+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4693#p4693 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

calculating equity against a probability distribution of 1326 hands becomes trivial with a pre-calculated matrix

and
Quote:

The only place I do live evaluation is showdown... perfectly possible to pre-calculate everything for the river too

OK guys, I hear what you are saying! Pre-calculation is obviously the best way to speed up hand evaluation.

Could you please tell me how to actually do it with 1 to 9 opponents (all with different hand ranges) and for all betting rounds?

Statistics: Posted by Seikez — Fri Aug 23, 2013 9:53 am


]]>
2013-08-19T09:39:47+00:00 2013-08-19T09:39:47+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4681#p4681 <![CDATA[Re: Best hand evaluator for C# bot?]]> Statistics: Posted by OneDayItllWork — Mon Aug 19, 2013 9:39 am


]]>
2013-08-18T13:19:39+00:00 2013-08-18T13:19:39+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4676#p4676 <![CDATA[Re: Best hand evaluator for C# bot?]]>
I always used the poker-eval c library - pinvoked from c#.

However I'd recommend lots pre-calculation and lookup tables. With a bit of effort you can avoid almost all live hand evaluations this way - making the performance of the evaluator fairly irrelevant. In fact this approach opens the door to doing far more complex evaluations than would be possible to calculate in realtime - e.g. calculating equity against a probability distribution of 1326 hands becomes trivial with a pre-calculated matrix - but would be challenging if calculated explicitly.

The only place I think live evaluation is necessary is on the river - where the calculations are trivial anyway.

- PeppaPig

Statistics: Posted by PeppaPig — Sun Aug 18, 2013 1:19 pm


]]>
2013-08-18T10:06:29+00:00 2013-08-18T10:06:29+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4674#p4674 <![CDATA[Re: Best hand evaluator for C# bot?]]>
I'll have a look at it. I am busy with other things now so it might take me a while.

Statistics: Posted by Seikez — Sun Aug 18, 2013 10:06 am


]]>
2013-08-17T23:17:47+00:00 2013-08-17T23:17:47+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4671#p4671 <![CDATA[Re: Best hand evaluator for C# bot?]]>
There is also a function to free the memory, because there was a bug that it wasn't freeing the memory allocated.
Also exhaustive method is reported to be bugged at river in certain circumstances, so i use only Monte Carlo simulation.

Statistics: Posted by shadehs — Sat Aug 17, 2013 11:17 pm


]]>
2013-08-17T18:48:22+00:00 2013-08-17T18:48:22+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4670#p4670 <![CDATA[Re: Best hand evaluator for C# bot?]]>
I'll try to isolate the functions and write a wrapper that works for the example, so you will see.

Statistics: Posted by shadehs — Sat Aug 17, 2013 6:48 pm


]]>
2013-08-16T22:37:01+00:00 2013-08-16T22:37:01+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4668#p4668 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

I use this in my bot with a wrapper.

I would be interested in having a look at that wrapper. How can I get it?

Statistics: Posted by Seikez — Fri Aug 16, 2013 10:37 pm


]]>
2013-08-16T13:16:39+00:00 2013-08-16T13:16:39+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4666#p4666 <![CDATA[Re: Best hand evaluator for C# bot?]]> Seikez wrote:

Anyone know the status of the XpokerEquity functions? See here: http://www.codingthewheel.com/archives/ ... n-poker-1/

I have found the source, but what is the status? Are there bugs in it (someone said it doesn't return the same Equity as pokerstove)?

Anyone have a C# wrapper for it?

Any alternative that does the same, but in C# ?

I use this in my bot with a wrapper. Don't know if it's fast or not, anyway it works good for my needs. Also you need to manually free the memory, not a difficult task anyway.

Statistics: Posted by shadehs — Fri Aug 16, 2013 1:16 pm


]]>
2013-08-16T08:37:58+00:00 2013-08-16T08:37:58+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4664#p4664 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

Did you try http://www.codeproject.com/Articles/190 ... n-C-Part-2
Keith adds MonteCarlo analysis and multicore support.

I have tested with the code from part 1 of that article, and if I am not mistaken the download link for the two articles point to exactly the same code. So yes, I have tried that link.


Quote:

Are you not getting a little hung up on the speed of the evaluator?

Ahh, hmmm, well... yes, maybe I am. Thank you for bringing me back to reality. I think what I will do is use Keith's evaluator for a first version of my bot. Then if I find I need more speed, I will have another look at this. Thanks! :)

Statistics: Posted by Seikez — Fri Aug 16, 2013 8:37 am


]]>
2013-08-15T15:07:15+00:00 2013-08-15T15:07:15+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4663#p4663 <![CDATA[Re: Best hand evaluator for C# bot?]]> Statistics: Posted by OneDayItllWork — Thu Aug 15, 2013 3:07 pm


]]>
2013-08-15T10:47:59+00:00 2013-08-15T10:47:59+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4661#p4661 <![CDATA[Re: Best hand evaluator for C# bot?]]> http://www.codeproject.com/Articles/19092/More-Texas-Holdem-Analysis-in-C-Part-2
Keith adds MonteCarlo analysis and multicore support.

Statistics: Posted by LOLWorld — Thu Aug 15, 2013 10:47 am


]]>
2013-08-15T09:54:41+00:00 2013-08-15T09:54:41+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4660#p4660 <![CDATA[Re: Best hand evaluator for C# bot?]]>
It is well documented and I have no reason to doubt it's reliability, but I feel the speed difference compared to other alternatives is too big to be ignored. What a pity! :(

Statistics: Posted by Seikez — Thu Aug 15, 2013 9:54 am


]]>
2013-08-14T21:47:17+00:00 2013-08-14T21:47:17+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4657#p4657 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

When you run your tests, are you pre-populating a list of random hands and running though that? If not, you should be.

Well, actually I am not sure exactly what I am doing. I am running the program named 'Benchmark' and just select a menu item to pick a test to run. The benchmark program comes in the code you can download from this link: http://www.codeproject.com/Articles/19091/More-Texas-Holdem-Analysis-in-C-Part-1 If I understand it correctly, this article is a follow-up to the article in the link you gave me, OneDayItllWork.

I will give it one more try, because the exception suggests something isn't quite right. I suspect the Evaluator dll isn't built because of a dependency that is missing. This means the benchmark is compiled with net 4.0 and the evaluator is compiled for some much older .NET version but run under 4.0, which might hurt it's speed, that's my theory anyway. I will try to fix it so the evaluator dll builds and will then run the benchmarks again. After that I will report back.

Statistics: Posted by Seikez — Wed Aug 14, 2013 9:47 pm


]]>
2013-08-14T17:07:03+00:00 2013-08-14T17:07:03+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4653#p4653 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

Managed to run last test on view menu (Thread Pool Evaluate/Iterate) in Debug mode and are getting 80-100M hands/sec. This is slooooow compared to some other evaluators.


If you just want a good 6 and 7 card evaluator you could use the 2p2 C code or the java port to generate a lookup table file and then write your own very small evaluator in C#. The speed of that should be as fast as it gets. Maybe one hour's work for someone who is fluent in C# and C.

Statistics: Posted by spears — Wed Aug 14, 2013 5:07 pm


]]>
2013-08-14T16:54:09+00:00 2013-08-14T16:54:09+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4652#p4652 <![CDATA[Re: Best hand evaluator for C# bot?]]>
When you run your tests, are you pre-populating a list of random hands and running though that? If not, you should be.

Statistics: Posted by OneDayItllWork — Wed Aug 14, 2013 4:54 pm


]]>
2013-08-14T16:05:07+00:00 2013-08-14T16:05:07+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4651#p4651 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

I use this:
http://www.codeproject.com/Articles/122 ... d-Analysis

Lots of features - there are a few speed improvements that can be made too.

I have run the benchmark included in this, and I am not impressed by the speed. On my i7 2600K running @ 4.2GHz I get 40-50M hands/sec for the first test on view menu (Evaluate) in Release mode. Debug mode 30-40M hands/sec.

In release configuration, I am getting an exception for most of the other tests: "A first chance exception of type 'System.Threading.ThreadAbortException' occurred in HandEvaluator.dll"

Managed to run last test on view menu (Thread Pool Evaluate/Iterate) in Debug mode and are getting 80-100M hands/sec. This is slooooow compared to some other evaluators.

@OneDayItllWork, What speeds are you getting with the Keith Rule c# evaluator?

Statistics: Posted by Seikez — Wed Aug 14, 2013 4:05 pm


]]>
2013-08-14T12:54:26+00:00 2013-08-14T12:54:26+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4649#p4649 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

I use this:
http://www.codeproject.com/Articles/122 ... d-Analysis

Lots of features - there are a few speed improvements that can be made too.

Yes, I know about that. Still collecting info so haven't yet started locking closer at it, but will soon.

It is based on this (http://www.codeproject.com/Articles/19091/More-Texas-Holdem-Analysis-in-C-Part-1) isn't it?

Quote:

there are a few speed improvements that can be made too

Are they secret? Want to share them with the rest of us?

Statistics: Posted by Seikez — Wed Aug 14, 2013 12:54 pm


]]>
2013-08-14T11:49:23+00:00 2013-08-14T11:49:23+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4648#p4648 <![CDATA[Re: Best hand evaluator for C# bot?]]> http://www.codeproject.com/Articles/122 ... d-Analysis

Lots of features - there are a few speed improvements that can be made too.

Statistics: Posted by OneDayItllWork — Wed Aug 14, 2013 11:49 am


]]>
2013-08-14T10:46:45+00:00 2013-08-14T10:46:45+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4647#p4647 <![CDATA[Re: Best hand evaluator for C# bot?]]> http://www.codingthewheel.com/archives/ ... n-poker-1/

I have found the source, but what is the status? Are there bugs in it (someone said it doesn't return the same Equity as pokerstove)?

Anyone have a C# wrapper for it?

Any alternative that does the same, but in C# ?

Statistics: Posted by Seikez — Wed Aug 14, 2013 10:46 am


]]>
2013-08-14T10:37:03+00:00 2013-08-14T10:37:03+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4646#p4646 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

http://www.codeproject.com/Articles/19091/More-Texas-Holdem-Analysis-in-C-Part-1

Yes, that is one alternative I will have a closer look at. Do you have any experience with it, LoLWorld? Is it reliable and bug free, thread safe?

Statistics: Posted by Seikez — Wed Aug 14, 2013 10:37 am


]]>
2013-08-13T21:08:59+00:00 2013-08-13T21:08:59+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4645#p4645 <![CDATA[Re: Best hand evaluator for C# bot?]]> Statistics: Posted by OneDayItllWork — Tue Aug 13, 2013 9:08 pm


]]>
2013-08-13T19:38:16+00:00 2013-08-13T19:38:16+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4644#p4644 <![CDATA[Re: Best hand evaluator for C# bot?]]> I remember doing some tests at work comparing C++ and C# speed, I used a simple matrix multiplication and got roughly the same speed in both. In one of the tests C# was even a tiny fraction of time faster.
So I think with a bit of looking into it I should be able to get very similar performance in C# for simple arithmetic operations like hand evaluation.

Statistics: Posted by vlad2048 — Tue Aug 13, 2013 7:38 pm


]]>
2013-08-13T17:04:25+00:00 2013-08-13T17:04:25+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4643#p4643 <![CDATA[Re: Best hand evaluator for C# bot?]]> http://www.codeproject.com/Articles/19091/More-Texas-Holdem-Analysis-in-C-Part-1

Statistics: Posted by LOLWorld — Tue Aug 13, 2013 5:04 pm


]]>
2013-08-13T08:27:11+00:00 2013-08-13T08:27:11+00:00 http://poker-ai.org/phpbb/viewtopic.php?t=2553&p=4640#p4640 <![CDATA[Re: Best hand evaluator for C# bot?]]> Quote:

I don't know the best answer.
I've ported the poker-eval 7 card evaluation function to c# (exactly the same with all the table lookups) and it's 10x slower
I wonder why ?

Make sure you time it with VisualStudio set to Release configuration, it makes a big difference compared to Debug. And remember highly optimized C++ will always be faster than C# (about 1.5 - 3 times I think).

If you are still 10 times slower, try to use some kind of profiler (for instance Red-gate or Jetbrains) to track down where your CPU spends it's time and optimize that part. If that doesn't help, I think you can write IL code directly in your C# program, which is sort of like the asm directive in some C/C++ compilers.
Also check this page for C# optimization: http://www.dotnetperls.com/optimization

Statistics: Posted by Seikez — Tue Aug 13, 2013 8:27 am


]]>