Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Combinatorial math game played by Thai bargirls

4 views
Skip to first unread message

Peter Webb

unread,
Nov 14, 2009, 8:51:41 AM11/14/09
to
Having just returned from Phuket in Thailand, I can report the bargirls
there play various games with customers to keep them drinking.

The most common involve hand eye co-ordination - stacking wooden blocks,
hammering in nails with icepicks.

At least two are clearly mathematical. One is the classic connect four game,
which has been extensively modeled mathematically and is quite a deep game.

The other game is a solitaire. It has a ridiculously easy strategy. Its
called "Jackpot". There is a board with 9 wooden pegs, numbered 1..9. You
throw two dice. You can turnover a single peg which matches either one of
the dice or the sum of the two dice. Eg throwing 1,2 will let you turn over
1,2 or 3, but throwing 5,6 will only let you turn over 5 or 6 as there is no
11th peg. If you cannot turn over a peg you lose, if you turn over all 9 you
win.

I was able to guess the best strategy and verify it on the back of the bill
for my beer before playing it myself. That was itself sufficiently boring
that I went back you my hotel room, fired up my laptop and wrote a program
to play it a million times to see what percentage of games are won using the
optimum strategy. Which was probably a healthier thing to be doing in my
hotel room than the bargirl who showed me the game intended.

OK, what's the best strategy?

How often do you win when employing that strategy?


Mensanator

unread,
Nov 14, 2009, 10:45:24 AM11/14/09
to
On Nov 14, 7:51 am, "Peter Webb"

<webbfam...@DIESPAMDIEoptusnet.com.au> wrote:
> Having just returned from Phuket in Thailand, I can report the bargirls
> there play various games with customers to keep them drinking.
>

You're playing bar games in a town called "Phuket"?

Sounds like you're missing the point of something
or other.

James Dow Allen

unread,
Nov 14, 2009, 12:25:29 PM11/14/09
to
"Peter Webb" <webbf...@DIESPAMDIEoptusnet.com.au> might have writ, in
news:4afeb5ef$0$5419$afc3...@news.optusnet.com.au:

> Having just returned from Phuket in Thailand, I can report the
> bargirls there play various games with customers to keep them
> drinking.
>

> At least two are clearly mathematical. One is the classic connect four
> game, which has been extensively modeled mathematically and is quite a
> deep game.

Elsewhere I wrote:
> ... Finally, I should thank the anonymous bartender in Banglamung who
> used Diagram 1 twenty-five years ago to make me aware that Connect
> Four is not an easy game.

Peter wrote:
> The other game is a solitaire. It has a ridiculously easy strategy.
> Its called "Jackpot". There is a board with 9 wooden pegs, numbered
> 1..9. You throw two dice. You can turnover a single peg which matches
> either one of the dice or the sum of the two dice. Eg throwing 1,2
> will let you turn over 1,2 or 3, but throwing 5,6 will only let you
> turn over 5 or 6 as there is no 11th peg. If you cannot turn over a
> peg you lose, if you turn over all 9 you win.
>

> OK, what's the best strategy?

I've also solved this game! (I don't know whether it would be faster
for me to hunt through directories or redo from scratch.)

You imply the optimal strategy is trivial. I suspect I know what
you intend; however IIRC there are situations where the trivial
strategy is slightly sub-optimal.

(BTW, although *I* would never take advantage of a bargirl, it's
quite easy to win this game. Just turn over the 9 on your second
roll regardless of dice, then 8, etc. She's paying no attention.)


James Dow Allen

Chip Eastham

unread,
Nov 14, 2009, 3:05:38 PM11/14/09
to
On Nov 14, 12:25 pm, James Dow Allen <gm...@jamesdowallen.nospam>
wrote:
> "Peter Webb" <webbfam...@DIESPAMDIEoptusnet.com.au> might have writ, innews:4afeb5ef$0$5419$afc3...@news.optusnet.com.au:

For each position, starting from single pegs
and recursing back to all nine pegs, we can
compute the probability of success (clearing
all pegs) assuming that with each throw the
choice of action is dictated by maximizing
the resulting probability of success.

Pr(winning|pegs={1}) = 11/36
Pr(winning|pegs={2}) = 1/3
Pr(winning|pegs={3}) = 13/36
Pr(winning|pegs={4}) = 7/18
Pr(winning|pegs={5}) = 5/12
Pr(winning|pegs={6}) = 4/9
Pr(winning|pegs={7}) = 1/6
Pr(winning|pegs={8}) = 5/36
Pr(winning|pegs={9}) = 1/9

regards, chip

James Dow Allen

unread,
Nov 14, 2009, 3:38:13 PM11/14/09
to
On Nov 15, 3:05 am, Chip Eastham <hardm...@gmail.com> wrote:
> On Nov 14, 12:25 pm, James Dow Allen <gm...@jamesdowallen.nospam>
> wrote:
> > (BTW, although *I* would never take advantage of a bargirl, it's
> > quite easy to win this game.  Just turn over the 9 on your second
> > roll regardless of dice, then 8, etc.  She's paying no attention.)
>
> For each position, starting from single pegs
> and recursing back to all nine pegs, we can
> compute the probability of success

Well, yes. The idea is to get one's lazy self off the
bar stool and actually do it. I recoded from scratch just
now and posted the C code at
http://james.fabpedigree.com/phukdice.c

Obpuzzle: *Without* running the posted program, what is the
position where the almost-optimal trivial strategy loses the
most compared with the optimal strategy?

James Dow Allen

Peter Webb

unread,
Nov 15, 2009, 3:36:00 AM11/15/09
to

"James Dow Allen" <jdall...@yahoo.com> wrote in message
news:3d55be18-a86a-4b03...@m7g2000prd.googlegroups.com...

James Dow Allen

____________________________________

The almost-optimal trivial strategy is to take the "least likely" option. As
the probabilities in increasing order are 9,8,7,1,2,3,4,5,6 the summary
strategy is:

1. If sum>6 and not taken then take the sum.
2. Otherwise take the lowest not taken of throw1, throw2 and sum.

(Really just a greedy strategy).

My Monte-Carlo of this gives the chances of winning as somewhere between
0.079 and 0.081. As I can't compile your C program, do you get much the same
answer?

I couldn't extract from your C program exactly what your better strategy is.
Could you explain it, and provide the counter-example you alluded to?

PS I called my C# program "Jackpot". I prefer your name of "phuket.c", seems
to capture the essence of the game environment better ....!

James Dow Allen

unread,
Nov 15, 2009, 4:22:44 AM11/15/09
to
On Nov 15, 3:36 pm, "Peter Webb"
<webbfam...@DIESPAMDIEoptusnet.com.au> wrote:

Hi, Peter. The attribution prefixes (">") got omitted when you
replied
to my post. In other words, the "Well, yes ...." here looks like it
was
written by Peter, but was actually wrtiten by me.

> "James Dow Allen" <jdallen2...@yahoo.com> wrote in messagenews:
> 3d55be18-a86a-4b03...@m7g2000prd.googlegroups.com...


> Well, yes.  The idea is to get one's lazy self off the
> bar stool and actually do it.  I recoded from scratch just
> now and posted the C code at
>    http://james.fabpedigree.com/phukdice.c
>
> Obpuzzle: *Without* running the posted program, what is the
> position where the almost-optimal trivial strategy loses the
> most compared with the optimal strategy?

SPOILER Warning. I give the answer to this "Obpuuzle" below.

>
> James Dow Allen

Back to Peter:


> The almost-optimal trivial strategy is to take the "least likely" option. As

> the probabilities in increasing order are 9,8,7,1,2,3,4,5,6 ...


>
> My Monte-Carlo of this gives the chances of winning as somewhere between
> 0.079 and 0.081. As I can't compile your C program, do you get much the same
> answer?

You speak of a C# program, below. May I ask *why* you can't compile
my C program?

> I couldn't extract from your C program exactly what your better strategy is.
> Could you explain it, and provide the counter-example you alluded to?

If you *run* the program, it will display *all* the exceptions to the
almost-optimal strategy, and, as its final line, give the net
probability
of success from the starting position. Changing a "0" to "1" near
very
beginning of program and recompiling will give you the probability
with the
almost-optimal strategy. Test your compilation environment by
confirming
you get the same answers as I get:
Win with optimal strategy = 0.079987
Win with almost-opt strategy = 0.079855

As seen, you're not giving up much to the bargirls by going with
only the "almost optimal" strategy! ... And it may seem like
perfectionistic nitpicking to complain that your strategy is
suboptimal. Don't know what the stakes you were playing for were;
IIRC from my misspent youth the main topic of negotiation would
be "Who brings the party hats?"

> PS I called my C# program "Jackpot". I prefer your name of "phuket.c", seems
> to capture the essence of the game environment better ....!

> ...


> Could you explain it, and provide the counter-example you alluded to?

The list of exceptions printed by phukdice.c include cases where you
prefer
any of 2, 3, 4, 5, or 6 to a smaller number.

The exception where you lose the most by playing "almost-optimal" is
in this problem:
> How do you play with a board of
> 2 4 5 6 8
> when rolling (1,4) or (4,5) ?
>
> The wrong play yields 10.88% win rate instead of 11.56%.
> Demonstration: If the *next* shake is 1-3 or 3-4, you'll
> be happy if you kept 4. (If 5-5 you'll be happy to keep
> 5. Any other shake is, I think, almost a toss-up.)

James Dow Allen

Peter Webb

unread,
Nov 15, 2009, 8:41:28 AM11/15/09
to

> The exception where you lose the most by playing "almost-optimal" is
> in this problem:
> How do you play with a board of
> 2 4 5 6 8
> when rolling (1,4) or (4,5) ?
>
> The wrong play yields 10.88% win rate instead of 11.56%.

OK, I get it. On 24568 with a throw of 1,4 my algorithm takes the 5. I
calculate the chances of winning with 2468 being 3.8% but with 2568 I get a
win rate of 4.0%.

I can also see why; the assumption was that the individual pegs were
independent, but they are not; having for example only 235 left double
counts throwing a 2,3 (amongst others).

What I don't get is how you know the exact exceptions, or even how you
worked out they existed. Was this by exhaustive Monte-Carlo searching, or
did you use a counting argument ...

James Dow Allen

unread,
Nov 15, 2009, 9:35:37 AM11/15/09
to
On Nov 15, 8:41 pm, "Peter Webb"

<webbfam...@DIESPAMDIEoptusnet.com.au> wrote:
> OK, I get it. On 24568 with a throw of 1,4 my algorithm takes the 5.

I think you meant "takes the 4".

> What I don't get is how you know the exact exceptions,...

Chip Eastham already outlined the solution method up-thread.
The software automatically finds all best strategies by brute
force. And, instead of "simulating a million games" we need
only consider 512*21*3 situations where 512 is the number of
board settings, 21 the number of dice rolls, 3 the maximum
number of legal plays at any turn.

My phukdice.c isn't well commented but *does* do the work.
Why couldn't you compile it?

James

Peter Webb

unread,
Nov 15, 2009, 6:54:46 PM11/15/09
to

"James Dow Allen" <jdall...@yahoo.com> wrote in message
news:30eb96d0-3faa-464a...@u25g2000prh.googlegroups.com...

On Nov 15, 8:41 pm, "Peter Webb"
<webbfam...@DIESPAMDIEoptusnet.com.au> wrote:
> OK, I get it. On 24568 with a throw of 1,4 my algorithm takes the 5.

I think you meant "takes the 4".

> What I don't get is how you know the exact exceptions,...

Chip Eastham already outlined the solution method up-thread.

____________________________
Yeah, sorry, I missed his explanation, worked it out for myself overnight
(or rather just woke up this morning knowing the algorithm, strange how that
happens).

I might have a little play with generalising this. Increasing the number of
pegs won't much change the game much, but increasing the number of dice may
make these exceptions to the simple strategy more significant and add to the
gameplay.

Then of course I will have to buy another ticket to Phuket to do some field
testing.

Thanks all for the insights ...

Prai Jei

unread,
Dec 6, 2009, 1:56:48 PM12/6/09
to
Peter Webb set the following eddies spiralling through the space-time
continuum:

> The other game is a solitaire. It has a ridiculously easy strategy. Its
> called "Jackpot". There is a board with 9 wooden pegs, numbered 1..9. You
> throw two dice. You can turnover a single peg which matches either one of
> the dice or the sum of the two dice. Eg throwing 1,2 will let you turn
> over 1,2 or 3, but throwing 5,6 will only let you turn over 5 or 6 as
> there is no 11th peg. If you cannot turn over a peg you lose, if you turn
> over all 9 you win.

I know that one as "close the box" but in the version I know, you are not
restricted to the numbers on the individual dice e.g. if you throw 5+6 then
you can turn over *any* combination of digits that totals 11 e.g. 1,2,3,5.

My strategy is:
(a) Keep 2 up as long as possible, against the inevitable double-1.
(b) Subject to (a), take the largest possible number plus any smaller
digits.
(c) Split even numbers between even digits, e.g. for 10, take 6+4 rather
than 7+3. (Rationale: odd digits can make both odd and even sums, even
digits can only make even sums so are less useful.)
--
ξ:) Proud to be curly

Interchange the alphabetic letter groups to reply

James Dow Allen

unread,
Dec 8, 2009, 8:05:31 AM12/8/09
to
On Dec 7, 1:56 am, Prai Jei <pvstownsend.zyx....@ntlworld.com> wrote:
> I know that one as "close the box" but in the version I know, you are not
> restricted to the numbers on the individual dice e.g. if you throw 5+6 then
> you can turn over *any* combination of digits that totals 11 e.g. 1,2,3,5.

How does the game end? If you're left with just the 6,
do you then need to roll exactly 6 (3,3 or 2,4 or 1,5) to win?

> My strategy is:
>         (a) Keep 2 up as long as possible, against the inevitable double-1.
>         (b) Subject to (a), take the largest possible number plus any smaller
> digits.
>         (c) Split even numbers between even digits, e.g. for 10, take 6+4 rather
> than 7+3. (Rationale: odd digits can make both odd and even sums, even
> digits can only make even sums so are less useful.)

It might be better to consider what you're left with, rather than what
you take. But as you imply, it's bad to be left with just even
numbers.

Another game where the fact that even numbers never sum to an odd
plays a role is in backgammon bearing off. Avoid ending up with
all your men on the 5-, 3- and 1-points as even numbers will then have
little value.

> ξ:) Proud to be curly

What is that curli-cue and how did you enter it? Is it an ISO-xxx
code?
I see it now, with IE-G.Groups, but which "Encoding: works generally?

James

Prai Jei

unread,
Dec 10, 2009, 4:08:41 PM12/10/09
to
James Dow Allen set the following eddies spiralling through the space-time
continuum:

> On Dec 7, 1:56 am, Prai Jei <pvstownsend.zyx....@ntlworld.com> wrote:


>> I know that one as "close the box" but in the version I know, you are not
>> restricted to the numbers on the individual dice e.g. if you throw 5+6
>> then you can turn over *any* combination of digits that totals 11 e.g.
>> 1,2,3,5.
>
> How does the game end? If you're left with just the 6,
> do you then need to roll exactly 6 (3,3 or 2,4 or 1,5) to win?

Certainly the exact throw is needed to clear all the digits. Throwing excess
(e.g. 8 when you have just 3 and 4 left) is no good and does not count as a
win.

When the total of the remaining digits is 6 or less you only throw one die.
If you have just the 6 left and you throw anything but 6 you're f'd. If
you've got 1,2,3 left then you can't go bust on this throw.

In some versions of the rules, your penalty score if you fail to complete
all the digits, is to run the remaining digits together as a huge number so
you might have a penalty scores of 356,

That is why leaving the 2 up is so critical. If you begin with double-1 all
you can do is take the 2. If you then throw double-1 again you bomb out
with a penalty score of 13456789.

> Another game where the fact that even numbers never sum to an odd
> plays a role is in backgammon bearing off. Avoid ending up with
> all your men on the 5-, 3- and 1-points as even numbers will then have
> little value.

I'll bear that in mind.

>> ξ:) Proud to be curly
>
> What is that curli-cue and how did you enter it? Is it an ISO-xxx
> code?

It's a lower-case Greek letter xi. In KCharSelect you go to Table 3 and all
the Greek letters are there for the clipboarding. In Unicode its character
958 (hex 3BE).

> I see it now, with IE-G.Groups, but which "Encoding: works generally?

Probably Unicode. Mostly it comes out correct because the newsreader can
tell that that is the encoding.
--

ξ:) Proud to be curly

Interchange the alphabetic letter groups to reply

Prai Jei

unread,
Dec 10, 2009, 4:23:50 PM12/10/09
to
James Dow Allen set the following eddies spiralling through the space-time
continuum:

>> ξ:) Proud to be curly


>
> What is that curli-cue and how did you enter it? Is it an ISO-xxx
> code?

Just curious: are you curly too?
--

ξ:) Proud to be curly

Interchange the alphabetic letter groups to reply

James Dow Allen

unread,
Dec 11, 2009, 4:25:13 AM12/11/09
to
On Dec 11, 4:23 am, Prai Jei <pvstownsend.zyx....@ntlworld.com> wrote:
> James Dow Allen set the following eddies spiralling through the space-time
> continuum:
> > [snip]

> In some versions of the rules, your penalty score
> ... is to run the remaining digits together as a huge number
> so you might have a penalty scores of 356 ... or even 13456789
> That is why leaving the 2 up is so critical...

I've got the software scaffold and can add additional rules
and scorings easily. First let's agree on the sets of
rules. Since S = 13456789 will dominate strategy if S
is in dollars, perhaps one should take log(S) as the dollar penalty.

> >> ξ:) Proud to be curly

I can cut-and-paste the xi ( ξ ) here in GGroups, or perhaps use
> &xi; for html
but still don't know which keys to push in vi.

Prei Jei wrote:
> Just curious: are you curly too?

> ξ:) Proud to be curly

ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ ξ
I've oft-noted curly hair ....

Also, I am prideful ... among other deadly sins.

James

0 new messages