Dice Game: 6-sided die vs 20-sided die

  • Thread starter Master1022
  • Start date
  • Tags
    Dice Game
In summary: Both set of dice average 10.5. If the goal is to get the highest sum, then they are equal.However, would the variance come into consideration if we had to choose one set with which to play the game?Not really. It would only indicate if you lost (won) a roll by a lot or a little.
  • #36
pbuk said:
That loop will execute 1,000,001 times.
I realized that when I counted the total wins for each set and the ties.
 
Physics news on Phys.org
  • #37
pbuk said:
That loop will execute 1,000,001 times.
Complete enumeration of the probability space for the two-way competition is way cheaper than that.

I did a complete enumeration for a 3-way competition and only needed 25,920 cases. My intuition about 3d6 beating 1d20 in a three way match against (5, 5, 5, 6, 21, 21) was faulty.

Scoring: win = 6 points, 2 way tie = 3 points, 3 way draw = 2 points each.
Code:
C:\>test.pl
Player 1 (3d6)           scores 50972 points
Player 2 (1d20)          scores 51632 points
Player 3 (5,5,5,6,21,21) scores 52916 points

Player 1 (3d6)           rolled a mean of 10.5 pips per roll
Player 2 (1d20)          rolled a mean of 10.5 pips per roll
Player 3 (5,5,5,6,21,21) rolled a mean of 10.5 pips per roll

There were 25920 combinations with a total of 155520 points available
The total points awarded were 155520
The code for this is somewhat verbose with extra sanity-checking, but is fairly straightforward.
Perl:
#!/usr/bin/perl

use strict;
use warnings;

# Points = winning points: 6 = clear win, 3 = two-way tie, 2 = three-way tie
my $p1_points = 0;
my $p2_points = 0;
my $p3_points = 0;

# Total = total pips rolled
my $p1_total = 0;
my $p2_total = 0;
my $p3_total = 0;

my $total_combos = 0;

sub scores ( $$$$$ );

foreach my $d1 ( 1, 2, 3, 4, 5, 6 ) {
    foreach my $d2 ( 1, 2, 3, 4, 5, 6 ) {
        foreach my $d3 ( 1, 2, 3, 4, 5, 6 ) {
            foreach my $d4 ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ) {
                foreach my $d5 ( 5, 5, 5, 6, 21, 21 ) {
                    my @result = scores ( $d1, $d2, $d3, $d4, $d5 );
                    $p1_points = $p1_points + $result[0];
                    $p2_points = $p2_points + $result[1];
                    $p3_points = $p3_points + $result[2];
                    $p1_total = $p1_total + $result[3];
                    $p2_total = $p2_total + $result[4];
                    $p3_total = $p3_total + $result[5];
                    $total_combos = $total_combos + 1;
                };
            };
        };
    };
};

if ( $total_combos != 6 * 6 * 6 * 20 * 6 ) {
    print STDERR "Calculated total combinations is ", 6 * 6 * 6 * 20 * 6, " but this code found $total_combos instead\n";
    exit;
};

print "Player 1 (3d6)           scores $p1_points points\n";
print "Player 2 (1d20)          scores $p2_points points\n";
print "Player 3 (5,5,5,6,21,21) scores $p3_points points\n";
print "\n";
print "Player 1 (3d6)           rolled a mean of ", $p1_total/$total_combos, " pips per roll\n";
print "Player 2 (1d20)          rolled a mean of ", $p2_total/$total_combos, " pips per roll\n";
print "Player 3 (5,5,5,6,21,21) rolled a mean of ", $p3_total/$total_combos, " pips per roll\n";
print "\n";
print "There were $total_combos combinations with a total of ", $total_combos * 6, " points available\n";
print "The total points awarded were ", $p1_points + $p2_points + $p3_points, "\n";

sub scores ( $$$$$ ) {
    my $p1d1 = $_[0];
    my $p1d2 = $_[1];
    my $p1d3 = $_[2];
    my $p2d1 = $_[3];
    my $p3d1 = $_[4];

    # Player 1 scores 3d6
    my $p1_score = $p1d1 + $p1d2 + $p1d3;

    # Player 2 scores 1d20
    my $p2_score = $p2d1;

    # Player 3 scores pips equal to 5, 5, 5, 6, 21, 21 on a d6;
    my $p3_score = $p3d1;

    if ( $p1_score > $p2_score && $p1_score > $p3_score ) {
        return ( 6, 0, 0, $p1_score, $p2_score, $p3_score );
    } elsif ( $p2_score > $p1_score && $p2_score > $p3_score ) {
        return ( 0, 6, 0, $p1_score, $p2_score, $p3_score );
    } elsif ( $p3_score > $p1_score && $p3_score > $p2_score ) {
        return ( 0, 0, 6 , $p1_score, $p2_score, $p3_score);
    } elsif ( $p1_score == $p2_score && $p1_score > $p3_score ) {
        return ( 3, 3, 0, $p1_score, $p2_score, $p3_score );
    } elsif ( $p1_score == $p3_score && $p1_score > $p2_score ) {
        return ( 3, 0, 3, $p1_score, $p2_score, $p3_score );
    } elsif ( $p2_score == $p3_score && $p2_score > $p1_score ) {
        return ( 0, 3, 3, $p1_score, $p2_score, $p3_score );
    } elsif ( $p1_score == $p2_score && $p1_score == $p3_score ) {
        return ( 2, 2, 2, $p1_score, $p2_score, $p3_score );
    } else {
        print STDERR "No clear winner, no two way tie, no three way tie. What is going on?\n";
        print STDERR "Player 1: $p1d1 $p1d2 $p1d3 = $p1_score\n";
        print STDERR "Player 2: $p2d1 = $p2_score\n";
        print STDERR "Player 3: $p3d1 = $p3_score\n";
        exit;
    };
};
 
  • Like
Likes FactChecker and PeroK
  • #38
PeroK said:
PS I assigned the third player a fixed score of everything from 1-20 and there is no score that creates an advantage for 3D6.
That cannot be true: 3D6 will always beat 1 or 2 whereas D20 will sometimes lose.
 
  • #39
pbuk said:
That cannot be true: 3D6 will always beat 1 or 2 whereas D20 will sometimes lose.
A third player score of 1 or 2 leaves the contest between 3D6 and D20 level. In terms of outright wins.

PS the third player must score at least 3 to influence the contest.
 
  • Like
Likes pbuk
  • #40
jbriggs444 said:
Complete enumeration of the probability space for the two-way competition is way cheaper than that.
Indeed. For non-linear problems (and you can't get much more non-linear than win/lose) Monte-Carlo methods are not in general worthwhile.

jbriggs444 said:
I did a complete enumeration for a 3-way competition and only needed 25,920 cases. My intuition about 3d6 beating 1d20 in a three way match against (5, 5, 5, 6, 21, 21) was faulty.
I suspect 3d6 may score better against [2, 2, 2, 36] (particularly if you only count clear wins) but I can't be bothered to fire up a Linux instance at the moment to test your Perl script :-p

Your post would have received a like if it hadn't been in Perl :rolleyes:
 
  • #41
pbuk said:
I suspect 3d6 may score better against [2, 2, 2, 36] (particularly if you only count clear wins) but I can't be bothered to fire up a Linux instance at the moment to test your Perl script :-p
You suspect wrongly!
 
  • Like
Likes pbuk
  • #42
PeroK said:
A third player score of 1 or 2 leaves the contest between 3D6 and D20 level. In terms of outright wins.

PS the third player must score at least 3 to influence the contest.
Yes of course, I missed that point.
PeroK said:
You suspect wrongly!
Yes, because of the above, although for this case d20 and 3d6 should be equal because of the same point?

In fact [2, 2, 2, 36] will win 1/4 of the time with d20 and 3d6 each 3/8 (not counting ties)?
 
  • Like
Likes PeroK
  • #43
pbuk said:
Yes of course, I missed that point.

Yes, because of the above, although for this case d20 and 3d6 should be equal because of the same point?

In fact [2, 2, 2, 36] will win 1/4 of the time with d20 and 3d6 each 3/8 (not counting ties)?
If we take player 3 scores from 1 to 20 inclusive and run 100,000 games, the wins for D20 and 3D6 are:

47354 47644
47666 47388
47456 47454
47484 47313
47265 46809
46984 45773
46870 43375
45993 40052
44605 35698
42625 29718
40302 23573
37067 17194
33381 11238
28932 7031
24434 3637
19949 1559
15091 378
9910 0
5084 0
0 0

The low scores leave the contest fairly even, but from 3 onwards 3D6 loses more winning games than D20. You could actually compute the probabilities fairly easily, and prove the matter. I might try that now.
 
  • Like
Likes jbriggs444
  • #44
pbuk said:
Yes of course, I missed that point.

Yes, because of the above, although for this case d20 and 3d6 should be equal because of the same point?

In fact [2, 2, 2, 36] will win 1/4 of the time with d20 and 3d6 each 3/8 (not counting ties)?
Counting ties...
Code:
C:\>test2.pl
Player 1 (3d6)           scores 38880 points
Player 2 (1d20)          scores 38880 points
Player 3 (2,2,2,36)      scores 25920 points

Player 1 (3d6)           rolled a mean of 10.5 pips per roll
Player 2 (1d20)          rolled a mean of 10.5 pips per roll
Player 3 (2,2,2,36)      rolled a mean of 10.5 pips per roll

There were 17280 combinations with a total of 103680 points available
The total points awarded were 103680
 
  • #45
pbuk said:
Your post would have received a like if it hadn't been in Perl :rolleyes:
Real programmers can write Fortran in any language.
 
  • Haha
  • Wow
Likes Master1022, FactChecker and pbuk
  • #46
PeroK said:
You could actually compute the probabilities fairly easily, and prove the matter. I might try that now.
Here are the probabilities:

Player 3 scores 1, D20 wins 0.4750, 3D6 wins 0.4750
Player 3 scores 2, D20 wins 0.4750, 3D6 wins 0.4750
Player 3 scores 3, D20 wins 0.4750, 3D6 wins 0.4745
Player 3 scores 4, D20 wins 0.4748, 3D6 wins 0.4725
Player 3 scores 5, D20 wins 0.4738, 3D6 wins 0.4669
Player 3 scores 6, D20 wins 0.4715, 3D6 wins 0.4553
Player 3 scores 7, D20 wins 0.4669, 3D6 wins 0.4345
Player 3 scores 8, D20 wins 0.4588, 3D6 wins 0.4005
Player 3 scores 9, D20 wins 0.4458, 3D6 wins 0.3542
Player 3 scores 10, D20 wins 0.4271, 3D6 wins 0.2979
Player 3 scores 11, D20 wins 0.4021, 3D6 wins 0.2354
Player 3 scores 12, D20 wins 0.3708, 3D6 wins 0.1718
Player 3 scores 13, D20 wins 0.3338, 3D6 wins 0.1134
Player 3 scores 14, D20 wins 0.2919, 3D6 wins 0.0683
Player 3 scores 15, D20 wins 0.2465, 3D6 wins 0.0359
Player 3 scores 16, D20 wins 0.1988, 3D6 wins 0.0150
Player 3 scores 17, D20 wins 0.1498, 3D6 wins 0.0039
Player 3 scores 18, D20 wins 0.1000, 3D6 wins 0.0000
Player 3 scores 19, D20 wins 0.0500, 3D6 wins 0.0000
Player 3 scores 20, D20 wins 0.0000, 3D6 wins 0.0000
 
  • #47
pbuk said:
Indeed. For non-linear problems (and you can't get much more non-linear than win/lose) Monte-Carlo methods are not in general worthwhile.
I disagree. In fact, those are the situations where theoretical calculations get so tricky that Monte-Carlo methods have a significant advantage. Even if one can get an analytical answer, I would not completely trust it if it did not agree with a Monte-Carlo simulation. I have seen examples in this forum where a very complicated thread eventually (after several days) arrived at the same answer that a 10 minute Monte-Carlo simulation gave.
pbuk said:
I suspect 3d6 may score better against [2, 2, 2, 36] (particularly if you only count clear wins) but I can't be bothered to fire up a Linux instance at the moment to test your Perl script :-p
It is easy to install in Windows. In fact, my experience is that some tools that I used on Windows machines had Perl as part of their installation.
pbuk said:
Your post would have received a like if it hadn't been in Perl :rolleyes:
Boo! I have known people who have the silliest complaints about Perl. Perl has some significant advantages for many scripting applications.
 
  • #48
FactChecker said:
I disagree. In fact, those are the situations where theoretical calculations get so tricky that Monte-Carlo methods have a significant advantage. Even if one can get an analytical answer, I would not completely trust it if it did not agree with a Monte-Carlo simulation. I have seen examples in this forum where a very complicated thread eventually (after several days) arrived at the same answer that a 10 minute Monte-Carlo simulation gave.
Here's a simple example of what I mean. The UK national lottery draw is six unique numbers 1..59 so the chance of a winning ticket is trivially 1 in ## {59 \choose 6} = 45,057,474 ##. How many Monte Carlo trials would you need to reliably get close to the analytic solution?

The problem in the OP is another example: the symmetry argument leads instantly to the correct 50:50 answer, and @jbriggs444's complete enumeration verifies that with only 25,920 evaluations. A Monte Carlo method would require many more trials and would be no easier to program than the complete enumeration.

Even when the solution space is sufficiently large that complete enumeration is not feasible, a divide and conquer approach will often lead to an exact solution.

But yes, when analytic, enumerative and divide and conquer and similar methods fail then Monte Carlo may be all that's left - but unless there is some smoothness to the problem you can't be sure that you haven't over- or under-estimated the frequency of 'unicorns'.
 
  • #49
pbuk said:
Here's a simple example of what I mean. The UK national lottery draw is six unique numbers 1..59 so the chance of a winning ticket is trivially 1 in ## {59 \choose 6} = 45,057,474 ##. How many Monte Carlo trials would you need to reliably get close to the analytic solution?
Yes. Trivial problems are easier to solve analytically. I wish that I lived in a trivial world.

Now, suppose that every even number, n, tentatively picked, was rejected with a probability of 1/n. I can modify the Monte-Carlo simulation in a minute. How easy is the analytic solution? There are a million things that can, and do, occur like that.
 
Last edited:
  • #50
FactChecker said:
Now, suppose that every even number, n, tentatively picked, was rejected with a probability of 1/n. I can modify the Monte-Carlo simulation in a minute. How easy is the analytic solution?
If you think about it, the only way to get any accuracy would be to calculate the probability for each individual ball using a Monte Carlo method (with only 39 outcomes with the minimum frequency (for 2) better than 1 in 78 this should be computable with very high confidence of accuracy) and then use an analytic method to calculate the probability of any given choice. If you just go looking for that needle in the haystack you are still going to need billions of trials to reliably get anywhere near.

FactChecker said:
Yes. Trivial problems are easier to solve analytically. I wish that I lived in a trivial world.
And anlytically solvable problems can be solved analytically and feasibly enumerable problems can be solved by complete enumeration; in neither case are they better solved by Monte Carlo. Your argument is analagous to 'I have to bang in a lot of nails so whenever I need to fix a screw or a pop rivet I reach for the hammer'.
 
  • #51
This thread seems to have gone wildly off-topic discussing a class of methods that are not appropriate for solving the OP's question, which was easily solved in #6 :sorry:
 
  • Love
Likes DaveC426913
  • #52
pbuk said:
Your argument is analagous to 'I have to bang in a lot of nails so whenever I need to fix a screw or a pop rivet I reach for the hammer'.
Be careful. I have dealt with plenty of analytical methods in probability and statistics (although I admit that I am rusty).
 
Last edited:
  • #53
Many thanks to all for writing out the responses. It has been interesting to read about analytical and numerical ways of approaching the problem.
 
  • Like
Likes jbriggs444 and berkeman
  • #54
Thanks @Master1022 !

This sounds like a good time to close this thread before we get busted for gambling without a license.

Thank you all for contributing here.

Closing this thread now.
 
  • Like
Likes Master1022 and berkeman

Similar threads

  • Precalculus Mathematics Homework Help
Replies
2
Views
1K
  • Precalculus Mathematics Homework Help
Replies
11
Views
2K
  • Precalculus Mathematics Homework Help
Replies
34
Views
2K
  • Precalculus Mathematics Homework Help
Replies
7
Views
1K
  • Precalculus Mathematics Homework Help
Replies
10
Views
2K
  • Precalculus Mathematics Homework Help
Replies
8
Views
950
  • Precalculus Mathematics Homework Help
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
Replies
8
Views
2K
  • Precalculus Mathematics Homework Help
Replies
1
Views
1K
  • Precalculus Mathematics Homework Help
Replies
3
Views
1K
Back
Top