konglify
konglify
  • Threads: 28
  • Posts: 160
Joined: Aug 28, 2014
September 10th, 2017 at 10:02:47 AM permalink
Hi all,
I am self-learning the algorithm of poker strategy. I start with the simplest 1-deck video poker game (says jacks or better). I read some online material about the statistics on that game but I am not sure I understand the whole idea completely. Here is what I have so far. One deck has 52 cards, and each hand have 5 random card dealt, so total COMBIN(52, 5) = 2598960 hands. For each hand, it is possible to change 0, 1, 2, 3, 4 or 5 cards to get better outcome. But to figure out which cards to replace, from computer aspect, we should just try all possibilities. Let's say I have a hand, five cards: a b c d e

Let's consider replacing 1 card only, there are 5 choices
1) replace card a, then there will be 52-5=47 outcomes leading to 47 hands, we could evaluate all 47 hands to figure the pay for each hand; since each of the 47 outcomes are independent and random, so expectation value of those 47 hands will be EV1=SUM(pay(for nth hand))/47
2) replace card b, then there will be 47 outcomes leading to 47 hands, we could evaluate all 47 hands to figure the pay for each hand; expectation value EV2=SUM(pay(for nth hand))/47
3) replace card c, ...; EV3
4) replace card d, ...; EV4
5) replace card e, ...; EV5

We compare EV1, EV2, EV3, EV4, EV5 and EV0 (the pay of the initial hand without replacement) to find out the maximum expectation value, which will tells us which card(s) should be replaced to maximize the winning.

Similarly, we should consider to replace 2 cards at a time; then 3 cards at a time; then 4 cards at a time and then 5 cards at a time.

So I can easily tell which card(s) I should change (or hold) if I decide to change 1 card, 2 cards, 3 cards, 4 cards and 5 cards separately. And for a given hand, I can compute the EVs when changing 0 card, 1 card, 2 cards, 3 cards, 4 cards and 5 cards. I only have to find out the maximized EV which will tell me how many cards should be changed and which cards they are.

Repeating similar procedure for each hand out of 2598960 hands will show my the maximized payout for this game. Do you think this is a correct way to estimate the game return to player?

I am not quite confident on this method because it took me 3 hours to do the computation and not end yet. So I think it above approach is correct or because too many states to consider make it too slow.
RS
RS
  • Threads: 62
  • Posts: 8626
Joined: Feb 11, 2014
September 10th, 2017 at 11:14:36 AM permalink
So there are 2,598,460 original dealt hands.

For each of those hands you can discard 0 to 5 cards.

# discards || # outcomes
0 || 1
1 || 47
2 || 1081
3 || 16,215
4 || 178,365
5 || 1,533,939

Total: 1+47+1081+16215+178365+1533939 = 1,729,648



So you have 2.5 million dealt hands and each of those can turn into 1.7 million hands, for a total of 2598460*1729648 = 4,494,421,142,080. That's 4.49 trillion total outcomes.

Whatever function you write to determine what hand it ended up with is going to be run 1.7 million times per initial dealt hand (totalling 4.49 trillion). Then you're going to have to find the average result of the 0 card discard, 1 card discards, etc. up to 5 card discards...then determine which is highest. Also, that function is likely not very elegant or smooth but clunky and slow. Unless you really thought it through well, your code for checking if outcome is a straight is probably a total mess. There's actually a very nice solution (which I can't remember) which is something like multiplying all the ranks then using modulo, or something like that.

Then comes the question -- do you want to do the same thing for other games like bonus poker, double bonus, double double bonus, deuces wild, deuces wild bonus, etc.? If so, then you may want to figure out a way to write your code to handle those games, since four of a kinds are much different in bonus games than they are in JOB.


Is it a good way to do it? Yes and no. Yes meaning it's a proper way to do it, meaning that it works and it's logically sound. It's not a good way to do it in the sense that you can optimize it and make it run in a few seconds or minutes instead of days or weeks.


There's an interesting page on the wizardofodds.com site that shows how to re-map all the hands down to a few thousand....since hands like AK873 suited is the same whether it's hearts, diamonds, clubs, or the other suit I can't think of right now. Look up the user's profile "thedonguy" here, I think he may have made a thread on the same thing.


I've tried doing this a few times in the past (the way you're trying to do it) and gave up because the code gets too hectic, takes too long to execute, and it was usually a thing on the back-burner that I'd do for fun when I had down time.
ThatDonGuy
ThatDonGuy
  • Threads: 117
  • Posts: 6274
Joined: Jun 22, 2011
Thanked by
monet0412LuckyPhowRomes
monet0412
monet0412
  • Threads: 9
  • Posts: 627
Joined: Feb 18, 2016
September 10th, 2017 at 12:40:40 PM permalink
Quote: ThatDonGuy

Somebody asked this question before...in fact, you did, three years ago



Now that's funny!! Nice Catch by the way!
konglify
konglify
  • Threads: 28
  • Posts: 160
Joined: Aug 28, 2014
September 10th, 2017 at 7:56:57 PM permalink
Quote: ThatDonGuy

Somebody asked this question before...in fact, you did, three years ago


My bad. I know I thought I ask somewhere else but don't realize at here. My computer broken and I lost my previous work, so I have to work it out again. I will close this thread anyway. Sorry to bother.
  • Jump to: