• 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: Nigel Garvey <email@hidden>
  • Date: Thu, 4 Nov 2004 12:06:28 +0000

email@hidden wrote on Wed, 3 Nov 2004 11:21:27 -0500:

>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.

I think I've got a new take on Bernard and Michael's idea, but the
statisticians out there would have to decide if it's valid. In Bernard's
script, each player always has one chance in four of being dealt the next
card card ‹ until one of them gets a full hand and the chances for the
other three suddenly change to one in three. Then one in two. Then
inevitability.

In the version below, each player starts off with thirteen chances in
fifty-two. As each chance is used up, the odds of any particular player
getting the next card change more gradually and more unevenly, thus
reducing the likelihood of the last player being landed with a run of low
clubs. This amateur theory seems to be born out by the results so far.

  script Bridge
    property cards : {"AS", "KS", "QS", "JS", "10S", "9S", "8S", "7S",
"6S", "5S", "4S", "3S", "2S", ¬
      "AH", "KH", "QH", "JH", "10H", "9H", "8H", "7H", "6H", "5H", "4H",
"3H", "2H", ¬
      "AD", "KD", "QD", "JD", "10D", "9D", "8D", "7D", "6D", "5D", "4D",
"3D", "2D", ¬
      "AC", "KC", "QC", "JC", "10C", "9C", "8C", "7C", "6C", "5C", "4C",
"3C", "2C"}
    property new_hands : {}
    property chances : {}

    on deal()
      set new_hands to {{}, {}, {}, {}}
      set chances to {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, ¬
        14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, ¬
        27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, ¬
        40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52}
      repeat with i from 1 to 52
        set h to some integer of my chances
        set item h of my chances to missing value
        set end of item ((h - 1) mod 4 + 1) of my new_hands to item i of
my cards
      end repeat
    end deal
  end script

  --set t to (GetMilliSec)
  --repeat 1000 times
  tell Bridge
    deal()
    its new_hands
  end tell
  --end repeat
  --((GetMilliSec) - t) / 1000

NG
 _______________________________________________
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

  • Prev by Date: Script Libraries
  • Next by Date: Fwd: Bridge anyone? [not off topic]
  • Previous by thread: Re: Bridge anyone? [not off topic]
  • Next by thread: Fwd: Bridge anyone? [not off topic]
  • Index(es):
    • Date
    • Thread