Introduction
Introduction Statistics Contact Development Disclaimer Help
remove the ability to castle when the king or rook moves - chess-puzzles - ches…
git clone git://git.codemadness.org/chess-puzzles
Log
Files
Refs
README
LICENSE
---
commit d69d3ff1075f952ebdd45af40e7580bb3003721f
parent a0e61726e8e522f6731e6eb27e18856f4fde61fb
Author: Hiltjo Posthuma <[email protected]>
Date: Wed, 20 Dec 2023 20:19:55 +0100
remove the ability to castle when the king or rook moves
Diffstat:
M fen_to_svg.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/fen_to_svg.c b/fen_to_svg.c
@@ -559,8 +559,6 @@ main(int argc, char *argv[])
y2 = 7;
place(0, x2, y2);
}
- /* remove the ability to castle */
- white_can_castle[0] = white_can_castle[1] = 0;
} else if (piece == 'k' && y == 0 && y2 == 0 && x == 4…
/* black: kingside castling: "e8g8" */
if (x2 == 6) {
@@ -575,8 +573,23 @@ main(int argc, char *argv[])
y2 = 0;
place(0, x2, y2); /* clear rook square…
}
- /* remove the ability to castle */
+ }
+
+ /* remove the ability to castle */
+ if (piece == 'K') {
+ white_can_castle[0] = white_can_castle[1] = 0;
+ } else if (piece == 'k') {
black_can_castle[0] = black_can_castle[1] = 0;
+ } else if (piece == 'R') {
+ if (x == 7 && y == 7)
+ white_can_castle[0] = 0;
+ else if (x == 0 && y == 7)
+ white_can_castle[1] = 0;
+ } else if (piece == 'r') {
+ if (x == 0 && y == 0)
+ black_can_castle[1] = 0;
+ else if (x == 7 && y == 0)
+ black_can_castle[0] = 0;
}
/* possible promotion: queen, knight, bishop */
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.