Poker-AI.org
https://poker-ai.org/phpbb/

Best hand evaluator for C# bot?
https://poker-ai.org/phpbb/viewtopic.php?f=24&t=2553
Page 3 of 3

Author:  AutoFocus [ Tue Oct 28, 2014 3:48 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

Please tell me if it all work for you with the version I just posted.

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.

Author:  shadehs [ Tue Oct 28, 2014 5:59 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

I tested using the test code:
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.

Author:  AutoFocus [ Tue Oct 28, 2014 7:06 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

Hello, and thank you, I forgot the case of a single pair like KK in opponent range :)
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

Author:  AutoFocus [ Tue Oct 28, 2014 7:10 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

I read again the tests and in fact, it doesn't test ranges like K2o+ and the old code was only working with Ax+ not K2s+ or Q6s+
or ranges like ATo - AQo so the tests will pass without seeing this huge bug.

Author:  shadehs [ Wed Oct 29, 2014 8:26 am ]
Post subject:  Re: Best hand evaluator for C# bot?

Nice find :)
Will update mine too.

Author:  AutoFocus [ Wed Oct 29, 2014 8:35 am ]
Post subject:  Re: Best hand evaluator for C# bot?

Ty ;)
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

Author:  AutoFocus [ Wed Oct 29, 2014 3:09 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

Do someone know how to create a C++ COM DLL to access it directly from C# without Pinvoke ?
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.

Author:  Sharkfacepoker [ Sat Feb 14, 2015 11:03 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

When I try need to call a c++ dll in C# I have always used DLLImport attribute in C#.

in c# for example

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

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

Author:  AutoFocus [ Sun Feb 15, 2015 7:54 am ]
Post subject:  Re: Best hand evaluator for C# bot?

Ty but this is the call I want to avoid, DllImport = Pinvoke

Author:  cantina [ Thu May 28, 2015 3:53 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

Maybe not the best but certainly useful:
http://www.codeproject.com/Articles/190 ... -in-C-Part

Author:  AutoFocus [ Thu May 28, 2015 4:00 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

Hi, I help you with all the PartyPoker part, do you have a working AI for now ?

Author:  cunika [ Sun Jun 14, 2015 6:14 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

.

Author:  peterJJJJ [ Wed Apr 12, 2017 12:10 pm ]
Post subject:  Re: Best hand evaluator for C# bot?

Hey guys,

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

Page 3 of 3 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/