Re: Bridge anyone? [not off topic]
Re: Bridge anyone? [not off topic]
- Subject: Re: Bridge anyone? [not off topic]
- From: David Andrews <email@hidden>
- Date: Mon, 8 Nov 2004 21:17:43 -0500
Ok Folks,
The cards are randomly selected here and dealt (without any funny business) and sorted (without any sorting routine). The Unicode text may be removed if it might improve speed and some parts may be put into loops if so desired, but I went with simple code.
Oh, and only the first three hands are dealt, the last hand, West, just gets what's left over:
set suit0 to {"S", "H", "D", "C"} --> readable cards for archives
-- for pretty cards, <bill> email@hidden gave us:
-- black spade, white heart, white diamond & black club
set suit1 to {«data utxt2660», «data utxt2661», «data utxt2662», «data utxt2663»}
-- white spade, black heart, black diamond & white club
set suit2 to {«data utxt2664», «data utxt2665», «data utxt2666», «data utxt2667»} --< correction
set x to {"A", "K", "Q", "J", "X", "9", "8", "7", "6", "5", "4", "3", "2"}
set deck to {}
repeat with j from 1 to 4
repeat with i in x
set end of deck to ("" as Unicode text) & (contents of i) & item j of suit0
end repeat
end repeat
set dealt to {}
repeat with n from 1 to 52
set end of dealt to n
end repeat
set emptyHand to {}
repeat 52 times
set end of emptyHand to missing value
end repeat
copy {emptyHand, emptyHand, emptyHand, {}} to {north, east, south, west}
repeat 13 times
set c to (some integer of dealt)
set item c of dealt to missing value
set item c of north to item c of deck
set c to (some integer of dealt)
set item c of dealt to missing value
set item c of east to item c of deck
set c to (some integer of dealt)
set item c of dealt to missing value
set item c of south to item c of deck
end repeat
set north to every Unicode text of north
set east to every Unicode text of east
set south to every Unicode text of south
set dealt to every integer of dealt
repeat with c in dealt
set end of west to item c of deck
end repeat
{north, east, south, west}
-->{{"AS", "QS", "7S", "KH", "9H", "AD", "8D", "5D", "2D", "KC", "9C", "8C", "3C"}, {"XS", "9S", "4S", "2S", "AH", "XH", "QD", "XD", "6D", "4D", "JC", "4C", "2C"}, {"JS", "8S", "5S", "3S", "QH", "8H", "7H", "6H", "4H", "JD", "9D", "7D", "6C"}, {"KS", "6S", "JH", "5H", "3H", "2H", "KD", "3D", "AC", "QC", "XC", "7C", "5C"}}
David A
_______________________________________________
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