Author: Dieter Buerssner
Date: 07:01:37 02/01/01
Go up one level in this thread
On January 31, 2001 at 20:17:17, Bruce Moreland wrote:
>I expressed very forcefully that a 10-0 result was more valid than a 60-40
>result.
Because this misses some context, I am not certain, what you exactly mean by
"more valid".
>I've done some experimental tests and it appears that I'm wrong.
Nevertheless, I also made some simulations. While I have some experience in
doing simulations very carefully, the code I attach is just a hack. I hope, the
attentive eyes of the readers will see the errors. The only verification I
have done, is for some cases, where I easily could calculate the outcome
analytically.
The simulation shall answer the question: What is the distribution of the
results in chess matches between equal opponents. The games shall be independant
(no learning). The distribution does not only depend on the probability of
draws, but also on the probability of white wins and black wins.
(Of course one of the 3 is redundant).
For 30% white wins, 20% black wins and 50% draws, I get for ten games:
D:\USR\DIETER\schachn3>cmatch 10 3 2 5 100000
Result of chess matches between equal opponents
White wins 30.0%, black 20.0% and 50.0% draws
A match of 10 games was simulated by 100000 Monte Carlo tries
result prob. of result this or smaller better than this
5.0 - 5.0 ( 50.0%): 17.569% 17.569% 82.431%
5.5 - 4.5 ( 55.0%): 32.415% 49.984% 50.016%
6.0 - 4.0 ( 60.0%): 24.031% 74.015% 25.985%
6.5 - 3.5 ( 65.0%): 14.835% 88.850% 11.150%
7.0 - 3.0 ( 70.0%): 7.186% 96.036% 3.964%
7.5 - 2.5 ( 75.0%): 2.819% 98.855% 1.145%
8.0 - 2.0 ( 80.0%): 0.904% 99.759% 0.241%
8.5 - 1.5 ( 85.0%): 0.199% 99.958% 0.042%
9.0 - 1.0 ( 90.0%): 0.037% 99.995% 0.005%
9.5 - 0.5 ( 95.0%): 0.005% 100.000% 0.000%
Which means, that a 10-0 is very unprobable. Note, that for 50% winning
probability for both sides, the 10-0 result has a probility of 1/512=0.2%.
In the output, 5.5-4.5 and 4.5-5.5, etc. are put together.
Now, for 100 games, same winning/drawing probabilities:
[...]
result prob. of result this or smaller better than this
50.0 - 50.0 ( 50.0%): 5.689% 5.689% 94.311%
50.5 - 49.5 ( 50.5%): 11.477% 17.166% 82.834%
[...]
59.5 - 40.5 ( 59.5%): 0.302% 99.482% 0.518%
60.0 - 40.0 ( 60.0%): 0.190% 99.672% 0.328%
[...]
So, in about 0.5% of the cases of such a match, a result of 60-40 or better has
to be expected.
Regards,
Dieter
cmatch.c:
Note, that there will probably one bad line wrap close to the end.
For brevity, I included a reasonable, portable and small PRNG, you can easily
substitute this with the most sophisticated PRNG you know. I didn't care about
speed. For function rand_range() some calculations could have been done outside
of the loop.
/* Simulate chess matches between equal opponents. Dieter Buerssner */
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
/* Must fit the used PRNG */
#define MY_RAND_MAX 0xffffffffUL
static unsigned long zseed = 0x12345678UL;
static unsigned long wseed = 0x87654321UL;
/* Combine 2 multiply with carry RNGs suggested by George Marsaglia,
returns pseudo random number between 0 and 2^32-1 inclusive */
static unsigned long mwc1616(void)
{
unsigned long t = zseed;
zseed=30903*(t&0xffff)+(t>>16);
t = wseed;
wseed=18000*(t&0xffff)+(t>>16);
return ((wseed<<16)&0xffffffffUL) + (zseed&0xffff);
}
static void seed_mwc1616(unsigned long s)
{
zseed = s&0xffffffffUL;
wseed = (s*1103515245UL + 12345)&0xffffffffUL;
}
/* Call with 2 < range <= MY_RAND_MAX+1, returns 0 <= r < range. */
static unsigned long rand_range(unsigned long range)
{
unsigned long rmax, r, d;
/* find the largest number rmax <= MY_RAND_MAX, for which
(rmax+1) % range == 0.
All returns from rand() > rmax will be skipped, to guarantee
equal probability for all return values. */
d = (MY_RAND_MAX+1U-range) / range + 1;
rmax = d * range - 1; /* -1 to avoid "overflow to zero" */
do
r = mwc1616(); /* Substitute your favorite PRNG */
while (r > rmax);
return r/d;
}
int main(int argc, char *argv[])
{
unsigned long ww=6, bw=4, draw=5, ntrys=10000, ngames=42;
unsigned long i, j, sum, sum1, r;
int res, result;
static unsigned long results[1001]; /* Upto matches of 1000 games */
if (argc == 6)
{
/* No check for valid commandline parameters done */
ngames = atol(argv[1]);
ww = atol(argv[2]);
bw = atol(argv[3]);
draw = atol(argv[4]);
ntrys = atol(argv[5]);
}
/* Substitute seeding routine of your favorite PRNG */
seed_mwc1616((unsigned long)time(NULL)); /* Practically portable */
sum = ww+bw+draw;
sum1 = ww+bw;
for (i=0; i<ntrys; i++)
{
result = 0;
for (j=0; j<ngames; j++)
{
/* Don't use r=rand()%sum or other inferior methods */
r = rand_range(sum);
res = r < ww ? 1 : r < sum1 ? -1 : 0;
/* switch colors, needed when black and white win are not equal */
if (j&1)
res = -res;
result += res;
}
if (result < 0)
result = -result;
results[result]++;
}
printf("Result of chess matches between equal opponents\n");
printf("White wins %.1f%%, black %.1f%% and %.1f%% draws\n",
(100.0*ww)/sum, (100.0*bw)/sum, (100.0*draw)/sum);
printf("A match of %lu games was simulated by %lu Monte Carlo tries\n\n",
ngames, ntrys);
printf(" result prob. of result this or smaller better than
this\n");
sum = 0;
for (j=0; j<=ngames; j++)
{
if (results[j] == 0)
continue;
sum += results[j];
printf("%5.1f - %-5.1f (%5.1f%%): %14.3f%% %14.3f%% %14.3f%%\n",
0.5*(ngames+j), 0.5*(ngames-j),
100.0*0.5*(ngames+j)/ngames,
(100.0*results[j])/ntrys, (100.0*sum)/ntrys,
(100.0*(ntrys-sum))/ntrys);
}
return 0;
}
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.