Wisdom is knowing how

   little we know -- Socrates

About Company

Started in 1980, retired in 2004 REBEL was baptized into ProDeo, latin for gratis according to Dutch tradition.

Other Information

    Quick downloads

 

 

    Quick links

 

 

    Technical

 

 

    Misc

 

 

    Personal links

 

 

 

A Material Base for everybody

 

A material imbalance table as first introduced by Vasik Rajlich in Rybka 1.0 beta now made easy to implement using Protools menu F10. It's data structure first:

 

static int mat_bonus    [9][9] [3][3] [3][3] [3][3] [2][2];   // wp|bp|wn|bn|wb|bb|wr|br|wq|bq
static int mat_pos        [9][9] [3][3] [3][3] [3][3] [2][2];
static int mat_perc       [9][9] [3][3] [3][3] [3][3] [2][2];

 

Step-1

 

  1. Copy a good quality and large PGN database into the PGN subfolder.
     
  2. Select the PGN with Load PGN and press Make Matbase.
     
  3. OPTIONS:  
       

          Bishop color       -   Irrelevant for the moment.

 

          Score Factor      -   Only relevant if you want to use the precalculated scores.

 

          Minimum ELO     -   Extremely important. Consider only games where both players have a
                                       given minimum elo rating.

 

The utility will create the following *.mat output files with the above listed data structure

 

bonus.mat

Contains the precalculated bonus for each cell multiplied with the Score Factor percentage.

pos.mat Contains the number of positions for each cell.
perc.mat Contains the winning percentage for each cell.

 

 

Step-2

 

Insert the 3 files at program start into the 3 tables. The code:

 

 int wp,wn,wb,wr,wq,bp,bn,bb,br,bq;  

 

     fp1 = fopen("bonus.mat","rb");
     fp2 = fopen("pos.mat","rb");
     fp3 = fopen("perc.mat","rb");

 

        for (wp=0; wp<=8; wp++)
        for (bp=0; bp<=8; bp++)
        for (wn=0; wn<=2; wn++)
        for (bn=0; bn<=2; bn++)
        for (wb=0; wb<=2; wb++)
        for (bb=0; bb<=2; bb++)
        for (wr=0; wr<=2; wr++)
        for (br=0; br<=2; br++)
        for (wq=0; wq<=1; wq++)
        for (bq=0; bq<=1; bq++)

         { fread(&mat_bonus [wp][bp] [wn][bn] [wb][bb] [wr][br] [wq][bq],4,1,fp1);
           fread(&mat_pos     [wp][bp] [wn][bn] [wb][bb] [wr][br] [wq][bq],4,1,fp2);
           fread(&mat_perc    [wp][bp] [wn][bn] [wb][bb] [wr][br] [wq][bq],4,1,fp3);   }

 

 fclose(fp1);  fclose(fp2);  fclose(fp3); 

 

 

 

Step-3

 

Then finally in EVAL add the below code:

 

void  Material_Imbalance()  

 

{      int wp,wn,wb,wr,wq,bp,bn,bb,br,bq;

 

       wp = number_of_white_pawns;
       wn = number_of_white_knights;           // max=2
       wb = number_of_white_bishops;           // max=2
       wr = number_of_white_rooks;              // max=2
       wq = number_of_white_queens;           // max=1
 

       bp = number_of_black_pawns;

       bn = number_of_black_knights;            // max=2
       bb = number_of_black_bishops;            // max=2
       br = number_of_black_rooks;               // max=2
       bq = number_of_black_queens;            // max=1

 

      /////////////////////////////////////////////////////////////////////////////////////////////////

      ///    Get the precalculated bonus from the cell and add it to your EVAL variable    ///

      ///          NOTE: the precalculated bonus is from the white point of view.              ///

      /////////////////////////////////////////////////////////////////////////////////////////////////

 

     your_eval_score += mat_bonus [wp][bp] [wn][bn] [wb][bb] [wr][br] [wq][bq])

 

     return;                    // That's it !

 

   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

   ///   Another and more preferable way is to calculate the bonus yourself                                   ///

   ///         via the number of positions in the cell and its percentage.                                           ///

   ///   For instance multiply your EVAL with the percentage of the cell:                                        ///

   ///   In case your eval score is 100 and the cell reports a 85% score the new score will be 135   ///

   ///   In case your eval score is 100 and the cell reports a 20% score the new score will be 70    ///   

   /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

     if  (mat_pos [wp][bp] [wn][bn] [wb][bb] [wr][br] [wq][bq] < 10) return;   // too few positions !

 

     x=mat_perc [wp][bp] [wn][bn] [wb][bb] [wr][br] [wq][bq];

 

     your_eval_score += (your_eval_score * (x-50))/100;

 

     return;

}

 

 

Final comments

 

A big advantage of the system is that you can replace the material base any time by selecting a different PGN.

 

Using a comp-comp PGN is preferable, just collect games of the current top-engines and you are pretty safe. The quality of the Material Base is in the quality of the PGN.

 

Copyright ® 2012  Ed Schröder