I am testing your program against original polyglot and there are discrepancies when promoting.
The test is done on this simple game:
- f4 g5 2. fxg5 Nc6 3. g6 Nf6 4. g7 h6 5. gxh8=Q *
and this position:
r1bqkb1r/ppppppP1/2n2n1p/8/8/8/PPPPP1PP/RNBQKBNR w KQkq - 0 5
After some tests and reviewed your code I propose a mod in this way (or similar) in conversions.rs :
**pub fn to_book_move(mov: Uci) -> u16 {
if let Uci::Normal{from: sq1, to: sq2, promotion} = mov {
let **mut** promotion =
if let Some(p) = promotion {
usize::from(p)
} else {
0
};
**if promotion != 0 {
promotion -= 1;
}**
let i1 = usize::from(sq1);
let i2 = usize::from(sq2);
return (promotion << 12 | i1 << 6 | i2) as u16;
}
unreachable!()
}**
But maybe there is an error in my side, perhaps.
Edit:
in polyglot into file move.h the description of promotions are:
const int MoveNone = 0; // HACK: a1a1 cannot be a legal move
const int MovePromoteKnight = 1 << 12;
const int MovePromoteBishop = 2 << 12;
const int MovePromoteRook = 3 << 12;
const int MovePromoteQueen = 4 << 12;
const int MoveFlags = 7 << 12;
so, in our case, I consider that this will be:
promoteKnight = 1
promoteBishop = 2
promoteRook = 3
promoteQueen = 4
In above mentioned example it throws a five "promotion = 5"
I am testing your program against original polyglot and there are discrepancies when promoting.
The test is done on this simple game:
and this position:
r1bqkb1r/ppppppP1/2n2n1p/8/8/8/PPPPP1PP/RNBQKBNR w KQkq - 0 5
After some tests and reviewed your code I propose a mod in this way (or similar) in conversions.rs :
**pub fn to_book_move(mov: Uci) -> u16 {
}**
But maybe there is an error in my side, perhaps.
Edit:
in polyglot into file move.h the description of promotions are:
const int MoveNone = 0; // HACK: a1a1 cannot be a legal move
const int MovePromoteKnight = 1 << 12;
const int MovePromoteBishop = 2 << 12;
const int MovePromoteRook = 3 << 12;
const int MovePromoteQueen = 4 << 12;
const int MoveFlags = 7 << 12;
so, in our case, I consider that this will be:
promoteKnight = 1
promoteBishop = 2
promoteRook = 3
promoteQueen = 4
In above mentioned example it throws a five "promotion = 5"