LOS calculation fiddling

Discussion of chess software programming and technical issues.

Moderator: Ras

User avatar
Rebel
Posts: 7303
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

LOS calculation fiddling

Post by Rebel »

Nowadays when I play matches on bullet level I get already get a draw rate of 67%, at LTC the percentage may rise to 80+% and these high draw rates affect the standard LOS calculation. Some LOS.EXE examples -

Code: Select all

Type number of won games  199
Type number of lost games 177
Type number of draw games 1277
In this hypothetical case the standard LOS = 70.6%
When we remove the 1277 draws the LOS = 87.1%
When we also count wins as 2 points the LOS = 94.6%

The question is If that is realistic.

Another variation -
In this hypothetical case the standard LOS = 70.6%
When we also count wins as 2 points the LOS = 77.8%

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

From the command line we add a PGN, los rebel.pgn, we get -

Code: Select all

rebel-16b - rebel-16a (G=678) [W=80] [L=67] [D=531] Score 345.5 - 332.5

LOS without draws = 85.7%
LOS win is double = 93.5%

LOS with draws    = 69.1%
LOS win is double = 76.0%
Source code in next post.
90% of coding is debugging, the other 10% is writing bugs.
User avatar
Rebel
Posts: 7303
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: LOS calculation fiddling

Post by Rebel »

Source code, compile as C++

Code: Select all

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <signal.h>

//////////////////////////////////////////////////////
//                         //                       //
//  WhoIsBest.cpp          //                       //
//                         //                       //
//  Rémi Coulom            //   compile as C++      //
//                         //                       //
//  November, 2002         //                       //
//                         //                       //
//////////////////////////////////////////////////////

float ProbaBinom(int n1, int n0)
{   float *pi = new float[n1 + 2];
    pi[0] = 0;
    for (int i = n1 + 1; --i >= 0;)
    pi[i + 1] = 1;
    for (int j = n0 + 1; --j >= 0;)
    for (int i = 0; i <= n1; i++)
    pi[i + 1] = (pi[i + 1] + pi[i]) * 0.5;
    float Result = pi[n1 + 1];
    delete[] pi;
    return Result*100;
}

main (argc,argv)

        int argc; char *argv[];

{       int won=0; int loss=0; int draw=0; char s[10000],e1[100],e2[100]; FILE *fp; int game=0; int x,l; float f1,f2,f3,f4;
        int WON,LOSS;

        printf("LOS calculator\n\n");

        if (argc==2) goto pgn;

loop:   printf("Type number of won games  "); gets(s); won=atoi(s);  WON=won*2;
        printf("Type number of lost games "); gets(s); loss=atoi(s); LOSS=loss*2;
        printf("Type number of draw games "); gets(s); draw=atoi(s);

        printf("\n\nLOS without draws = %.1f%%",ProbaBinom(won,loss));
        printf("\nLOS win as double = %.1f%%\n\n",ProbaBinom(WON,LOSS));

        f1=won;  f2=draw; f3=f1+(f2/2); won=f3;  WON=won*2;
        f1=loss; f2=draw; f4=f1+(f2/2); loss=f4; LOSS=loss*2;

        printf("LOS with draws    = %.1f%%\n",ProbaBinom(won,loss));
        printf("LOS win as double = %.1f%%\n\n",ProbaBinom(WON,LOSS));

        goto loop;



pgn:    fp=fopen(argv[1],"r"); if (fp==NULL) { printf("File %s not present",argv[1]); getch(); exit(1); }

//      Parse PGN
//      =========

next:   if (feof(fp)) goto finito;
        fgets(s,7777,fp); strlwr(s);

        if (game==0 && strstr(s,"[white ")) { strcpy(e1,s); l=strlen(e1); memmove(e1,e1+8,l); l=strlen(e1); e1[l-3]=0; }
        if (game==1 && strstr(s,"[black ")) { strcpy(e2,s); l=strlen(e2); memmove(e2,e2+8,l); l=strlen(e2); e2[l-3]=0; }

        if (strstr(s,"[white ")) { x=0; game++; if ((game & 255)==0) printf("."); }   // new game

        if (strstr(s,e1) && strstr(s,"[white ")) x=1;
        if (strstr(s,e1) && strstr(s,"[black ")) x=2;

        if (strstr(s,"1-0") && strstr(s,"[result") && x==1) won++;
        if (strstr(s,"0-1") && strstr(s,"[result") && x==2) won++;

        if (strstr(s,"1-0") && strstr(s,"[result") && x==2) loss++;
        if (strstr(s,"0-1") && strstr(s,"[result") && x==1) loss++;

        if (strstr(s,"1/2-1/2") && strstr(s,"[result")) draw++;

        goto next;

finito: fclose(fp);

        f1=won;  f2=draw; f3=f1+(f2/2);
        f1=loss; f2=draw; f4=f1+(f2/2);

        printf("\n\n%s-%s (G=%d) [W=%d] [L=%d] [D=%d] Score %.1f-%.1f\n\n",e1,e2,game,won,loss,draw,f3,f4);

        printf("LOS without draws = %.1f%%\n",ProbaBinom(won,loss));
        printf("LOS win is double = %.1f%%\n\n",ProbaBinom(won*2,loss*2));

        won=f3; loss=f4;
        printf("LOS with draws    = %.1f%%\n",ProbaBinom(won,loss));
        printf("LOS win is double = %.1f%%\n\n",ProbaBinom(won*2,loss*2));

        getch();
}
90% of coding is debugging, the other 10% is writing bugs.