| | |
Compare Scores
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2009
Posts: 29
Reputation:
Solved Threads: 3
I am fairly new to Python, but trying to make a poker game. How do I determine the winner? I have 'scored' the hands 1-8, and given sub-scores for the high card, but how do I compare the scores of 4 players and then in the event of a tie, compare the sub-scores of the tied players? I have been contimplating this for 3 days now, and still come up blank. I wish I could post the code I have so far, but it is simply an empty def statement. Does anyone know a simple algorithm for this? Or even a long drawn out process would be fine at this point. Thanks.
That's an interesting challenge... If it were me I would use a two-tiered scoring system, whereby you could assign a value to the hand itself, ie:
Then, in the event of a tie, you'd need to compare the actual value of the hand. Do you get my meaning?
Is that what you were asking or am I misinterpreting your question?
•
•
•
•
high card = 1
pair = 2
two pair = 3
three of kind = 4
etc...
Is that what you were asking or am I misinterpreting your question?
•
•
Join Date: Apr 2009
Posts: 29
Reputation:
Solved Threads: 3
Well, I assigned scores like you mentioned, "High card" = 1, "Pair" = 2..."4 of a Kind" = 7, "Straight Flush" = 8. And I assigned sub-values to the high card. "Ace" =13, "King" = 12..."2"=2. But I'm not sure how to write the script to compare them to determine the 'winner'. I thought of putting them into a list and using max(list), but then, how do I associate the high score with the player?
•
•
Join Date: Jun 2008
Posts: 128
Reputation:
Solved Threads: 31
If I understand correctly, you want to have a strict order of poker hands. That means, there can be a tie only, when all the cards are the same, except the colour (pikk, tref ...)
The hand value can be a 6 member tuple:
case 1: K,Q,10,8,2 (not the same colour)
value: 0,13,12,10,8,2
case 2: a,2,3,4,5 (not the same colour)
value 4,5,4,3,2,1
case 3: 10,10,10,J,J (not the same colour)
value 6,10,10,10,11,11
And so on...
I am not a big player, but I could not find the exact rules on the net.
I hope I have given some help with this.
The hand value can be a 6 member tuple:
- First the formation value 0-9, poker twopairs etc...
- Second the the value of the cards in the formation in descending order. In case of full, the 3 member part comes before (I think a 3xJ-2x10 full beats a 3x9-2xQ full). In case of a flush or straight beginning with ace, the ace comes at last (with value 1) etc ...
- Third the values of the other cards in descending order.
case 1: K,Q,10,8,2 (not the same colour)
value: 0,13,12,10,8,2
case 2: a,2,3,4,5 (not the same colour)
value 4,5,4,3,2,1
case 3: 10,10,10,J,J (not the same colour)
value 6,10,10,10,11,11
And so on...
I am not a big player, but I could not find the exact rules on the net.
I hope I have given some help with this.
Last edited by slate; May 11th, 2009 at 7:07 pm. Reason: Removed impossible full houses
![]() |
Similar Threads
- Finding the lowest of five test scores (C++)
- SCORING SYSTEM C++ (C++)
- Help With Java (Java)
- c++ scores (C++)
- Time function (C)
Other Threads in the Python Forum
- Previous Thread: Command line question
- Next Thread: Passing an Object Arguements
| Thread Tools | Search this Thread |
Tag cloud for Python
ansi assignment avogadro backend beginner binary bluetooth character cmd code customdialog cx-freeze data decimals dictionary drive dynamic error examples excel exe file float format ftp function gnu graphics gui heads homework http ideas import input java leftmouse line linux list lists logging loop module mouse number numbers output parsing path pointer port prime program programming progressbar projects push py2exe pygame pyqt python random recursion recursive refresh schedule screensaverloopinactive script scrolledtext sqlite ssh statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable wikipedia windows write wxpython xlib






