void make(struct rmove m, int color) {
int piece = m.fromPiece;
switch (piece) {
case MovedRook: piece = Rook;
break;
case MovedKing: piece = King;
break; // See what I did here?
case King: if (m.flags) {
//...
}
break;
case Pawn: //...
break;
}
board[m.fromSquare] = 0;
board[m.toSquare] = piece | Moved | color;
//...
}
void unmake(struct rmove m, int color) {
int toPiece = m.toPiece != MovedRook
? m.toPiece
: (Rook | Moved);
board[m.toSquare] = toPiece | (color ^ Color);
//...
}
I see what you mean now, but this doesn't help. Previous castling rights cannot be inferred just from the pieces involved in the move, as demonstrated in my first PGN.
Fulvio's way sounds okay, if it had the 1 ep bit.
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.
Maybe you copied your stockfish commits from someone else too?
I will look into that.
void make(struct rmove m, int color) {
int piece = m.fromPiece;
switch (piece) {
case MovedRook: piece = Rook;
break;
case MovedKing: piece = King;
break; // See what I did here?
case King: if (m.flags) {
//...
}
break;
case Pawn: //...
break;
}
board[m.fromSquare] = 0;
board[m.toSquare] = piece | Moved | color;
//...
}
void unmake(struct rmove m, int color) {
int toPiece = m.toPiece != MovedRook
? m.toPiece
: (Rook | Moved);
board[m.toSquare] = toPiece | (color ^ Color);
//...
}
I see what you mean now, but this doesn't help. Previous castling rights cannot be inferred just from the pieces involved in the move, as demonstrated in my first PGN.
void make(struct rmove m, int color) {
int piece = m.fromPiece;
switch (piece) {
case MovedRook: piece = Rook;
break;
case MovedKing: piece = King;
break; // See what I did here?
case King: if (m.flags) {
//...
}
break;
case Pawn: //...
break;
}
board[m.fromSquare] = 0;
board[m.toSquare] = piece | Moved | color;
//...
}
void unmake(struct rmove m, int color) {
int toPiece = m.toPiece != MovedRook
? m.toPiece
: (Rook | Moved);
board[m.toSquare] = toPiece | (color ^ Color);
//...
}
I see what you mean now, but this doesn't help. Previous castling rights cannot be inferred just from the pieces involved in the move, as demonstrated in my first PGN.
int canCastlePseudo(int king, int rook, int color) {
return board[king] == (King | color) && board[rook] == (Rook | color);
}
What are the "Moved" bits in this fen? [fen]rn2k1nr/p3bp2/2pqb1p1/1p2p2p/4P3/NQPP1N2/P2BBPPP/2KR3R b kq - 3 12[/fen]
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.
Maybe you copied your stockfish commits from someone else too?
I will look into that.
Sopel wrote: ↑Fri Dec 03, 2021 2:04 pm
What are the "Moved" bits in this fen? [fen]rn2k1nr/p3bp2/2pqb1p1/1p2p2p/4P3/NQPP1N2/P2BBPPP/2KR3R b kq - 3 12[/fen]
All Moved bits are cleared by default. When a castling right is missing in FEN, the respective rook's Moved bit is set.
Sopel wrote: ↑Fri Dec 03, 2021 2:04 pm
What are the "Moved" bits in this fen? [fen]rn2k1nr/p3bp2/2pqb1p1/1p2p2p/4P3/NQPP1N2/P2BBPPP/2KR3R b kq - 3 12[/fen]
All Moved bits are cleared by default. When a castling right is missing in FEN, the respective rook's Moved bit is set.
So it doesn't work until you encode positions with the "Moved" bit. Which is what what you cannot do in general.
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.
Maybe you copied your stockfish commits from someone else too?
I will look into that.
void make(struct rmove m, int color) {
int piece = m.fromPiece;
switch (piece) {
case MovedRook: piece = Rook;
break;
case MovedKing: piece = King;
break; // See what I did here?
case King: if (m.flags) {
//...
}
break;
case Pawn: //...
break;
}
board[m.fromSquare] = 0;
board[m.toSquare] = piece | Moved | color;
//...
}
void unmake(struct rmove m, int color) {
int toPiece = m.toPiece != MovedRook
? m.toPiece
: (Rook | Moved);
board[m.toSquare] = toPiece | (color ^ Color);
//...
}
I see what you mean now, but this doesn't help. Previous castling rights cannot be inferred just from the pieces involved in the move, as demonstrated in my first PGN.
He is using 2 MovedRook: 1 in the fromPiece and the other in toPiece.
In your example with the move Rh1h8, fromPiece is set to MovedRook and toPiece is set to MovedRook only if black can castle king side.
void make(struct rmove m, int color) {
int piece = m.fromPiece;
switch (piece) {
case MovedRook: piece = Rook;
break;
case MovedKing: piece = King;
break; // See what I did here?
case King: if (m.flags) {
//...
}
break;
case Pawn: //...
break;
}
board[m.fromSquare] = 0;
board[m.toSquare] = piece | Moved | color;
//...
}
void unmake(struct rmove m, int color) {
int toPiece = m.toPiece != MovedRook
? m.toPiece
: (Rook | Moved);
board[m.toSquare] = toPiece | (color ^ Color);
//...
}
I see what you mean now, but this doesn't help. Previous castling rights cannot be inferred just from the pieces involved in the move, as demonstrated in my first PGN.
He is using 2 MovedRook: 1 in the fromPiece and the other in toPiece.
In your example with the move Rh1h8, fromPiece is set to MovedRook and toPiece is set to MovedRook only if black can castle king side.
Yes, I understood that, that's why I'm only posting the other pgn now, because there I don't see a way without encoding more into the position.
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.
Maybe you copied your stockfish commits from someone else too?
I will look into that.