====== Chess - Programming - Database ====== My propriety database format to hold a record of every move. ^Field^Bits^Range^Comment^ |Move From|6|A1=0, H1=7, A8=56, H8=63|File=-'A', rank=-'1'. Castle and Enpassant moves are assumed to be valid moves.| |Move To|6|A1=0, H1=7, A8=56, H8=63|File=-'A', rank=-'1'. Castle and Enpassant moves are assumed to be valid moves.| |Promotion Type|3|000-111|000=unused, 001=Knight, 010=Bishop, 011=Rook, 100=Queen.| |White Elo|11|0-2047|Actual elo of white – 1000.| |Elo Diff|8|0-255|0-255=w, 256-511=b.| |Elo Diff Neg|1|0-1|0=positive, 1=negative.| |%WDL|9|0-511|0-99=Percentage Win, 100-199=Percentage Draw, 200-299=Percentage Loss. From White Perspective. Unused Values 300-511.| |Count|12|0-4095|Rolling.| |Weight|8|0-255|A 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 = - 'A', row = - '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. ^Values^Description^ |0-99|Percent of Wins.| |100-199|Percent of Draws.| |200-299|Percent of Losses.| |300-511|Unused 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). ---- [[Chess:Programming:Database|Database]]