| Date | File | Comment by | Comment | Rating |
|---|---|---|---|---|
| 27 Feb 2009 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | MuffinMan | Great starting point for a hand evaluator however still has issues and does not rank all hands correctly. I discovered this several months ago but didn't want to bother with registering to post a reply. After a coworker mentioned using this evaluator to prove an argument, I mentioned the shortcomings. Unfortunately now I can't remember the cases it fails at, but I recall the error is due to the arbitrary method of ranking hands by hashing the card numbers. In some cases hands that should not have the same rank are hashed to the same value. A easy test is to use combs=nchoosek([1:52],5); ranks=rankp(combs,5); unique(ranks) and you will find that all possible hands gives 6987 possible ranks using rankp, which is incorrect, and instead you should get 7462. Once the total ranks checks out, you should test and find that there are 10 straight flushes, 156 four of a kinds and full houses, 1277 flushes, 10 straights, 858 trips and two pairs, 2860 pairs, and 1277 high card ranks. Otherwise, there is still an error. As an aside, the 2+2 evaluator can do unordered evaluations of 5-7 card hands, at blazing speeds, and can easily be ported to Matlab. |
|
| 27 Feb 2009 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | MuffinMan | ||
| 30 Aug 2008 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | S., Rob | Thanks Tim C., there was a hole in the conditional statement for hands with pairs. Nice catch, the update has it fixed. |
|
| 22 Aug 2008 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | C, Tim | Pretty neat! But I can't seem to wrap my head around what's happening for the test case below. Using the input: >> trick = [21, 22, 40, 33, 26, 42, 1, 7];
yields: >> descriptions{1}
But there are no kings in the 'trick' vector, let alone in the 'usedcards' output. Any hints where this is coming from? I'm using R2007a. |
|
| 27 May 2008 | Place one 2D matrix inside another Places a 2D matrix B into a larger 2D matrix A | Le, Khai | Great! |
|
| 03 Dec 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | S, Rob | Daniel, Thanks for the feedback. I don't get this error with handlength of 5. My first thought is that the random cards might sometimes create an erroneous hand, but that's a guess. Can you email me your complete code and we'll have a look please? Regards,
|
|
| 02 Dec 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | Schröter, Daniel | hi,
Warning: Values other than 0 or 1 converted to logical 1
Whats this error about? If I run it with a handlenght of two there is no problem at all. Best regards
|
|
| 28 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | S, Rob | James, Yep, a "Straight to the King" beats a "Pair of Jacks" all the time. The straight gets a rank of 80000 and the pair ranks at 801230000, like I think it should. Am I missing something you were pointing out? Please email me with more details if so. Thanks for testing out the function. Best Regards,
|
|
| 28 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | B, James | Is this working properly??? In the example
15 29 43 45 20 9 31
|
|
| 20 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | S, Rob | James, Thanks for the suggestion. In rev 2 (now posted) we actually did replace the bweuler call with something simpler and faster. I like the idea of using sum(diff), but there are some cases that it appears not to work. Check out the any(sum(logical)) method that Doug came up with. I think this is much closer to elegant than my original approach. So, the image processing toolbox requirement is gone. But there is still a call to combnk, which is from the statistics toolbox. Besides pasting that m-file in as a subfunction, I haven't found a better way. If you have an interest in simulating poker hands, or the associated stats, please share your work. There are lots of neat combinatorial things to do with card games. Best,
|
|
| 20 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | Kemp, James | Pretty neat, but it's a bit of shame that it uses toolboxes just to test for a straight. Couldn't the test: (bweuler(rowsum(1:13))==1) be replaced with something like (sum(diff(rowsum(1:13))==-1)==1), it's a bit unwieldy and not nearly as elegant as that in the code, but it seems to works. (Although I only tested it with two hands!) |
|
| 20 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | S, Rob | Marcelo,
Doug,
Best,
|
|
| 19 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | Perlin, Marcelo | Agreed Doug, Also, I just spotted an error at my msg. The input should be: {'A','spades' ; 2,'Diamonds'...} forming a total of 7 rows and 2 columns. Another idea, which is similar to the monte carlo simulation, is to use the code to play poker against matlab in a GUI environment. You can also extend it by allowing to computer to make rational choices over the game considering probabilistic measures (maybe given by monte carlo?). |
|
| 19 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | Hull, Doug | Marcelo, I agree that this would be very useful for simulation, that is in fact why I made the request for it on my blog: http://blogs.mathworks.com/pick/2007/11/13/lazyweb-on-the-file-exchange/ I think that the engine should be separate from the Monte Carlo, so this structure is perfect. |
|
| 19 Nov 2007 | Poker hand ranker Function that evaluates poker hands, returns ranks and text descriptions. | Perlin, Marcelo | This is nice, but I think the input is not very intuitive, Why dont you make it as [number,suite;number;suite ...] e.g. [A,Spades;2,Diamonds ...] Also, another suggestion to make things interesting is to write functions and scripts for a monte carlo experiment and see how much % of the simulations you can beat with your current hand. Such function could take as input: - number of players in the table
and the output would be the number of simulations where you beated the other players (or n of the others). Then you can use the simulation function and play poker with your players assisted by Matlab power. Cool, isn't it? |
|
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.
Contact us at files@mathworks.com