Poker Hand Scoring Program -- Almost Done
This program ( scorePoker_0_040.htm) ranks poker hands based on Hoyle's page at http://www.hoylegaming.com/rules/showrule.aspx?RuleID=222 .
It identifies the vairous hand combinations (straight flush,four of kind.full house, etc.) correctly, but the numeric ranking isn't quite working ({KH AC AS AD AH} a full house gives 14253 which is higher than {10H JH QH KH AH} straight flush at 12318).
NOTE program developed and tested only in Google Chrome browser version Version 39.0.2171.95 m
Running the program
This program is at scorePoker_0_040.htm.
The poker hands may be entered in the field to the right of the Enter hand label (A in the picture) in the format of 7S 10D 7H 9C 9S .
"D","H","C","S" are the suffix of each card and stand for diamonds, hearts, clubs, and spades resspetively.
The prefixes 10,J,Q,K,A and 1 to 9 are the prefix for each representation of the cards. Alphabetic characters may be of either upper or lower case. Note: pressing the Tab key or otherwise moving out of this field
has the program process the hard.
Alternatively a hand may be entered using the radio buttons labeled B. If duplicate cards are entered, the last duplicate is blanked. When five cards are entered this way the program processes the hand.
Pushing the nextStored button (C in the picture) will input a sample test hand. Repeatedly pressing it will cycle through the (30+ in this version) hands shown below at stored sample data.
A number may be put into the field right the item label (D in the picture) to select one of the sample hands.
Pushing the Random_Hand button (E in the picture) will generate a random hand. Samples are shown below at randomly generated sample data .
Results:The text area labeled F in the picture reports the score along with a bunch of information used to test and debug the program.
- As noted previously -- scoring not working quite properly ({KH AC AS AD AH} a full house gives 14253 which is higher than {10H JH QH KH AH} straight flush at 12318).
- Strict score - ranking by the rules on the hoyle page http://www.hoylegaming.com/rules/showrule.aspx?RuleID=222 .
- - Score possibly more cases than by Strict score
- second Score - tiebreaker when two hands matching Strict score or Strict score.
- in future versions probably will seperate into Tie breaker Strict score or Tie breaker
Fields for entering first and last name are labeled G and H in the picture.
Summary of running:
- program at scorePoker_0_040.htm
- first and last name are labeled G and H in the picture. (Fill these first)
- Entering Hands
- enter at field to the right of the Enter hand label (A in the picture). Leave field (press tab key) to get program to process.
- radio buttons labeled B
- nextStored button (C in the picture) gives a sample hand
- Random_Hand button (E in the picture)
- Results in text area F.
fixes and modifications
- get scoring to work correctly
- split tiebreaker score into strict and not
- put in fields so key key2 may be entered
- remove card entry radio buttons (B in picture)
- put in dummy first and last fields in HDS.add( so that easier to import to spreadsheet
- put in yr,mon,day,hr,min fld ?
- have program store, sort, and retrieve entered hands
- Javascript won't save to file -- but can save in memory - kept as long as program is running - can copy out of text area.
- possible could have send to .php program on servers to save -- rusty at doing this
Sample data:
field descriptions -- likely to change some in newer version
HDS.add(key,key2,strict_score,score,tie_breaker_score,"First Name","Last Name","Hand","result");
- key option to add numeric field to sort on -- sample data vs. real perhaps ... not yet implemented
- key2 option to add numeric field to sort on -- sample data vs. real perhaps ... not yet implemented
- strict score exactly by Hoyle
- score seperating hands a little more ... stuff perhaps not mentioned by Hoyle
- tie_breaker_score (second score) if two hands have the same score and strict score
- First Name
- Last Name
- Result eventually to be straight flush,four of kind,four of kind, etc.
-
- add strict tie breaker?
stored sample data
Press Next_Stored button to generate
HDS.add(0,0,12318,12318,0,"highest straight flush","sample ","10H JH QH KH AH ","straight flush with with high card AH");
HDS.add(0,0,12318,12318,0,"generated !!!! highest straight flush","sample ","10H JH QH KH AH ","straight flush with with high card AH");
HDS.add(0,0,12318,12318,0,"generated !!!! highest straight flush","sample ","10H JH QH KH AH ","straight flush with with high card AH");
HDS.add(0,0,1131,1131,52,"low runt","sample","2C 4S 5S 6C 7C ","runt");
HDS.add(0,0,2470,2470,221,"high runt","sample","9D 10C JS QH AD ","runt");
HDS.add(0,0,3685,3685,6,"mid pair","sample","7S 8D 8H 9S JH ","pair");
HDS.add(0,0,2588,2588,2,"low pair","sample","2D 2H 3S 4D 5D ","pair");
HDS.add(0,0,4728,4728,10,"high pair","sample","JD QS KS AD AH ","pair");
HDS.add(0,0,6515,6515,0,"mid two pair","sample","7S 8D 8H JS JH ","two pair");
HDS.add(0,0,5083,5083,0,"low two pair","sample","2D 2H 3S 3D 5D ","two pair");
HDS.add(0,0,7092,7092,0,"high two pair","sample","QS KS KD AD AH ","two pair");
HDS.add(0,0,7281,7322,0,"lowest 3 of a kind","sample","2C 2D 2H 3S 4C ","three of a kind");
HDS.add(0,0,9309,9476,0,"highest 3 of a kind","sample","QH KS AC AS AD ","three of a kind");
HDS.add(0,0,9505,9505,0,"mid lowest straight","sample","5H 6D 7C 8S 9H ","straight with with high card 9H");
HDS.add(0,0,9502,9502,0,"second lowest straight?","sample","2C 3S 4H 5H 6D ","straight with with high card 6D");
HDS.add(0,0,9501,9501,0,"lowest straight","sample","2C 3S 4H 5H AD ","straight with with high card 5H");
HDS.add(0,0,9510,9510,0,"higest straight","sample","10C JC QH KS AD ","straight with with high card AD");
HDS.add(0,0,11375,11375,897,"mid flush","sample","4S 5S 6S 7S 10S ","flush with high card 10S");
HDS.add(0,0,10842,10842,702,"lowest flush","sample","2D 4D 5D 6D 7D ","flush with high card 7D");
HDS.add(0,0,12181,12181,1807,"highest flush","sample","9H 10H JH QH AH ","flush with high card AH");
HDS.add(0,0,13018,13018,0,"mid full house","sample","7S 7D 7H 9C 9S ","full house");
HDS.add(0,0,12095,12095,0,"lowest full house","sample","2C 2S 2H 3S 3D ","full house");
HDS.add(0,0,14253,14253,0,"highest full house","sample","KD KH AS AD AH ","full house");
HDS.add(0,0,2392,2392,65,"too many cards","sample","3S 4D 6H JS AD ","runt");
HDS.add(0,0,13246,13245,0,"mid four of kind","sample","7C 7S 7D 7H JC ","Four of a kind");
HDS.add(0,0,12297,12296,0,"lowest four of kind","sample","2C 2S 2D 2H 3C ","Four of a kind");
HDS.add(0,0,14455,14454,0,"highest four of kind","sample","KH AC AS AD AH ","Four of a kind");
HDS.add(0,0,12313,12313,0,"mid straight flush","sample ","5H 6H 7H 8H 9H ","straight flush with with high card 9H");
HDS.add(0,0,12309,12309,0,"lowest straight flush","sample ","2H 3H 4H 5H AH ","straight flush with with high card 5H");
HDS.add(0,0,12318,12318,0,"highest straight flush","sample ","10H JH QH KH AH ","straight flush with with high card AH");
randomly generated sample data
generate by pressing Random Hand button to generate
HDS.add(0,0,2864,2864,1,"","","2H 7D KS 3H 3D ","pair");
HDS.add(0,0,4206,4206,4,"","","JH QS JC 5C 10S ","pair");
HDS.add(0,0,3034,3034,6,"","","7S 4C 4D KH 8D ","pair");
HDS.add(0,0,1521,1521,39,"","","3H 7D 8H 9C 2H ","runt");
HDS.add(0,0,8464,8583,0,"","","9C 9H 10S 9D 3S ","three of a kind");
HDS.add(0,0,2093,2093,130,"","","QC 9S 8H 4D JC ","runt");
HDS.add(0,0,4699,4699,5,"","","AC JS AD 9S 6H ","pair");
HDS.add(0,0,4514,4514,4,"","","10H 6C KS KD 5D ","pair");
HDS.add(0,0,4022,4022,2,"","","3C 10C 10H JC 8C ","pair");
HDS.add(0,0,2171,2171,52,"","","2H KH 5S 4C 8S ","runt");
HDS.add(0,0,1469,1469,39,"","","3C 9D 6S 5S 2D ","runt");
HDS.add(0,0,2868,2868,8,"","","JD 3C 9H KS 3D ","pair");
HDS.add(0,0,2353,2353,78,"","","8S AS 3D 6C 5C ","runt");
HDS.add(0,0,2223,2223,65,"","","5H 2C 7C 10S KS ","runt");
HDS.add(0,0,3531,3531,2,"","","QC 7S JC 7D 3D ","pair");
HDS.add(0,0,2223,2223,39,"","","3S 2D 5H QC KD ","runt");
HDS.add(0,0,4320,4320,1,"","","7D 8D QS 2D QD ","pair");
HDS.add(0,0,2444,2444,78,"","","QC 5C 3D 9H AC ","runt");
HDS.add(0,0,7788,7925,0,"","","5H 8H 5D JH 5C ","three of a kind");
HDS.add(0,0,7281,7460,0,"","","JS 2H 2D AS 2C ","three of a kind");
HDS.add(0,0,2685,2685,3,"","","4S 2S 10D QC 2D ","pair");
HDS.add(0,0,1703,1703,52,"","","10C 7S 4C 9S 2D ","runt");
HDS.add(0,0,2288,2288,156,"","","QD 5D 10D 9H KC ","runt");
HDS.add(0,0,2854,2854,6,"","","3D 7D 3S 10H QH ","pair");
HDS.add(0,0,1976,1976,52,"","","6C QS 5H 4C 2H ","runt");
HDS.add(0,0,6320,6320,0,"","","6H 7C 10S 6S 10H ","two pair");
HDS.add(0,0,2869,2869,6,"","","7C 3H KH QD 3D ","pair");
HDS.add(0,0,4359,4359,2,"","","QS QD JS 3S 7H ","pair");
HDS.add(0,0,2602,2602,3,"","","6C 2H 2S 5H 4D ","pair");
HDS.add(0,0,2979,2979,2,"","","5H 9D 4C 3S 4S ","pair");
HDS.add(0,0,3220,3220,8,"","","QD AH 9S 5D 5S ","pair");
HDS.add(0,0,2262,2262,52,"","","8C 2S 4S QD KD ","runt");
HDS.add(0,0,2093,2093,91,"","","3C 9D JS QH 6S ","runt");
HDS.add(0,0,3559,3559,3,"","","KH 7C 7H AS 4D ","pair");
HDS.add(0,0,2093,2093,78,"","","6H 9D 2C QS JC ","runt");
HDS.add(0,0,4034,4034,1,"","","10C QD 2D 10S 7C ","pair");
HDS.add(0,0,2457,2457,169,"","","8C 9S KD AS 7D ","runt");
HDS.add(0,0,3541,3541,5,"","","7D 6D 7H KD 8S ","pair");
HDS.add(0,0,2470,2470,65,"","","AC 3C 4D JH QS ","runt");
HDS.add(0,0,4319,4319,2,"","","8H QC 3H QS 6C ","pair");
HDS.add(0,0,6457,6457,0,"","","JD JS 3H AS 3C ","two pair");
HDS.add(0,0,4049,4049,1,"","","2C 9S 10H KD 10S ","pair");
HDS.add(0,0,1807,1807,65,"","","4C 6C JH 5S 3D ","runt");
HDS.add(0,0,5635,5635,0,"","","5H JD 6D 5S 6H ","two pair");
HDS.add(0,0,6180,6180,0,"","","9H 9S 8D 8C 10H ","two pair");
HDS.add(0,0,5626,5626,0,"","","5C 5S 6H 2S 6C ","two pair");
HDS.add(0,0,2405,2405,78,"","","3H 5S 6S QC AC ","runt");
HDS.add(0,0,2483,2483,130,"","","KC AD 3C JC 9H ","runt");
HDS.add(0,0,3179,3179,5,"","","JD 5C 5D 10H 6H ","pair");
HDS.add(0,0,3221,3221,9,"","","AC KH 5C 10D 5D ","pair");
HDS.add(0,0,2223,2223,117,"","","KD 8C 9D 6C 5C ","runt");
HDS.add(0,0,3034,3034,6,"","","7D KS 4H 4C 8H ","pair");
hint on reading with spreadsheet
sample .txt file of previous section to read into excel, etc. Is partially comma seperated. If delimete on "(" & ")" all fields would go to seperate columns. Future version to put in dummy column so can
just use comma delimeter.