Poker-AI.org

Poker AI and Botting Discussion Forum
It is currently Mon Nov 13, 2023 2:08 pm

All times are UTC




Post new topic Reply to topic  [ 53 posts ]  Go to page 1, 2, 3  Next
Author Message
PostPosted: Mon Aug 12, 2013 9:33 pm 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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.

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!


Top
 Profile  
 
PostPosted: Mon Aug 12, 2013 10:00 pm 
Offline
Junior Member

Joined: Mon Aug 12, 2013 7:28 pm
Posts: 16
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 ?


Top
 Profile  
 
PostPosted: Mon Aug 12, 2013 10:06 pm 
Offline
Veteran Member

Joined: Mon Mar 04, 2013 9:40 pm
Posts: 269
I use Timmys available here for absolute equity and hand state info. For range equity I use propokertools which has a nice shell script but its a bit slow. There are probably faster native or DLL based range equity calculators that you could use.


Top
 Profile  
 
PostPosted: Tue Aug 13, 2013 8:27 am 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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


Top
 Profile  
 
PostPosted: Tue Aug 13, 2013 5:04 pm 
Offline
Junior Member

Joined: Sun Mar 10, 2013 10:30 am
Posts: 20
http://www.codeproject.com/Articles/19091/More-Texas-Holdem-Analysis-in-C-Part-1


Top
 Profile  
 
PostPosted: Tue Aug 13, 2013 7:38 pm 
Offline
Junior Member

Joined: Mon Aug 12, 2013 7:28 pm
Posts: 16
Hey thanks Seikez, release mode made it 40% faster, I'll look into the rest when I'll need the speed later.
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.


Top
 Profile  
 
PostPosted: Tue Aug 13, 2013 9:08 pm 
Offline
Regular Member

Joined: Sun Mar 03, 2013 11:55 am
Posts: 64
You'll also get more speed running without the debugger attached.


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 10:37 am 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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?


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 10:46 am 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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# ?


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 11:49 am 
Offline
Regular Member

Joined: Sun Mar 03, 2013 11:55 am
Posts: 64
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.


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 12:54 pm 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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?


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 4:05 pm 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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?


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 4:54 pm 
Offline
Regular Member

Joined: Sun Mar 03, 2013 11:55 am
Posts: 64
Can't say I've timed it. I use custom lookups in any time critical code. I posted the code for those on the old forum somewhere.

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


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 5:07 pm 
Offline
Site Admin
User avatar

Joined: Sun Feb 24, 2013 9:39 pm
Posts: 642
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.


Top
 Profile  
 
PostPosted: Wed Aug 14, 2013 9:47 pm 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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.


Top
 Profile  
 
PostPosted: Thu Aug 15, 2013 9:54 am 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
I have now changed build target from .Net 2.0 to .NET 4.0 for all the projects in the Keith Rule C# Evaluator Analysis Part 1 code. No significant speed change compared to earlier results. I don't think the exception is the problem. This is how slow it is (well, actually it's amazingly fast, but it's slow compared to some other evaluators).

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! :(


Top
 Profile  
 
PostPosted: Thu Aug 15, 2013 10:47 am 
Offline
Junior Member

Joined: Sun Mar 10, 2013 10:30 am
Posts: 20
Did you try http://www.codeproject.com/Articles/19092/More-Texas-Holdem-Analysis-in-C-Part-2
Keith adds MonteCarlo analysis and multicore support.


Top
 Profile  
 
PostPosted: Thu Aug 15, 2013 3:07 pm 
Offline
Regular Member

Joined: Sun Mar 03, 2013 11:55 am
Posts: 64
Are you not getting a little hung up on the speed of the evaluator? My bot (apparently) spends 0.13% of it's time in Keith's code... hence, I don't really care about the speed of the evaluator. If I got an evaluator that was twice as fast I'd make next to no difference.


Top
 Profile  
 
PostPosted: Fri Aug 16, 2013 8:37 am 
Offline
Junior Member

Joined: Sun Jul 07, 2013 11:13 am
Posts: 49
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! :)


Top
 Profile  
 
PostPosted: Fri Aug 16, 2013 1:16 pm 
Offline
Junior Member

Joined: Wed May 15, 2013 10:15 pm
Posts: 42
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 53 posts ]  Go to page 1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group