Compare Scores

Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2009
Posts: 29
Reputation: txwooley is an unknown quantity at this point 
Solved Threads: 3
txwooley txwooley is offline Offline
Light Poster

Compare Scores

 
0
  #1
May 7th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,067
Reputation: jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough jlm699 is a jewel in the rough 
Solved Threads: 268
Sponsor
jlm699's Avatar
jlm699 jlm699 is offline Offline
Knows where his Towel is

Re: Compare Scores

 
0
  #2
May 7th, 2009
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:
high card = 1
pair = 2
two pair = 3
three of kind = 4
etc...
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?
1. Use Code Tags.
2. Homework? Show Effort.
3. Keep discussions on the forum: no PMs
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 29
Reputation: txwooley is an unknown quantity at this point 
Solved Threads: 3
txwooley txwooley is offline Offline
Light Poster

Re: Compare Scores

 
0
  #3
May 7th, 2009
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?
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 128
Reputation: slate is an unknown quantity at this point 
Solved Threads: 31
slate slate is offline Offline
Junior Poster

Re: Compare Scores

 
0
  #4
May 11th, 2009
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:
  • 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.
So the compare function is simply the comparison of the value.

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
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 29
Reputation: txwooley is an unknown quantity at this point 
Solved Threads: 3
txwooley txwooley is offline Offline
Light Poster

Re: Compare Scores

 
0
  #5
May 13th, 2009
I think I get the idea now. Thanks for the help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Python Forum
Thread Tools Search this Thread



Tag cloud for Python
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC