• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bridge anyone? [not off topic]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bridge anyone? [not off topic]


  • Subject: Re: Bridge anyone? [not off topic]
  • From: email@hidden
  • Date: Wed, 3 Nov 2004 11:21:27 -0500

At 4:42 PM +0000 11/2/04, Nigel Garvey wrote:


Of the scripts I've seen so far, Bernard's is not only the fastest, but it supplies each player's cards ready sorted! I still haven't worked out how it works, though. :-)

I was chagrined, because as soon as I read the initial question, I thought of the same algorithm and wrote it out, sorting the list in half the time of other methods. But Bernard beat me to posting it.


The idea is, rather than deciding on a random card from the deck and dealing the hands in order, instead deal from the sorted deck, but choose randomly which hand to deal to for each card. Once a hand has 13 cards, omit that hand from further consideration.

The idea is that you avoid doing a bunch of shuffling on the large list, and stick strictly to relatively fast "set end of list to ..." operations on the hands list. You do have to delete items from the small counter list that shows which hands are not yet full, but this only happens 4 times, not 52. Hence the big time savings.

I'm pretty sure there's an even better algorithm. I know standard card deck dealers use some kind of hash encoding of a single number to represent a whole hand. I'm guessing that the char-math that normally accompanies that kind of encoding won't fly easily in applescript. There are also issues in that 32-bits (standard integer) isn't enough to encode all possible bridge hands, so some dealers settle for a subset of possible hands that has sufficient range, rather than dealing with bignums.


Michael

--
Michael Sullivan                             613 West Johnson Avenue
                                             Cheshire, CT 06410
Business Card Express                        800-962-4030
Thermographers to the Trade                  email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Bridge anyone? [not off topic]
      • From: Martin Orpen <email@hidden>
    • Re: Bridge anyone? [not off topic]
      • From: Graff <email@hidden>
References: 
 >Re: Bridge anyone? [not off topic] (From: Nigel Garvey <email@hidden>)

  • Prev by Date: Re: Bridge anyone? [not off topic]
  • Next by Date: Timeouts & FileMaker Scripts
  • Previous by thread: Re: Bridge anyone? [not off topic]
  • Next by thread: Re: Bridge anyone? [not off topic]
  • Index(es):
    • Date
    • Thread