Sopel wrote: ↑Fri Dec 03, 2021 2:46 pm
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.
Assuming that the last move was long castle, I guess that if the previous position was:
rn2k1nr/p3bp2/2pqb1p1/1p2p2p/4P3/NQPP1N2/P2BBPPP/R3K2R w KQkq - 0 12
he sets fromPiece to MovedKing and toPiece to MovedRook
while if it was:
rn2k1nr/p3bp2/2pqb1p1/1p2p2p/4P3/NQPP1N2/P2BBPPP/R3K2R w Qkq - 0 12
he sets fromPiece to MovedKing and toPiece to None
I'm not saying it's an encoding that I like.
It seems overly complicated for no reason.
For example I imagine that to recognize the promotion moves you need something like fromPiece == PAWN && rank(toSquare) == rank_relative(color, RANK8).
But it probably works.
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.
Sorry, I lost you here. There is a relation from the 4 castling rights to the 6 Moved bits, and a function from the bits to the rights, which is what counts.
Fulvio wrote: ↑Fri Dec 03, 2021 3:26 pm
I'm not saying it's an encoding that I like.
It seems overly complicated for no reason.
For example I imagine that to recognize the promotion moves you need something like fromPiece == PAWN && rank(toSquare) == rank_relative(color, RANK8).
But it probably works.
I don't see how it's complicated. Yes, you need additional logic for promotion, but it could be simply fromPiece == PAWN && (rank == 0 || rank == 7)
Fulvio wrote: ↑Fri Dec 03, 2021 3:26 pm
But it probably works.
Or maybe it does not work?
How do you encode the previous castling rights when the king moves?
With the position [fen]4k3/8/8/8/8/8/4K3/R6R b - - 0 12[/fen]
the last move was Ke2, how do you know if the previous position was:
4k3/8/8/8/8/8/8/R3K2R w - - 0 12
or
4k3/8/8/8/8/8/8/R3K2R w K - 0 12
or
4k3/8/8/8/8/8/8/R3K2R w KQ - 0 12
Fulvio wrote: ↑Fri Dec 03, 2021 3:26 pm
But it probably works.
Or maybe it does not work?
How do you encode the previous castling rights when the king moves?
With the position [fen]4k3/8/8/8/8/8/4K3/R6R b - - 0 12[/fen]
the last move was Ke2, how do you know if the previous position was:
4k3/8/8/8/8/8/8/R3K2R w - - 0 12
or
4k3/8/8/8/8/8/8/R3K2R w K - 0 12
or
4k3/8/8/8/8/8/8/R3K2R w KQ - 0 12
Fulvio wrote: ↑Fri Dec 03, 2021 3:26 pm
But it probably works.
Or maybe it does not work?
How do you encode the previous castling rights when the king moves?
With the position [fen]4k3/8/8/8/8/8/4K3/R6R b - - 0 12[/fen]
the last move was Ke2, how do you know if the previous position was:
4k3/8/8/8/8/8/8/R3K2R w - - 0 12
or
4k3/8/8/8/8/8/8/R3K2R w K - 0 12
or
4k3/8/8/8/8/8/8/R3K2R w KQ - 0 12
void unmake(struct rmove m, int color) {
int toPiece = m.toPiece != MovedRook
? m.toPiece
: (Rook | Moved);
board[m.toSquare] = toPiece | (color ^ Color);
int piece = m.fromPiece;
switch (piece) {
case MovedRook: piece = Rook | Moved;
break;
case MovedKing: piece = King | Moved;
break;
case King: if (m.flags & CastleQueen) {
//...
} else if (m.flags & CastleKing) {
//...
}
break;
case Pawn: //...
break;
}
//...
board[m.fromSquare] = piece | color;
}
I still think it does not work.
In all cases flags, isEnPassant, enPassantFile would be 0.
toPieces would also always be 0 (None) and cannot be used because in E2 maybe there was a piece.
fromSquare would always be E1 and toSquare E2.
So you are left with only fromPiece which you can use for 2 cases:
full castle rights KQ -> MovedKing
no castle rights -- -> King
but there is no way to encode the other 2 cases:
can only castle queen side Q
can only castle king side K
It would work changing MovedKing to Castle and merging isEnpassanto into flags.
The new multipurpose 3-bits flags would have different meaning based on fromPiece:
fromPiece == Castle -> used for castle moves, 2 bits stores the previous castling rights and 1 bits store the direction (queen side or king side)
fromPiece == King -> 2 bits stores the previous castling rights
fromPiece == PAWN -> 0: normal move
1: enpassant move
2,3,4,5: promo queen/rook/bishop/knight
leanchess wrote: ↑Fri Dec 03, 2021 7:11 pmDear Moderators
There is a button with an exclamation mark at every post which you can use to contact the moderation. That's there because you can't expect the moderation to read each and every post where they might get addressed. Also, don't post that redundantly in the thread itself.
leanchess wrote: ↑Fri Dec 03, 2021 7:11 pmDear Moderators
There is a button with an exclamation mark at every post which you can use to contact the moderation. That's there because you can't expect the moderation to read each and every post where they might get addressed. Also, don't post that redundantly in the thread itself.
According to the Report post page:
Reporting should generally be used only if the post breaks forum rules.