[CSC 330] Questions about Poker Hands

Andrew J. Pounds pounds_aj at mercer.edu
Sun Sep 3 18:03:20 EDT 2023


I am starting to get questions about how to build the hands 
classifications for sorting.  In other words, how do you decide if 
something is a straight, a full-house, etc.   Don't make this more 
difficult than it has to be.  For example, one person wanted to assign a 
unique number for each possible hand combination and use a lookup table 
for deciding the winning order.   That sounds like a nice computer 
science approach -- until you consider that you would have to process 
and store 311,875,200  different hands.

If you need some inspiration on how to break down the hands, take a look 
at https://rosettacode.org/wiki/Poker_hand_analyser.  Be warned, some of 
these are VERY convoluted and I didn't use any of them (my methods allow 
for a lot more code re-use) but they could get you going if you are 
having "code writers block".

My biggest piece of advice is to think about patterns.  Each of the 
poker hands has to observe certain patters (especially when the cards in 
the hand are sorted) -- so use that to your advantage.


-- 
*/Andrew J. Pounds, Ph.D./*
/Professor of Chemistry and Computer Science/
/Director of the Computational Science Program/
/Mercer University, Macon, GA 31207 (478) 301-5627/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://theochem.mercer.edu/pipermail/csc330/attachments/20230903/55776285/attachment.html>


More information about the csc330 mailing list