M README.md => README.md +1 -0
@@ 385,6 385,7 @@ chessboard displaying code in [PolyGlot](http://hgm.nubati.net/book_format.html)
## ?
+- fix `--win,draw,loss-factor` calculation for make
- Add 50-moves detection and 3-position repetition detection to the play
subcommand.
- upgrade `once_cell` crate from `1.18` to `1.19`.
M src/main.rs => src/main.rs +3 -3
@@ 6767,15 6767,15 @@ fn polyglot_make(
// rescaling
if !uniform {
- moves.sort_unstable_by_key(|mov| std::cmp::Reverse(mov.weight()));
+ moves.sort_unstable_by_key(|mov| std::cmp::Reverse(mov.weight(&wdl_factor)));
}
- let max_weight = if uniform { 1 } else { moves[0].weight() };
+ let max_weight = if uniform { 1 } else { moves[0].weight(&wdl_factor) };
// theoretically we prefer 0xffff but we stay on the safe side
let scale: f64 = 0xfff0 as f64 / max_weight as f64;
/* Enter the edited entries */
for game_entry in &mut *moves {
- let weight = if uniform { 1 } else { game_entry.weight() };
+ let weight = if uniform { 1 } else { game_entry.weight(&wdl_factor) };
if !preserve_null && weight == 0 {
continue;
M src/pgnbook.rs => src/pgnbook.rs +5 -2
@@ 72,11 72,14 @@ impl GameEntry {
pub const SERIALIZED_SIZE: usize = mem::size_of::<u16>() + 3 * mem::size_of::<u64>();
/// Calculates the weight of a move, considering both won and drawn games.
- pub fn weight(self) -> u64 {
+ pub fn weight(&self, wdl_factor: &(f64, f64, f64)) -> u64 {
let draws: u64 = self
.ngames
.saturating_sub(self.nwon.saturating_add(self.nlost));
- 2u64.saturating_mul(self.nwon).saturating_add(draws)
+ let w = (self.nwon as f64 * wdl_factor.0) as u64;
+ let d = (draws as f64 * wdl_factor.1) as u64;
+ let l = (self.nlost as f64 * wdl_factor.2) as u64;
+ w.saturating_add(d).saturating_add(l)
}
/// Serializes a `GameEntry` instance into a binary format using a writer.