User Tools

Site Tools


chess:programming:database

Chess - Programming - Database

My propriety database format to hold a record of every move.

FieldBitsRangeComment
Move From6A1=0, H1=7, A8=56, H8=63File=<file>-'A', rank=<rank>-'1'. Castle and Enpassant moves are assumed to be valid moves.
Move To6A1=0, H1=7, A8=56, H8=63File=<file>-'A', rank=<rank>-'1'. Castle and Enpassant moves are assumed to be valid moves.
Promotion Type3000-111000=unused, 001=Knight, 010=Bishop, 011=Rook, 100=Queen.
White Elo110-2047Actual elo of white – 1000.
Elo Diff80-2550-255=w, 256-511=b.
Elo Diff Neg10-10=positive, 1=negative.
%WDL90-5110-99=Percentage Win, 100-199=Percentage Draw, 200-299=Percentage Loss. From White Perspective. Unused Values 300-511.
Count120-4095Rolling.
Weight80-255A measure for the likelihood of a win after that particular move has been made. 0-127=w, 128-255=b. Default is to use ELO changes to calculate this.

NOTE: A total of 64-bits.


Moves

Moves are stored in format:

  • A1 = 0, H1 = 7, A8 = 56, H8 = 63.
  • File = <file> - 'A', row = <rank> - '1'.
  • Castle and Enpassant moves are assumed to be valid moves.

Promotion Type

Assumed that the associated moves are for a pawn and this promotion is valid.


White Elo

The average of the ELO rating for the White player - 1000.


Elo Diff & Elo Diff Neg

Used to calculate the ELO rating of the Black Player.

Either add, or subtract this figure from the White Elo.

  • If Elo Diff Neg is set, then subtract, otherwise add.

%WDL

The percentage of Wins, Draws and Losses for the White Player.

  • Obviously, the Black Player would be the opposite.
ValuesDescription
0-99Percent of Wins.
100-199Percent of Draws.
200-299Percent of Losses.
300-511Unused Values.

Count

The number of games having played this move.

A maximum of 4096 games is recorded.

The other fields using this figure for their calculations, such as %WDL, should be recalculated / updated even though this maximum number of 4096 is reached.


Weight

A measure for the likelihood of a win after that particular move has been made.

Range is 0-255.

Default is to use ELO changes per this formula:

  white_probability = (1.0 / (1.0 + std::pow(10.0, ((rating1 - rating2) / 400.0)) ) );
  black_probability = 1 - white_probability;

  if (rating1 > rating2)
  {
    result=-black_probability/20;
  }
  else
  if (rating1 < rating2)
  {
    res=white_probability/20;
  }

NOTE: A bespoke formula could be used to update this weighting.

  • Instead of using the k factor/value of 400 that the original formula uses, this is changed to be 100 + ((score difference) * 2).
  • So the max k factor would be 140 (20-0 is the biggest win, multiply by 2, add to 100).

Database

chess/programming/database.txt · Last modified: 2022/01/11 10:50 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki