Problem 391. Poker Series 11: selectBestHand
Solution Stats
Problem Comments
-
15 Comments
that took a really long time to do...
i think that it might be beneficial to return more information in the subfunctions such as the kicker(s) and the values of the cards themselves.
It's not that hard, using a modified hand card representation (sorting columns as A,K...2 and adding a repeated A for the straights) makes the comparison of two hands trivially simple (sortrows)
What i believe might have been beneficial would be to have the hand cards columns sorted by decreasing card value -like its rows- since all computations look much cleaner that way ...
scratch the above, it does need more work (and we need more test samples)
When deciding the best hand among two hands of the same rank (e.g. both players have a pair of 5's) what is more important, the suits of the hand or the rank of the kicker(s)? (i guess the latter but the test suite does not discriminate)
perhaps you could add these tests (most of the current solvers fail one or the other): TEST1: hm1=[ 0 0 0 0 0 0 0 0 0 1 0 1 0; 0 0 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 0 0 1 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 1 0];
hm2=[ 0 0 0 0 0 0 0 0 0 0 0 0 0; 1 0 0 0 0 0 0 0 0 0 0 1 0; 1 0 0 0 0 0 0 0 0 0 0 1 0; 0 0 0 0 0 0 0 0 0 0 0 1 0];
out.hm{1} = hm1;
out.hm{2} = hm2;
out.winner = 2;
TEST2: hm1=[ 0 0 0 1 1 1 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0];
hm2=[ 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 1 1 1 1 1 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0 0 0 0];
out.hm{1} = hm1;
out.hm{2} = hm2;
out.winner = 0;
hm1=[1 0 0 0 0 0 0 0 0 0 0 0 1;1 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 0 0 0 0 0 0 0];
hm2=[1 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 0 0 0 0 0 0 0;1 0 0 0 0 0 0 0 0 0 0 0 1];
Is player 1 supposed to win in this case?
On a second thought.. shouldn't there be only one deck?
@albert: your example should be a tie (the card suits do not break ties; in fact they are not used at all for scoring). And I believe there is no limitation on the number of decks the hand cards come from...
Test case 7 is broken, the case is expecting matrices of type double in the output, but all other cases want matrices of type logical.
Test case 7 is confusing.
hm2 = [1 1 1 1 1 1 0 0 0 0 0 1 1
0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0];
om2 = [0 1 1 1 1 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0];
1. Why the StraightFlush including Ace is not considered as the BestHand for hm2?
2. How could the winner be 2, since the first player has Ace in its BestHand?
Seconding both Athi's & Andrew's posts
Player 2 has an ace in his hand but chooses to play 2 3 4 5 6
That's backwards
also, the double thing is 100% true. why switch from logical to double
Many of the issues could have been easily solved with a better design choice (for instance, cases 5 and 9 are only an issue because the functions that identify both hands do not store the highest cards values). Storing the array usedCards is not useful, it would be best to store a number representing the hand, and the values of the highest cards or a number representing them.
For those asking why 2-3-4-5-6 beats A-2-3-4-5: in poker, the rank of a straight is determined by the card at the high end. So 2-3-4-5-6 beats A-2-3-4-5 because 6 beats 5. The ace becomes a low card.
smartest non-cheating solution is scored 480? omegaLOL
Solution Comments
Show commentsProblem Recent Solvers35
Suggested Problems
-
Remove the polynomials that have positive real elements of their roots.
1458 Solvers
-
934 Solvers
-
1151 Solvers
-
448 Solvers
-
221 Solvers
More from this Author51
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!