• 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: kai <email@hidden>
  • Date: Mon, 8 Nov 2004 02:31:05 +0000

On Thu, 4 Nov 2004 12:06:28 +0000, Nigel Garvey wrote:

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.

You've probably already done something like this, Nigel - but, in view of concerns over the validity of certain random dealing methods, I decided to compare for myself the results of a few scripts. My original reason for doing so had more to do with my difficulty in deciding if Bernard's/Michael's original approach was entirely random or not. For some reason, although my instincts told me it wasn't, I was reluctant to write it off without further evidence.


To check it, I selected a handful of scripts (including yours of 4 Nov) between which I could then make certain comparisons:

------------

Michelle:
http://lists.apple.com/archives/applescript-users/2004/Nov/msg00011.html

Kai 1:
http://lists.apple.com/archives/applescript-users/2004/Nov/msg00016.html

Graff 1:
http://lists.apple.com/archives/applescript-users/2004/Nov/msg00024.html

Bernard:
http://lists.apple.com/archives/applescript-users/2004/Nov/msg00038.html

Nigel Latest:
http://lists.apple.com/archives/applescript-users/2004/Nov/msg00112.html

------------

(Yeah, I know. That last one says 'Nigel Latest' - but then we know there's nearly always a new, improved version just around the corner - right?) ;-)

I then cobbled together a script (below) to make the comparisons. Initially, I intended to use it purely for my own purposes. However, I thought that I might share it here, FWIW.

The question was: what to extract and compare? In fact, I tried a few different comparison methods, of which the following is one of the simpler. Essentially, it merely does this on each run:

1) Run a target script to deal the cards into 4 hands

2) Select only the hand that contains the 2 of clubs

3) Count all the clubs in that hand

4) Run steps 1 thru 3 a total of 1,000 times to produce a fairly smooth average of the club count

5) Repeat step 4 a further 9 times to produce a 10-item list of average club counts

6) Summarise the list, extracting stuff like hi-lo points and ± variance from the mid point, etc.

I wouldn't even attempt to calculate the kind of target figure that should result from the averages. If we'd been looking at every hand, the expected average should, in theory, hover somewhere near the 3.25 (13 / 4) mark. However, in this case, we're looking only at hands that contain the 2 of clubs. By definition, that's more likely to be a hand containing more clubs - rather than less (or none). In view of this, I was content to simply compare results from the different methods - and to establish some kind of consensus.

Anyway, enough of this preamble...

----------------------------------

-- modify the properties 'scriptName' and 'currPath' as appropriate
-- 'scriptName' should be the name (excluding extension) of a compiled script (in folder 'currPath') -- each script should return a list of 4 lists (hands)


property scriptName : "Nigel Latest"
property currPath : (path to desktop as Unicode text) & "Bridge folder (Michelle Steiner):random check folder:"


property currFile : alias (currPath & scriptName & ".scpt")
property currScript : load script currFile
property testRepeat : 1000
property seriesCount : 10

to getClubCount(n, e, s, w)
	repeat with currHand in {n, e, s, w}
		if "2C" is in currHand then
			set l to currHand as string
			set text item delimiters to "C"
			set c to (count l's text items) - 1
			set text item delimiters to ""
			return c
		end if
	end repeat
end getClubCount

set text item delimiters to "" -- just in case...
set series to {}
repeat seriesCount times
	set finalCount to 0
	repeat testRepeat times
		set {n, e, s, w} to run currScript
		set finalCount to finalCount + getClubCount(n, e, s, w)
	end repeat
	set end of series to finalCount / testRepeat
end repeat

set lo to item 1 of series
set hi to lo
repeat with v in rest of series
	tell v to if it > hi then
		set hi to contents
	else if it < lo then
		set lo to contents
	end if
end repeat

beep -- wake me when you're done
{scriptName:scriptName, mid:(lo + hi) / 2, lo:lo, hi:hi, var:(hi - lo) / 2, series:series}


--> {scriptName:"Michelle", mid:3.8085, lo:3.724, hi:3.893, var:0.0845, series:{3.874, 3.821, 3.832, 3.843, 3.819, 3.846, 3.724, 3.878, 3.893, 3.807}}

--> {scriptName:"Kai 1", mid:3.799, lo:3.742, hi:3.856, var:0.057, series:{3.783, 3.789, 3.811, 3.853, 3.742, 3.789, 3.848, 3.856, 3.798, 3.818}}

--> {scriptName:"Graff 1", mid:3.8095, lo:3.759, hi:3.86, var:0.0505, series:{3.79, 3.808, 3.852, 3.826, 3.86, 3.833, 3.759, 3.807, 3.849, 3.833}}

--> {scriptName:"Bernard", mid:5.656, lo:5.583, hi:5.729, var:0.073, series:{5.658, 5.625, 5.646, 5.688, 5.712, 5.683, 5.583, 5.6, 5.726, 5.729}}

--> {scriptName:"Nigel Latest", mid:3.8135, lo:3.752, hi:3.875, var:0.0615, series:{3.81, 3.875, 3.849, 3.775, 3.822, 3.795, 3.806, 3.752, 3.838, 3.801}}

----------------------------------

As you'll see from just glancing at the 'mid' properties above, 4 of the 5 scripts return average club counts around the 3.8 mark, while Bernard's original (v. 2) shows a figure closer to 5.7 (enough to justify our reservations - not to mention those of a gambler friend with whom I also discussed the issue).

However, we can be grateful to Bernard for coming up with an individual approach that has a significant speed benefit - and to you, Nigel, for persevering with it and developing a version that appears to be every bit as random as any other method. Thanks. :-)

---
kai

_______________________________________________
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: Graff <email@hidden>
  • Prev by Date: Re: Bridge anyone? [not off topic]
  • Next by Date: Mail rule script flag as junk and move messages
  • Previous by thread: Re: Bridge anyone? [not off topic]
  • Next by thread: Re: Bridge anyone? [not off topic]
  • Index(es):
    • Date
    • Thread