Re: Bridge anyone? [not off topic]
Re: Bridge anyone? [not off topic]
- Subject: Re: Bridge anyone? [not off topic]
- From: Bill <email@hidden>
- Date: Tue, 2 Nov 2004 17:47:17 +0800
Any way to increase the efficiency of this script that deals out a
bridge (or spades, or hearts, etc.) hand?
set the pack to {}
set the terminator to {}
set the cards to {"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"}
Michelle,
May I suggest a unicode version of cards ;)
-- 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
utxt2666»}
set x to {"A", "K", "Q", "J", "10", "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
suit1
end repeat
end repeat
deck
-- {"A♠", "K♠", "Q♠", "J♠", "10♠", "9♠", "8♠", "7♠", "6♠", "5♠", "4♠",
"3♠", "2♠", "A♡", "K♡", "Q♡", "J♡", "10♡", "9♡", "8♡", "7♡", "6♡",
"5♡", "4♡", "3♡", "2♡", "A♢", "K♢", "Q♢", "J♢", "10♢", "9♢", "8♢",
"7♢", "6♢", "5♢", "4♢", "3♢", "2♢", "A♣", "K♣", "Q♣", "J♣", "10♣",
"9♣", "8♣", "7♣", "6♣", "5♣", "4♣", "3♣", "2♣"}
if you want suit2, change the line to
set end of deck to ("" as Unicode text) & (contents of i) & item j of
suit2
deck
-- {"A♤", "K♤", "Q♤", "J♤", "10♤", "9♤", "8♤", "7♤", "6♤", "5♤", "4♤",
"3♤", "2♤", "A♥", "K♥", "Q♥", "J♥", "10♥", "9♥", "8♥", "7♥", "6♥",
"5♥", "4♥", "3♥", "2♥", "A♦", "K♦", "Q♦", "J♦", "10♦", "9♦", "8♦",
"7♦", "6♦", "5♦", "4♦", "3♦", "2♦", "A♦", "K♦", "Q♦", "J♦", "10♦",
"9♦", "8♦", "7♦", "6♦", "5♦", "4♦", "3♦", "2♦"}
bill
☠ 孤寂地
<http://homepage.mac.com/cherish/triste/>
_______________________________________________
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