[Solved] Poker Run Card Sorting

Discuss the spreadsheet application
Post Reply
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

[Solved] Poker Run Card Sorting

Post by HGR »

Hi all -

I love Open Offices ease of use ... great program.

I am currently hosting a Poker Run where up to 100 motorcycles and vehicles ply a circuit route and collect a poker card at each route stop (5). It's a 5 card game, Five of Kind down to the lowest hand.

The winner and the second place winner and the lowest hand win prizes (fun stuff)

Here's my dilemma. I created a spreadsheet with the following cells (there will be 100 rows of entries. I used a numbering system for the cards selected: 14 for King all the way down to 1 for the ACE. Each column per row is like this (for example) Cell 1: First Card # (1-14), Cell 2: The suit (S,H,D,C for Spades, Hearts, etc). Third cell is the Second Card followed by the cell with the suit. This occurs on 10 consecutive cells. 14 C 8 C 14 D 9 S 4 H 4 D 6 H
I want to sort these to determine the highest hand of the 100, by sorting ... then I'll duplicate the original rows and columns to sort for the second highest hand, then the lowest.

I can't seem to make this work. Is there a simple way (that works for 100 rows) ? Otherwise it's a hand by hand process which might take one person hours.

Thanks for ANY help. Keep it simple, I'm a simpleton (hah).

HGR
Last edited by Hagar Delest on Wed May 23, 2018 10:33 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 4.1.on Windows 10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Poker Run Card Sorting

Post by RusselB »

Welcome to the Forum.
This will not be easy, and I have other things to do at the moment, but I do believe it is possible.
One thing I would like to clarify, is the reason you are using 14 for King? Based on Ace being 1, and using a standard deck of cards, that would make the King be the 13th card, not the 14th.... I'm going to presume that you are not allowing wildcards in the poker hands, as they would make an already complicated calculation even more so.
With up to 100 players, and 5 cards per hand, are you working with multiple decks, or might some players be outed due to other players getting the cards? A single deck of 52 cards is only sufficient for 10 hands of 5 cards, thus only 10 players can have a valid 5 card hand.
If you are allowing multiple decks, then how many decks? For 100 players to have valid 5 card hands, you would need 10 decks, thus causing possible 10 way ties for each possible hand.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Poker Run Card Sorting

Post by Lupp »

The central task as I see it isn't how to represent any card, or how many columns or copies to use.
The fundamental task is to collate two hands. If you can clearly tell me that, I think I'll be able to suggest a solution.
If this is thought to be trivial, I need an explanation in what way.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Russell -

Correct, the king is a 13, not a 14. Those damn Kings always want to be better than the rest.

That being said. previous Poker Runs I have been on with over 100 riders always used two decks reshuffled after each participant. The winning hand tie-offs were minimal doing it that way. We have a two-card draw, winner takes all in the event of any tie off, using only one deck - but again, tie offs were pretty minimal.
As an administrator, I figured I'd follow suit (sic).
I've had no luck using the SORT function every which way I could. Sometimes the sort would come up out of order on the first card, but all the others would follow their original row make-up, sometimes the first cards would sort correctly but the following rows would stay in their same position. It's making me crazy(ier). I'm no dummy in problem solving, but this one has me stumped. Again, we can spend an hour or two, manually checking the Tally Sheets and picking out the winner, second prize, and the loser hand ... but I thought that's what spreadsheets were for....perhaps I'm wrong.

Your reply was great, thanks, and do you think this can be done with Apache Spreadsheets ?

Be well,
HGR
OpenOffice 4.1.on Windows 10
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Lupp - After Russels correction on my card count let me clarify.

If a participant draws a 10 of spades at the first stop, a King of spades at the second, a Queen of spades at the third, a 7 of spades at the second and a 4 of spades at the last stop (A Flush),
I would represent (example) this way: Column 1: 10 Column 2: S Column 3: 13 Column 4: S Column 5: 12 Column 6: S Column 7: 7 Column 8: S Column 9: 4 -and- Column 10: S .
Columns 1,3,5,7,9 represent the number equivalent of the Rank of Hands and Colunns 2,4, 6, 8, 10 represent the suit The S, if not obvious, is for the Spade card in the even numbered Columns.

As far as your question about collating two hands .... hmmm, you lost me there bud .... not sure what you mean but I hope I've given you a clearer explanation, I hope.

HGR
OpenOffice 4.1.on Windows 10
User avatar
keme
Volunteer
Posts: 3699
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Poker Run Card Sorting

Post by keme »

HGR wrote:[...]
As far as your question about collating two hands .... hmmm, you lost me there bud .... not sure what you mean but I hope I've given you a clearer explanation, I hope.
Collating two hands is the same as to rank them, to determine which one is the winner.
For the standard poker hands, collating order is readily available online. Using non-standard hands makes it difficult, but you clarified that. I am talking about the 5 of a kind, which is not available with a standard deck. (You need to introduce wildcards or multiple decks.) Sometimes the royal straight flush beats 5 of a kind, but you clearly stated that 5 of a kind is the top hand.

I assume that other non-standard hands (cats, dogs, bobtails etc.) are not considered, and there is no suit ranking (all suits are of equal value) and only top kicker card considered.

With that, you have the following collating:
  • 5 of a kind
    • highest card value wins
  • Straight flush
    • highest top wins
      In this case it may be possible to introduce suit ranking for additional resolution of ties.
  • Four of a kind
    • Highest card value on the quartet wins a tie
      • With multiple decks you can have tied quartets. You can add a rule that the highest kicker (card which is not part of the hand pattern) wins that tie.
  • Full house
    • Highest triplet wins a tie
      • Again, tied triplet is possible. In that situation, the highest pair wins.
  • Flush
    • Top card of the flush wins a tie
  • Straight
    • Top card wins a tie
  • 3 of a kind
    • Highest card value for the triplet wins a tie
      • Highest kicker wins tied triplet
  • Two pairs
    • Highest high pair wins tie
      • Highest low pair wins tie
        Kicker not considered
  • One pair
    • Highest pair wins tie
      • Highest kicker wins tied pairs
  • Highest card (the "nothing" hand)
Is that what we are working with? We then have around 680 distinct ranks, and with 100 players there will be ties. Can you live with that.

If you consider all kickers, highest first, you can have around 7500 different ranks so a tie is less likely. Still ties are to be expected, though.
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Keme -
As a pretty successful poker player over the years, I've seen it all. Amazingly, though, just last night I was looking at a poker site by HOYLE and it actually put 3 of a kind ABOVE a Flush. What ? THAT I've never seen before and now cannot find the reference.

So, Yes we are playing the following way at each stop:
Stop 1 - Participant draws one card from two shuffled decks of 52. No Wild Cards. If player doesn't like that first card, that card is put aside and participant draws the second card from 103 cards now (first card set aside) For 50 Pesos (I'm a VFW member in the Philippines) participant can get another and is stuck with the second card. Participant then hops on his motor, moves to the second Stop of the 57 mile Poker Run. At Stop 2, 3, 4 and last. The next participant does the same, fresh deck of two packs of cards, draws one card, if doesn't like, card is stet aside and blah, blah, blah. Having done the Barstow to Vegas annual November motorcycle runs, this is how, I believe, it was done. Never did win a hand there, but saw a few, but not many, ties. A one card playoff from a fresh deck of 52 determined the winner. I would've opted for worst hand but that was not to happen either.

So, is this SORT thing even possible given the cell data as I originally posted? I would've thought this would be easy for a spreadsheet, but I'm not a spreadsheet guru, just an old retired Veteran and ex-lineman for the phone company.

From what I'm seeing, perhaps the hand counting might be the only way -GROAN-, but we'z acceptz de as we'z seez dem.

Be weill,
HGR
OpenOffice 4.1.on Windows 10
User avatar
keme
Volunteer
Posts: 3699
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Poker Run Card Sorting

Post by keme »

Certainly possible. Only need confirmation on collating rules first:
  • Hand ranks: Do you agree on the sequence I have given above?
    Suit ranking? Is a flush in clubs different from a flush in spades, given same value cards? If so, how is the suit ranking?
    Value tiebreaker: Top card only, or every available card? This makes a difference for flush, and for multiple kickers (one pair/3OAK) and "nothing". Also, do you want to use the kicker as a tiebreaker for tied two pairs (which I ruled out above).
    Moveable ace? Can an ace be used low and high, or only low?
I believe that it simplifies the matter if we can limit to two tiebreaker levels for each hand. Haven't thought it through thoroughly, though, so in the end it may make little difference. If it is important to reduce the chance of a tie as much as possible, we can go the full distance (whatever that may be).

With multiple decks there is no way to rule out all ties (two players may, in theory, be dealt identical hands), so when you publish the contest rules (if you do), you must allow for either a final tiebreaker (e.g. highest card draw) or shared winning.
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Keme -

A thousand thank you's if you can find a way. This charity run is for the Prisoners of War / Missing in Action Fund. Currently we are working on finding the rest of an old military plane lost in the jungle that purportedly had 3 on board back in 1943. They were searching for Japanese that were rounding up the Philippine people and shooting the on site. War is bloody hell.

So, actually the rank of hands is like this:

Five Of A Kind
Royal Flush (any A,K,Q,J,10 of the same suit)
Straight Flush (any other than above consecutive card run of the same suit)
Four of a Kind
Full House
Flush
Straight
3 of a Kind
Two Pair
Singleton (The nothing hand yes)

Suit rankings, according to our published rules are Spades over Hearts, Hearts over Diamonds, Diamonds over Clubs. The kicker comes into play when necessary.

Your third question perplexes me. A kicker on down to the last card would determine, also using the Suit rankings above.

Aces are High and Low (but not both, obviously) An A,K,Q,J,10 is the highest, an A,2,3,4,5 is the lowest straight, also using the Suit rankings above.

No shared winnings. Any exact tie, the Official who announces the hands will have a two card playoff. Each of the ties draws two down cards and (no extras) the best two will be the winner. This keeps happening until all ties are finished. Gotta run, the sweetie just called for dinner, and I'm ALL IN for that.

HGR
OpenOffice 4.1.on Windows 10
User avatar
keme
Volunteer
Posts: 3699
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Poker Run Card Sorting

Post by keme »

Right!
The royal flush is just the highest straight flush, so needs no special handling (unless there should be a hand in between, like the case I mentioned before). I suspect the missing "one pair" in your list is just a minor slip :-) You'd want that too, right?

Dinner in order for me too (I'm cooking, kids are hungry, homework and then table tennis, so I can't promise I'm working the sheets today.) I'll look into it soon, unless someone else beats me to it (Wink wink, nudge nudge ...).
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Ummm, Major slip - of course, two pair. I've been working on a 32 Operations Manual to make sure our 25 volunteers are on the same page with how we operate this thing, and have been a bit distracted by that ... . When it comes to handling money, we shall leave no turnip unstoned .... err, no stone unturned.

I didn't know you were actually going to work on this ... WOW .... well MUBAHAY from the Philippines and the Veterans of Foreign Wars SALUTE you for your help. And lastly, congratulations for your stellar OLYMPICS teams for bringing home the most for the best. Yeah!

Thanks,
HGR
OpenOffice 4.1.on Windows 10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Poker Run Card Sorting

Post by Lupp »

As this seemed to be a somehow challenging task I came back and tried to understand what was posted since my first comment. Now I feel sure I did not understand the basics. As I read it I cannot even see how many decks are needed to do all that, and if any single participant draws all his cards from the same pair of decks ...
I would need a very clear description without any kind of slang as I'm not in the least experienced in the field, and my English is rather poor.

But: The main concern is still the collation.
Using two decks with 104 cards a flush can contain a pair or even be a two-pairs hand at the same time e.g.
What shall be higher then:
J, 10, 8, 7, 2 of spade or
J, 9, 5, 5, 2 also of spade containing the two spade fives from the two decks?
Shall the higher second-top card 10 win for the first player, or the pair of fives for the second one?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Ahh, wie gehts - Mein Duetsch nicht so gut. Familie ist von Heidleberg, Ancestral Familie von Mettlach.

Answer Question 1: Yes, a flush containing a pair will RULE over a flush containing no pair. (Since all five cards are needed, it seems any other way would not be fair). Simply answered: J,9,5,5,2 WINS over the J,10,8,7,2.

Danke, Bis Spater Freund

Gordy
OpenOffice 4.1.on Windows 10
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Poker Run Card Sorting

Post by Lupp »

And what about these two flushs (suit disregarded):
A, K, Q, J, 9 vs.
5, 4, 3, 2, 2 ?
The second one must win then. OK?

Regards
(The one with two grandsons in Heidelberg.)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Poker Run Card Sorting

Post by Lupp »

I had to consider and to try a lot in this case. It was my kind of cooking I assume, and it was some fun, too.
But, after all, I never played poker except for some funny phantasy variants 55 years ago. Misunderstandings to be expected.

To avoid serious complications I had to rely on the IFERROR() function still not implemented in AOO. Therefor the demo will only run in not too old versions of LibO. Simply try a PortableApps LibO to avoid the need of installation.

Sorting in spreadsheets by formulae my way I have to use OFFSET() which will heavily slow down the reaction on input. On the other hand I worked with a constant number of rows to slightly simplify formulae and make them better understandable. In a real application I would parametrise this, too.

Since the file was too large for an upload here anyway, I did not cut the sheet down to less than the 2000 rows of (mostly) random hands I tested with.

You find the demo here: http://psilosoph.de/AskLO/OnlyWorkingIn ... anking.ods .
(I'm imterested in refutations!)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Poker Run Card Sorting

Post by Lupp »

(I'm still interested in refutations, but also in confirmations of any kind.)

A few additional remarks:

-1- I did not apply the representation of each card using two adjacent cells as HGR (the OQ) had described it. Instead I used one cell only representing the kinds by the numbers 2 through 14 and the suits by adding 0.1 through 0.4. There was no ranking concerning the suits but you may assign the ascending tenths denominators to Club, Diamond, Heart, and Spade in this order.
Having entered the cards in HGR's representation a mapping to my single-cell variant can easily be done by simple formulae.

-2- For a "Straight to 5" the Ace was interpreted as a "1", but not renamed. It stayed a "14".

-3- I had stressed the "collation" equalising the term roughly with "ranking comparison of pairs". This is not exactly what I did.
In fact I preferred to map all the possible hands to elements of a "value-space" regarding the requirements that
-a- any higher ranking hand is assured to get a higher value-code than any lower ranking one.
-b- equally ranking hands get the same (identical) value-codes.

For the mentioned space I didn't try to keep it small, but mainly to get value-codes to whitch lexicographical collation is applicable. Avoiding complicated calculations this approach led me to use strings of 24 characters consisting of decimal digits exclusively as the value-codes. (To get "human readable" value-codes the easiest way was to use base 100 instead of base 15 for the virtual g-adic numbers I had in mind. I didn't choose this way. It can easily be introduced by a few adaptions, however.

-4- About sorting
Sorting by formulae in spreadsheets is "expensive". You need some helper columns and slightly complicated formulae there having to do lots of comparisons before they can return their results. In common terms the time complexity for the way I'm doing it (it's a rather clever way I would claim) is O(N^2) as is the usual thing for the simple kind of sorting algorithms also if not restricted to spreadsheet formulae.
However, if you consider to write a program doing the sort in the background, the lexicographical approach would allow to use a radix-sort which is about O(N) in time usage. And, somehow more realistic: The mapping to value-codes allows to leave the apparatus of formulae at that, and to do the sorting by an interactive subsequent step. (Done by hand no time saved, I'm afraid.)
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
HGR
Posts: 8
Joined: Mon Apr 09, 2018 6:36 pm

Re: Poker Run Card Sorting

Post by HGR »

Ladies and Gentlemen - Original Poster on this thread here.

First off, I would like to thank you for ALL your hard work in assisting me with this. You all are far more intelligent than I can ever imagine to be. Half the stuff you posted was way beyond me so much so that I had to invest in a bottle of good Kentucky bourbon. :D .

It appears that I did have one positive effect … the melding of minds to come up with a solution to this issue. That's what makes this forum great … the sparking of ideas, better ways, the like.

Now, don't get upset at me after all your work, but trying out some of your suggestions left me befuddled and, unfortunately resource poor. Once entering information into the spreadsheet examples the computer locked up … not once, but many times. It appears I was not alone in being befuddled.

So, here is my simplified solution:

We decided to use ONE DECK of cards only, AND, using the participants tally sheets at each stop, we also decided to NOT reissue a card they might have previously selected. So, at stop 1 they draw a 6 of clubs as a keeper. When they get to stop 3 (for example) and draw another 6 of clubs, that card gets set aside and they draw another unique card. Simplified, delightful.

The last thing we did to avoid having to tally up all these results, we decided to ASK the participants at the prize draw to announce their winning hands … somewhat like this:

THe EmCee announces : OK, everyone who has a ROYAL FLUSH come up. If not Royals, we go announcing anyone who has four of a kind, and on down the line. Leave it up to the participants to do all the hard work. All we would do then is to verify their ticket with our master log to insure that no cheating took place.

Dumbification works sometimes.

Again, thanks all .. brilliant minds produce brilliant results.

HGR
OpenOffice 4.1.on Windows 10
Post Reply