Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > > >

General Software Discussion Discussions about gambling-related and poker software.

Reply
 
Thread Tools Display Modes
Old 03-14-2008, 06:37 PM   #1
Adrian20XX
grinder
 
Join Date: Dec 2005
Location: Screen Name Officer
Posts: 613
Looking for Poker Source Code

Hi
I'm looking for Poker Source Code, specially hand evaluators and calculators (and ideally in C).
So I've compiled a list of what I've found until now, and hope that if anyone knows something else interested will let us know.
I've also put here some Executable code (calculators) that I consider interested.
You'll find here the main things of the 7 cards evaluator thread, and a lot of stuff that I've found in other places.
I also have more information for each software, like the author, what I had to do to compile it, the relative performance for 7 cards evaluators, and a lot of stuff that I'll be posting if we'd have a decent way to post an HTML table.
Any addition to these will be more than welcomed.
TIA & Regards ...


PokerStove
Hand_7_Eval (the new version of the forum breaks the C code)
Hand Evaluator Speed Demo (handeval7cards.exe)
Hand5Eval (allfive.c)
fast_eval.c
Java Source Code (Old)
poker-eval
Holdem Ranger (link to the source file at the end)
Hold'Em Showdown
Hand Evaluator
poker.zip
fastran.c
fastshuffle.c
Short Stacking Strategy Calculator
ICM Calculator 2.0
Omaha Hand Calculator
Holdem and Omaha Odds Calculator
PokerBolide
TestHandRank.cpp
index52c7.h
FastHandEval.cpp (the new version of the forum breaks the C code)
HandRankSetup.cpp (the new version of the forum breaks the C code)
C# Poker Calculator (PokerCalculator)
C++ Poker Calculator (PokerLib)
Timing Project (PokerTest)
Fast, Texas Holdem Hand Evaluation and Analysis
More Texas Holdem Analysis in C#: Part 1
More Texas Holdem Analysis in C#: Part 2
Adrian20XX is offline   Reply With Quote
Old 03-14-2008, 06:42 PM   #2
Adrian20XX
grinder
 
Join Date: Dec 2005
Location: Screen Name Officer
Posts: 613
Re: Looking for Poker Source Code

F, the links do not work when I pasted them in here, if anyone has an idea to paste them from HTML in here I'll do it.
TIA & Regards ...
Adrian20XX is offline   Reply With Quote
Old 03-14-2008, 07:38 PM   #3
VP$IP
Carpal \'Tunnel
 
VP$IP's Avatar
 
Join Date: Aug 2007
Location: Zero Millions
Posts: 6,841
Re: Looking for Poker Source Code

Did you get any of the hand eval code to work?
VP$IP is offline   Reply With Quote
Old 03-14-2008, 07:40 PM   #4
VP$IP
Carpal \'Tunnel
 
VP$IP's Avatar
 
Join Date: Aug 2007
Location: Zero Millions
Posts: 6,841
Re: Looking for Poker Source Code

Just paste the links in, like this
http://www.suffecool.net/poker/evaluator.html
VP$IP is offline   Reply With Quote
Old 03-14-2008, 07:51 PM   #5
Adrian20XX
grinder
 
Join Date: Dec 2005
Location: Screen Name Officer
Posts: 613
Re: Looking for Poker Source Code

Quote:
Originally Posted by VP$IP View Post
Did you get any of the hand eval code to work?
(the problem was that 20 links was painfull to do by hand, so edited the HTML code and now it is ok).

I got some of them to work, some of them still not.
I have compiled Steve Brecher's Stuff, Cactus Kev, Paul Senzee, and a couple more.
Still didn't compiled RayW code, Holdem Ranger, poker-eval and Juk of York code.
If you want to know about someone in particular, let me know in the thread and I'll let you know.
(I'm using Visual C++ for now, so only C or C++ code)

Here are the links that I have.

Who can add something more to here? Or how to compile some specific code?

TIA & Regards ...


PokerStove
Hand_7_Eval (the new version of the forum breaks the C code)
Hand Evaluator Speed Demo (handeval7cards.exe)
Hand5Eval (allfive.c)
fast_eval.c
Java Source Code (Old)
poker-eval
Holdem Ranger (link to the source file at the end)
Hold'Em Showdown
Hand Evaluator
poker.zip
fastran.c
fastshuffle.c
Short Stacking Strategy Calculator
ICM Calculator 2.0
Omaha Hand Calculator
Holdem and Omaha Odds Calculator
PokerBolide
TestHandRank.cpp
index52c7.h
FastHandEval.cpp (the new version of the forum breaks the C code)
HandRankSetup.cpp (the new version of the forum breaks the C code)
C# Poker Calculator (PokerCalculator)
C++ Poker Calculator (PokerLib)
Timing Project (PokerTest)
Fast, Texas Holdem Hand Evaluation and Analysis
More Texas Holdem Analysis in C#: Part 1
More Texas Holdem Analysis in C#: Part 2
Adrian20XX is offline   Reply With Quote
Old 03-14-2008, 09:12 PM   #6
CallMeIshmael
Carpal \'Tunnel
 
CallMeIshmael's Avatar
 
Join Date: Dec 2004
Location: tinyurl.com/2e8etc
Posts: 9,325
Re: Looking for Poker Source Code

what exactly are you trying to do?


Just looking for the fastest way to evaluate a 7 card hand?
CallMeIshmael is offline   Reply With Quote
Old 03-14-2008, 09:46 PM   #7
Adrian20XX
grinder
 
Join Date: Dec 2005
Location: Screen Name Officer
Posts: 613
Re: Looking for Poker Source Code

Quote:
Originally Posted by CallMeIshmael View Post
what exactly are you trying to do?


Just looking for the fastest way to evaluate a 7 card hand?
No, I'm not looking for the fastest way to evaluate a 7 card hand, I know that the Lookup Table Solution that mykey1961 proposed and that Ray W implemented and published is the fastest (or very close to the fastest) for enumerations done in the traditional way.

I'm just looking for more ideas, about how to speed up things, ways to implement more functionallity, and have fun trying to understand what has been done and how.

I hope Andrew Prock will finish the version 2.0 of PokerStove, so I can stop day dreaming about doing an evaluator :-)

Regards ...
Adrian20XX is offline   Reply With Quote
Old 02-03-2009, 02:35 AM   #8
moeSizlak
stranger
 
Join Date: Feb 2009
Posts: 3
Re: Looking for Poker Source Code

Sorry to resurrect a dead thread, but...

why would anyone want to create 300MB worth of 7-card hand evaluation tables? (like this page suggests: http://www.senzee5.com/2007/01/7.html )

It takes about 2 CPU cycles to evaluate a hand algorithmically (as opposed to looking up rank in a table)....

I can evaluate about 10,000,000 7 card hands per second algormithically.

I used index52c7.h to try doing the same thing with a table, and I got 12,000,000 hands per second.....not much of a difference.

I was thinking about ranking every 2-card staring hand by the percentage of heads up hands won (against EVERY possible opponent hand and community cards).

I calculated itd take me 15-19 hours to rank all 169 starting hands....

Do you guys think thats a valid way to rank starting hands?
moeSizlak is offline   Reply With Quote
Old 02-03-2009, 06:22 AM   #9
contravariance
centurion
 
Join Date: Feb 2008
Posts: 104
Re: Looking for Poker Source Code

Quote:
Originally Posted by moeSizlak View Post
Sorry to resurrect a dead thread, but...

why would anyone want to create 300MB worth of 7-card hand evaluation tables? (like this page suggests: http://www.senzee5.com/2007/01/7.html )
The fastest I've tried does not use 300 MB but 123 MB, which becomes practical on computer having more and more mem (say, a stock Mac Mini has, what, 2GB of mem?).

People are willing to trade some memory (123 MB) in exchange for an algorithm being one order of magnitude faster than what you can achieve otherwise.

Quote:
It takes about 2 CPU cycles to evaluate a hand algorithmically (as opposed to looking up rank in a table)....
No, it doesn't.

A lookup in these kind of tables takes more than 2 cycles. How can you evaluate a "five best of 7-cards" hand algorithmically in 2 CPU cycles?

Quote:
I can evaluate about 10,000,000 7 card hands per second algormithically.
On a computer executing billions (with a 'b', it's not a typo) of cycles per second, this is not impressive at all and not anywhere near "2 CPU cycles".

Quote:
I used index52c7.h to try doing the same thing with a table, and I got 12,000,000 hands per second.....not much of a difference.
The evaluator using a 123 MB lookup table evaluates 133 millions+ hand per second on my Core 2 Duo. More than one order of magnitude faster than your code. And yet it's still not "2 CPU cycles per hand".

Quote:
I was thinking about ranking every 2-card staring hand by the percentage of heads up hands won (against EVERY possible opponent hand and community cards).

I calculated itd take me 15-19 hours to rank all 169 starting hands....

Do you guys think thats a valid way to rank starting hands?
How much memory would you need to store all these precalculated
values?

Quote:
"against EVERY possible opponent hand and community cards"
No it's not a valid way. You're facing combinatorial explosion here and won't have enough memory.

There are much more than 169 starting hands. There are 169 starting groups [C(13,2)*2 + 13] which are crude approximation for starting hands once you start to do "AKs vs JTs". AcKc vs JcTc is NOT the same as AcKc vs JsTs.

Even by only considering the 169 groups, there would be a lot of "player 1 vs player 2 on flop [x y z]" combination. And that would just be the flop. You then need to do the same for 3-ways, for the turn, etc.

How do you deal with a four-way all-in preflop?

Your system would waste Gigabytes of memory. To paraphrase your own question:

"why would anyone want to waste Gigabytes of memory when a 123 MB lookup table yelds 130 million+ evaluation per second?"

Also remember that an evaluator is cute, but even PokerStove is a pain in the a**e when it comes to correctly compute expected pot equity in multi-way all-ins involving a deal with more than one pot (it simply gives the pot equity for the main pot, not for the side pots).
contravariance is offline   Reply With Quote
Old 02-03-2009, 08:54 AM   #10
Adrian20XX
grinder
 
Join Date: Dec 2005
Location: Screen Name Officer
Posts: 613
Re: Looking for Poker Source Code

Quote:
Originally Posted by moeSizlak View Post
why would anyone want to create 300MB worth of 7-card hand evaluation tables? (like this page suggests: http://www.senzee5.com/2007/01/7.html )
Paul Senzee's algorithm came up before the idea of mykey1961, now the 125MB LUT approach is better.

Quote:
Originally Posted by moeSizlak View Post
It takes about 2 CPU cycles to evaluate a hand algorithmically (as opposed to looking up rank in a table)....
I can evaluate about 10,000,000 7 card hands per second algormithically.
I used index52c7.h to try doing the same thing with a table, and I got 12,000,000 hands per second.....not much of a difference.
I don't kind of hardware you are running on, but I get around 450.000.000 with the LUT solution on my Core 2 Duo. Start with RayW's code.

BTW, there is only the array on Paul Senze's site, can you post your program with index52c7.h in here?

Quote:
Originally Posted by moeSizlak View Post
I was thinking about ranking every 2-card staring hand by the percentage of heads up hands won (against EVERY possible opponent hand and community cards).
I calculated itd take me 15-19 hours to rank all 169 starting hands....
Like AKs vs random hand has 85.204%? In PokerStove that takes in my machine around 0.001 or 0.002 seconds.
This is the resulting table, the number were calculated with PokerStove (note that pokerstove for top % hands uses equity against 3 random hands, not one).
This table is also in this web page, but the calculations contains errors: http://www.top15poker.com/Strategy/Starting_Hands.htm
Code:
Hole Cards	Equity Against 1 Random Hand	Top % Equity Against 1 Random Hand
AA	85,204%	0,45%
KK	82,396%	0,90%
QQ	79,925%	1,36%
JJ	77,469%	1,81%
TT	75,012%	2,26%
99	72,057%	2,71%
88	69,163%	3,17%
77	66,236%	3,92%
66	63,285%	8,30%
55	60,325%	13,88%
44	57,023%	25,19%
33	53,693%	35,60%
22	50,334%	48,11%
AKs	67,045%	3,47%
AQs	66,209%	4,22%
AJs	65,393%	4,52%
ATs	64,402%	6,64%
A9s	62,781%	8,60%
A8s	61,944%	10,11%
A7s	60,984%	11,61%
A6s	59,906%	15,08%
A5s	59,923%	14,78%
A4s	59,034%	17,50%
A3s	58,220%	19,00%
A2s	57,379%	23,83%
KQs	63,400%	7,84%
KJs	62,567%	9,80%
KTs	61,789%	10,41%
K9s	59,988%	14,48%
K8s	58,312%	18,70%
K7s	57,538%	23,23%
K6s	56,641%	26,40%
K5s	55,793%	28,81%
K4s	54,885%	33,03%
K3s	54,055%	34,54%
K2s	53,212%	38,91%
QJs	60,259%	14,18%
QTs	59,468%	17,19%
Q9s	57,664%	22,93%
Q8s	56,018%	27,60%
Q7s	54,302%	33,33%
Q6s	53,613%	35,90%
Q5s	52,769%	39,22%
Q4s	51,855%	41,03%
Q3s	51,019%	45,85%
Q2s	50,169%	48,42%
JTs	57,528%	23,53%
J9s	55,662%	29,11%
J8s	54,016%	35,14%
J7s	52,325%	40,72%
J6s	50,606%	46,76%
J5s	49,987%	49,62%
J4s	49,070%	52,94%
J3s	48,232%	53,54%
J2s	47,378%	58,07%
T9s	54,028%	34,84%
T8s	52,334%	39,52%
T7s	50,639%	46,46%
T6s	48,941%	53,24%
T5s	47,216%	59,28%
T4s	46,530%	60,48%
T3s	45,693%	64,10%
T2s	44,839%	66,52%
98s	50,801%	46,15%
97s	49,118%	52,64%
96s	47,428%	57,77%
95s	45,722%	63,80%
94s	43,862%	69,83%
93s	43,264%	71,34%
92s	42,415%	74,96%
87s	47,936%	55,66%
86s	46,243%	61,69%
85s	44,545%	66,82%
84s	42,702%	72,85%
83s	40,784%	78,88%
82s	40,272%	81,00%
76s	45,372%	64,40%
75s	43,676%	70,14%
74s	41,849%	76,17%
73s	40,036%	81,30%
72s	38,156%	87,03%
65s	43,133%	72,55%
64s	41,333%	78,58%
63s	39,534%	83,71%
62s	37,669%	89,44%
54s	41,453%	77,38%
53s	39,693%	83,41%
52s	37,849%	89,14%
43s	38,642%	85,82%
42s	36,289%	92,46%
32s	35,984%	95,48%
AKo	65,320%	5,43%
AQo	64,432%	6,33%
AJo	63,563%	7,54%
ATo	62,722%	9,50%
A9o	60,773%	12,52%
A8o	59,873%	15,99%
A7o	58,841%	18,40%
A6o	57,682%	22,62%
A5o	57,697%	21,72%
A4o	56,730%	26,09%
A3o	55,845%	28,51%
A2o	54,929%	32,73%
KQo	61,546%	11,31%
KJo	60,569%	13,42%
KTo	59,739%	16,89%
K9o	57,812%	20,81%
K8o	56,020%	27,30%
K7o	55,187%	31,83%
K6o	54,223%	34,24%
K5o	53,314%	37,71%
K4o	52,327%	40,42%
K3o	51,426%	44,65%
K2o	50,509%	47,66%
QJo	58,135%	19,91%
QTo	57,291%	24,74%
Q9o	55,360%	30,02%
Q8o	53,600%	36,80%
Q7o	51,766%	41,93%
Q6o	51,024%	45,55%
Q5o	50,120%	49,32%
Q4o	49,128%	52,34%
Q3o	48,219%	54,45%
Q2o	47,295%	58,97%
JTo	55,248%	30,92%
J9o	53,251%	38,61%
J8o	51,490%	43,74%
J7o	49,682%	51,43%
J6o	47,844%	57,47%
J5o	47,181%	60,18%
J4o	46,186%	62,59%
J3o	45,276%	65,31%
J2o	44,348%	68,63%
T9o	51,532%	42,84%
T8o	49,721%	50,53%
T7o	47,908%	56,56%
T6o	46,092%	63,50%
T5o	44,251%	69,53%
T4o	43,504%	71,04%
T3o	42,595%	74,66%
T2o	41,668%	77,07%
98o	48,097%	55,35%
97o	46,298%	61,39%
96o	44,491%	67,72%
95o	42,669%	73,76%
94o	40,671%	79,79%
93o	40,020%	82,20%
92o	39,098%	85,52%
87o	45,051%	66,21%
86o	43,241%	72,25%
85o	41,428%	78,28%
84o	39,447%	84,62%
83o	37,484%	90,35%
82o	36,828%	91,25%
76o	42,323%	75,87%
75o	40,512%	80,69%
74o	38,550%	86,73%
73o	36,602%	92,16%
72o	34,584%	96,38%
65o	39,944%	83,11%
64o	38,010%	88,84%
63o	36,078%	95,17%
62o	34,075%	98,19%
54o	38,155%	87,93%
53o	36,265%	93,36%
52o	34,285%	97,29%
43o	36,146%	94,27%
42o	33,200%	99,10%
32o	32,303%	100,00%
Quote:
Originally Posted by moeSizlak View Post
Do you guys think thats a valid way to rank starting hands?
I think there are several ways to rank starting hands, and it depends on what situation do you try to apply this to.

These are the ways to start ranking hands I'm thinking of, and want to implement some day.
1) Rank starting hands by LHS at the flop (for LHS linear hand strength go to Andrew Prock's site).
2) Rank starting hands by % of flops they have the best hand
3) Rank starting hands by % of rivers they have the best hand

Quote:
Originally Posted by contravariance View Post
Also remember that an evaluator is cute, but even PokerStove is a pain in the a**e when it comes to correctly compute expected pot equity in multi-way all-ins involving a deal with more than one pot (it simply gives the pot equity for the main pot, not for the side pots).
In order to do that with PokerStove, you have to do to separeted calculations with PokerStove.
Like if you are evaluating a 3 way AI on a Jh9s7h board with players having Tc8c, AhKh, JJ, you first run the evaluation for the main pot with the 3 players, and then run a calculation for the side pot with the two players with the big stacks (and with the small stack cards marked as dead). Then, you have to weight this by the size of each pot to get each players EV in $.
Adrian20XX is offline   Reply With Quote
Old 02-03-2009, 05:02 PM   #11
moeSizlak
stranger
 
Join Date: Feb 2009
Posts: 3
Re: Looking for Poker Source Code

Ok, first of all, yes, there are EXACTLY 169 starting hands, if you consider that no suit is better than any other.

There are 78 suited starting hands.
There are 78 unsuited starting hands.
+ there are 13 pocket pair starting hands....

for a total of 169 starting hands.

I'm ranking the starting hands by % of hands won (after the river, and versus 1 opponent). I found a 4-CPU Xeon RHEL server to run my simulation on....it took 7 hours to compute the 78 suited hands (about 2 billion hands per starting hand):

Code:
(2c/3c) Count=2097572400 Player1_wins=655103625 (0.3123) split_pot: 115502268 (0.0551)
(2c/4c) Count=2097572400 Player1_wins=669055094 (0.3190) split_pot: 115584981 (0.0551)
(2c/5c) Count=2097572400 Player1_wins=688160523 (0.3281) split_pot: 115639517 (0.0551)
(2c/6c) Count=2097572400 Player1_wins=716500067 (0.3416) split_pot: 113283352 (0.0540)
(2c/7c) Count=2097572400 Player1_wins=754355732 (0.3596) split_pot: 108551302 (0.0518)
(2c/8c) Count=2097572400 Player1_wins=800864808 (0.3818) split_pot: 102381963 (0.0488)
(2c/9c) Count=2097572400 Player1_wins=854560497 (0.4074) split_pot: 95792141 (0.0457)
(2c/Tc) Count=2097572400 Player1_wins=914358108 (0.4359) split_pot: 89538228 (0.0427)
(2c/Jc) Count=2097572400 Player1_wins=979521951 (0.4670) split_pot: 84068227 (0.0401)
(2c/Qc) Count=2097572400 Player1_wins=1049703124 (0.5004) split_pot: 79534141 (0.0379)
(2c/Kc) Count=2097572400 Player1_wins=1125134960 (0.5364) split_pot: 75668423 (0.0361)
(2c/Ac) Count=2097572400 Player1_wins=1207321593 (0.5756) split_pot: 71307885 (0.0340)
(3c/4c) Count=2097572400 Player1_wins=682297521 (0.3253) split_pot: 115602951 (0.0551)
(3c/5c) Count=2097572400 Player1_wins=701405423 (0.3344) split_pot: 115646345 (0.0551)
(3c/6c) Count=2097572400 Player1_wins=729742907 (0.3479) split_pot: 113267338 (0.0540)
(3c/7c) Count=2097572400 Player1_wins=767582780 (0.3659) split_pot: 108512446 (0.0517)
(3c/8c) Count=2097572400 Player1_wins=813981917 (0.3881) split_pot: 102320265 (0.0488)
(3c/9c) Count=2097572400 Player1_wins=867645747 (0.4136) split_pot: 95706655 (0.0456)
(3c/Tc) Count=2097572400 Player1_wins=927385230 (0.4421) split_pot: 89429900 (0.0426)
(3c/Jc) Count=2097572400 Player1_wins=992477295 (0.4732) split_pot: 83937057 (0.0400)
(3c/Qc) Count=2097572400 Player1_wins=1062573040 (0.5066) split_pot: 79380129 (0.0378)
(3c/Kc) Count=2097572400 Player1_wins=1137905798 (0.5425) split_pot: 75491569 (0.0360)
(3c/Ac) Count=2097572400 Player1_wins=1219979703 (0.5816) split_pot: 71108189 (0.0339)
(4c/5c) Count=2097572400 Player1_wins=714650931 (0.3407) split_pot: 115609432 (0.0551)
(4c/6c) Count=2097572400 Player1_wins=742979511 (0.3542) split_pot: 113218321 (0.0540)
(4c/7c) Count=2097572400 Player1_wins=780804148 (0.3722) split_pot: 108443125 (0.0517)
(4c/8c) Count=2097572400 Player1_wins=827176018 (0.3943) split_pot: 102230640 (0.0487)
(4c/9c) Count=2097572400 Player1_wins=880729017 (0.4199) split_pot: 95596726 (0.0456)
(4c/Tc) Count=2097572400 Player1_wins=940426927 (0.4483) split_pot: 89298721 (0.0426)
(4c/Jc) Count=2097572400 Player1_wins=1005454449 (0.4793) split_pot: 83785574 (0.0399)
(4c/Qc) Count=2097572400 Player1_wins=1075473702 (0.5127) split_pot: 79208342 (0.0378)
(4c/Kc) Count=2097572400 Player1_wins=1150718019 (0.5486) split_pot: 75299478 (0.0359)
(4c/Ac) Count=2097572400 Player1_wins=1232691534 (0.5877) split_pot: 70895794 (0.0338)
(5c/6c) Count=2097572400 Player1_wins=759201839 (0.3619) split_pot: 111133753 (0.0530)
(5c/7c) Count=2097572400 Player1_wins=797009131 (0.3800) split_pot: 106345957 (0.0507)
(5c/8c) Count=2097572400 Player1_wins=843355991 (0.4021) split_pot: 100115706 (0.0477)
(5c/9c) Count=2097572400 Player1_wins=896873650 (0.4276) split_pot: 93464026 (0.0446)
(5c/Tc) Count=2097572400 Player1_wins=956464136 (0.4560) split_pot: 87148255 (0.0415)
(5c/Jc) Count=2097572400 Player1_wins=1021443732 (0.4870) split_pot: 81616396 (0.0389)
(5c/Qc) Count=2097572400 Player1_wins=1091395430 (0.5203) split_pot: 77021398 (0.0367)
(5c/Kc) Count=2097572400 Player1_wins=1166561944 (0.5561) split_pot: 73094768 (0.0348)
(5c/Ac) Count=2097572400 Player1_wins=1248447408 (0.5952) split_pot: 68673318 (0.0327)
(6c/7c) Count=2097572400 Player1_wins=816884024 (0.3894) split_pot: 101948257 (0.0486)
(6c/8c) Count=2097572400 Player1_wins=863207923 (0.4115) split_pot: 95705487 (0.0456)
(6c/9c) Count=2097572400 Player1_wins=916694200 (0.4370) split_pot: 89038579 (0.0424)
(6c/Tc) Count=2097572400 Player1_wins=976244675 (0.4654) split_pot: 82707580 (0.0394)
(6c/Jc) Count=2097572400 Player1_wins=1041124559 (0.4963) split_pot: 77160493 (0.0368)
(6c/Qc) Count=2097572400 Player1_wins=1111025338 (0.5297) split_pot: 72549321 (0.0346)
(6c/Kc) Count=2097572400 Player1_wins=1186124687 (0.5655) split_pot: 68607463 (0.0327)
(6c/Ac) Count=2097572400 Player1_wins=1267934439 (0.6045) split_pot: 64170785 (0.0306)
(7c/8c) Count=2097572400 Player1_wins=886112517 (0.4224) split_pot: 89637179 (0.0427)
(7c/9c) Count=2097572400 Player1_wins=939571847 (0.4479) split_pot: 82958527 (0.0395)
(7c/Tc) Count=2097572400 Player1_wins=999089437 (0.4763) split_pot: 76614838 (0.0365)
(7c/Jc) Count=2097572400 Player1_wins=1063929667 (0.5072) split_pot: 71055061 (0.0339)
(7c/Qc) Count=2097572400 Player1_wins=1133744426 (0.5405) split_pot: 66431199 (0.0317)
(7c/Kc) Count=2097572400 Player1_wins=1208794941 (0.5763) split_pot: 62475705 (0.0298)
(7c/Ac) Count=2097572400 Player1_wins=1290543081 (0.6153) split_pot: 58026337 (0.0277)
(8c/9c) Count=2097572400 Player1_wins=964432149 (0.4598) split_pot: 76160588 (0.0363)
(8c/Tc) Count=2097572400 Player1_wins=1023922645 (0.4881) split_pot: 69806747 (0.0333)
(8c/Jc) Count=2097572400 Player1_wins=1088730257 (0.5190) split_pot: 64236818 (0.0306)
(8c/Qc) Count=2097572400 Player1_wins=1158507457 (0.5523) split_pot: 59602804 (0.0284)
(8c/Kc) Count=2097572400 Player1_wins=1233488237 (0.5881) split_pot: 55637158 (0.0265)
(8c/Ac) Count=2097572400 Player1_wins=1315191228 (0.6270) split_pot: 51176692 (0.0244)
(9c/Tc) Count=2097572400 Player1_wins=1049667578 (0.5004) split_pot: 63114075 (0.0301)
(9c/Jc) Count=2097572400 Player1_wins=1114447347 (0.5313) split_pot: 57536532 (0.0274)
(9c/Qc) Count=2097572400 Player1_wins=1184195804 (0.5646) split_pot: 52894904 (0.0252)
(9c/Kc) Count=2097572400 Player1_wins=1259144602 (0.6003) split_pot: 48921644 (0.0233)
(9c/Ac) Count=2097572400 Player1_wins=1340798616 (0.6392) split_pot: 44453564 (0.0212)
(Tc/Jc) Count=2097572400 Player1_wins=1140290604 (0.5436) split_pot: 51488971 (0.0245)
(Tc/Qc) Count=2097572400 Player1_wins=1210016753 (0.5769) split_pot: 46842267 (0.0223)
(Tc/Kc) Count=2097572400 Player1_wins=1284944085 (0.6126) split_pot: 42863931 (0.0204)
(Tc/Ac) Count=2097572400 Player1_wins=1366575096 (0.6515) split_pot: 38390775 (0.0183)
(Jc/Qc) Count=2097572400 Player1_wins=1235495104 (0.5890) split_pot: 41698627 (0.0199)
(Jc/Kc) Count=2097572400 Player1_wins=1310409065 (0.6247) split_pot: 37717753 (0.0180)
(Jc/Ac) Count=2097572400 Player1_wins=1392029289 (0.6636) split_pot: 33242059 (0.0158)
(Qc/Kc) Count=2097572400 Player1_wins=1335161847 (0.6365) split_pot: 33680522 (0.0161)
(Qc/Ac) Count=2097572400 Player1_wins=1416781039 (0.6754) split_pot: 29204828 (0.0139)
(Kc/Ac) Count=2097572400 Player1_wins=1440041223 (0.6865) split_pot: 26853684 (0.0128)
I'm doing the non-suited ones now. The "count" of 2097572400 is this: For every starting hand, there are 50*49/2 possible opponent hands, and for each of those opponent hands, there are 48*47*46*45*44/(5*4*3*2*1) possible 5-card boards, giving...... 2097574200 possibilities per startinghand, each of them equally likely. So AFAIK my numbers are correct.

Here is my ranking code...I know it's far from optimized, but I'm pretty sure its mathmatically correct. The rank() function returns an int, which can be used to compare hands....a higher rank (int) means the hand is better than a hand with a lower rank....

Comments are welcome.

Code:
// CONSTANTS:
#define STRAIGHT_FLUSH  775892
#define FOUR_OF_A_KIND  775723
#define FULL_HOUSE      775554
#define FLUSH           404261
#define STRAIGHT        404248
#define THREE_OF_A_KIND 402051
#define TWO_PAIR        399854
#define ONE_PAIR        371293
#define HIGH_CARD       0

// POWERS of 13
#define TT0 1
#define TT1 13
#define TT2 169
#define TT3 2197
#define TT4 28561
#define TT5 371293

//POWERS of 13 multiplied by 0-12
const unsigned int tt0[13] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
const unsigned int tt1[13] = {0, 13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156};
const unsigned int tt2[13] = {0, 169, 338, 507, 676, 845, 1014, 1183, 1352, 1521, 1690, 1859, 2028};
const unsigned int tt3[13] = {0, 2197, 4394, 6591,8788, 10985, 13182, 15379, 17576, 19773, 21970, 24167, 26364};
const unsigned int tt4[13] = {0, 28561, 57122, 85683, 114244, 142805, 171366, 199927, 228488, 257049, 285610, 314171, 342732};
const unsigned int tt5[13] = {0, 371293, 742586, 1113879, 1485172, 1856465, 2227758, 2599051, 2970344, 3341637, 3712930, 4084223, 4455516};


// The "Board" contains 5 "Card" objects.
// The "Hand" contains 2 "Card" objects.
// A card object's "value_" is an int from 0-51
// 0-12 are suit1 (clubs), 2-A
// 13-25 are suit2, 2-A
// etc...
int rank(Board b1, Hand p1) {

	int suit[7];
	int value[7];
	int isFlush = 0;
	int isStraightFlush = 0;
	int isStraight = 0;
	int flushCards[7];
	int flushSuit=-1;	
	int straightHighCard=-1;
	int straightFlushHighCard=-1;
	int fourple = -1;
	int triple = -1;
	int pair[2];
	pair[0] = -1;
	pair[1] = -1;
	
	//set values[] & suits[]
	value[0] = b1.board_[0].value_ % 13;
	value[1] = b1.board_[1].value_ % 13;
	value[2] = b1.board_[2].value_ % 13;
	value[3] = b1.board_[3].value_ % 13;
	value[4] = b1.board_[4].value_ % 13;
	value[5] = b1.board_[5].value_ % 13;
	value[6] = b1.board_[6].value_ % 13;
	suit[0]  = b1.board_[0].value_ / 13;
	suit[1]  = b1.board_[1].value_ / 13;
	suit[2]  = b1.board_[2].value_ / 13;
	suit[3]  = b1.board_[3].value_ / 13;
	suit[4]  = b1.board_[4].value_ / 13;
	suit[5]  = b1.board_[5].value_ / 13;
	suit[6]  = b1.board_[6].value_ / 13;

	// sort by increasing values
	for (int i=0; i<6; i++) {
		for (int j=0; j<6-i; j++) {
			if (value[j+1] < value[j]) {
				int tmp1 = value[j];      
				int tmp2 = suit[j];
				value[j] = value[j+1];
				value[j+1] = tmp1;
				suit[j] = suit[j+1];
				suit[j+1] = tmp2;
			}
		}
	}

	//get suit counts
	int a=0;
	int b=0;
	int c=0;
	int d=0;
	for (int i=0, j=0;i<7;i++) {
		if(suit[i] == 0)
			a++;
		else if(suit[i] == 1)
			b++;
		else if(suit[i] ==2)
			c++;
		else
			d++;
	}

	//check for a flush
	if(a>4) {
		flushSuit = 0;
		isFlush = 1;
	}
	else if ( b>4) {
		flushSuit = 1;
		isFlush = 1;
	}
	else if ( c>4) {
		flushSuit = 2;
		isFlush = 1;
	}
	else if (d>4) {
		flushSuit = 3;
		isFlush = 1;
	}
	else
		isFlush = 0;
		
	//check for a straight flush:
	if (isFlush) {
		for (int f=0; f<7; f++) {
			flushCards[f] = -1;
		}
		for (int x=0,y=6; y >= 0; y--) {
			if (suit[y] == flushSuit) {
				flushCards[x++] = value[y];
			}
		}

		int straightFlushHistogram[13];
		for (int f=0; f<13; f++) {
			straightFlushHistogram[f] = 0;
		}
		for (int g = 0; g < 7 && flushCards[g] != -1; g++) {
			straightFlushHistogram[flushCards[g]]++;
		}

		int straightFlushCount = 0;
		isStraightFlush = 0;
		for (int i = 0; i < 13; i++) {
			if(straightFlushHistogram[i]) {
				straightFlushCount++;
				if(straightFlushCount >= 5) {
					isStraightFlush = 1;
					straightFlushHighCard = i;
				}
			}
			else {
				straightFlushCount=0;
			}
		}	
	}

	// straight flush:
	if (isStraightFlush) {
		return (STRAIGHT_FLUSH + straightFlushHighCard);
	}

	
//check for a straight or 4 of a kind:
	int straightHistogram[13];
	for(int i = 0; i <13; i++)
		straightHistogram[i] = 0;

	for(int i = 0; i <7; i++) {
		straightHistogram[value[i]]++;
		if(straightHistogram[value[i]] == 4) {
			fourple = value[i];
		}
	}

	int straightCount = 0;
	isStraight = 0;
	for (int i = 0; i < 13; i++) {
		if(straightHistogram[i]) {
			straightCount++;
			if(straightCount >= 5) {
				isStraight = 1;
				straightHighCard = i;
			}
		}
		else
			straightCount=0;
	}


	
	// four of a kind:
	if (fourple != -1) {
		int kicker;
		int i = 7;
		while(value[--i] == fourple) {}
		kicker = value[i];
		return (FOUR_OF_A_KIND + tt1[triple] + kicker); 
	}
	
	//check for trips and pairs:
	else {//if(fourple == -1)
		for (int i = 12; i >= 0; i--) {
			if (straightHistogram[i] == 3)
				if (triple == -1)
					triple = i;
				else {  // 2nd triple means no pairs possible, but full house definite.
						// so use high trip as the triple and the low trip as the pair for the full house.
					pair[0] = i;					
				}
				
			else if (straightHistogram[i] == 2) {
				if( pair[0] == -1)
					pair[0] = i;
				else if (pair[1] == -1)
					pair[1] = i;
			}
		}
	}
	
	// full house:
	if(triple != -1 && pair[0] != -1) {
		return (FULL_HOUSE + tt1[triple] + pair[0]);
	}
	
	// flush:
	else if (isFlush) {
		return (FLUSH + tt4[flushCards[0]] + tt3[flushCards[1]] + tt2[flushCards[2]] + tt1[flushCards[3]] + flushCards[4]);
	}
	
	// three of a kind:
	if (triple != -1) {
		int kick1, kick2;
		int i = 6;
		while(value[i] == triple) {i--;}
		kick1 = value[i--];
		while(value[i] == triple) {i--;}
		kick2 = value[i];
		
		return (THREE_OF_A_KIND + tt2[triple] + tt1[kick1] + kick2);
	}

	// two pair:
	else if (pair[1] != -1) {
		int kick;
		int i = 6;
		while(value[i] == pair[0] || value[i] == pair[1]) {i--;}
		kick = value[i];
		
		return (TWO_PAIR + tt2[pair[0]] + tt1[pair[1]] + kick);
	}
	
	// one pair:
	else if (pair[0] != -1) {
		int kick1;
		int kick2;
		int kick3;
		
		int i = 6;
		while(value[i] == pair[0]) {i--;}
		kick1 = value[i--];
		while(value[i] == pair[0]) {i--;}
		kick2 = value[i--];
		while(value[i] == pair[0]) {i--;}
		kick3 = value[i];
		
		return (ONE_PAIR + tt3[pair[0]] + tt2[kick1] + tt1[kick2] + kick3);
	}
	
	// high card (no pair):
	else
		return (HIGH_CARD + tt4[value[6]] + tt3[value[5]] + tt2[value[4]] + tt1[value[3]] + value[2]);
	
}

Last edited by moeSizlak; 02-03-2009 at 05:11 PM.
moeSizlak is offline   Reply With Quote
Old 02-03-2009, 05:40 PM   #12
moeSizlak
stranger
 
Join Date: Feb 2009
Posts: 3
Re: Looking for Poker Source Code

BTW, here is all of my code, as used in the above simulation:


poke.cpp http://www.mediafire.com/?sharekey=4...4e75f6e8ebb871
poke.h http://www.mediafire.com/?sharekey=4...4e75f6e8ebb871
index52c7.h http://www.mediafire.com/?sharekey=4...4e75f6e8ebb871

BTW, when I used index52c7 w/ gcc/g++ with -O2 or -O3, it DOES NOT WORK. With no optimization, it does. In VC++, it works with or without optimizations.

Last edited by moeSizlak; 02-03-2009 at 05:54 PM.
moeSizlak is offline   Reply With Quote
Old 02-03-2009, 09:23 PM   #13
contravariance
centurion
 
Join Date: Feb 2008
Posts: 104
Re: Looking for Poker Source Code

Quote:
In order to do that with PokerStove, you have to do to separeted calculations with PokerStove.
Like if you are evaluating a 3 way AI on a Jh9s7h board with players having Tc8c, AhKh, JJ, you first run the evaluation for the main pot with the 3 players, and then run a calculation for the side pot with the two players with the big stacks (and with the small stack cards marked as dead). Then, you have to weight this by the size of each pot to get each players EV in $.

I fully know that... And that's exactly my definition of being a "pain in the a**e"

Which is why I said it was in pain in the a**se to do that in PokerStove, not that it was impossible
contravariance is offline   Reply With Quote
Old 01-08-2011, 01:06 PM   #14
RedDog2011
stranger
 
Join Date: Jan 2011
Posts: 5
Re: Looking for Poker Source Code

PokerStove
Hand5Eval (allfive.c)
Java Source Code (Old)
poker-eval
Holdem Ranger (link to the source file at the end)
Hold'Em Showdown
Hand Evaluator
poker.zip
fastran.c
fastshuffle.c
Short Stacking Strategy Calculator
ICM Calculator 2.0
Omaha Hand Calculator
Holdem and Omaha Odds Calculator
PokerBolide
TestHandRank.cpp
index52c7.h
FastHandEval.cpp (the new version of the forum breaks the C code)
HandRankSetup.cpp (the new version of the forum breaks the C code)
Timing Project (PokerTest)
Fast, Texas Holdem Hand Evaluation and Analysis




What software are used to compile all that scripts?
I would like to check them out...
Thank you.
RedDog2011 is offline   Reply With Quote
Old 01-08-2011, 01:14 PM   #15
MasterLJ
Carpal \'Tunnel
 
MasterLJ's Avatar
 
Join Date: Dec 2005
Location: California
Posts: 13,684
Re: Looking for Poker Source Code

Holdem Ranger is free and the source code is available:

http://www.******************/holdem_ranger
MasterLJ is offline   Reply With Quote
Old 01-08-2011, 03:21 PM   #16
_dave_
_Pooh_Bah_
 
Join Date: Feb 2005
Location: UK (or what remains of it)
Posts: 13,126
Re: Looking for Poker Source Code

Holdem Ranger should be accessed via IP address, the url is hijacked. The link in the forum FAQ is to IP address now
_dave_ is offline   Reply With Quote
Old 08-29-2011, 07:44 PM   #17
Relok
stranger
 
Join Date: Aug 2011
Posts: 1
Re: Looking for Poker Source Code

MasterLJ tried that site, but the link doesn't work, if you downloaded it could you share the program an the code ?

@Dave: The only IP I saw was unreachable.
Relok is offline   Reply With Quote
Old 10-29-2011, 10:55 AM   #18
Cernunnos86
journeyman
 
Join Date: Jan 2008
Posts: 384
Re: Looking for Poker Source Code

Quote:
Originally Posted by Relok View Post
MasterLJ tried that site, but the link doesn't work, if you downloaded it could you share the program an the code ?

@Dave: The only IP I saw was unreachable.
+1

anyone with the source could share it/pm me, i would really appriciate it
Cernunnos86 is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 05:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
Copyright © 2008-2020, Two Plus Two Interactive