Skip to content

Commit

Permalink
Add code for debugging castling generator
Browse files Browse the repository at this point in the history
  • Loading branch information
rchastain committed Oct 22, 2020
1 parent 2a94980 commit 0a34919
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions castling.pas
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ procedure Search(const AKingToCol, ARookToCol: integer); { Colonnes d'arrivée.
{ Deuxième condition : aucune pièce n'est sur le passage du roi ni sur celui de la tour. }
LKingPath := CPath[LKingFromIdx, LKingToIdx] or CIndexToSquare[LKingToIdx];
LRookPath := CPath[LRookFromIdx, LRookToIdx] or CIndexToSquare[LRookToIdx];
{$IFDEF DEBUG}
Log.Append(Concat(
'** King path:', LineEnding, BoardToFormattedStr(LKingPath), LineEnding,
'** Rook path:', LineEnding, BoardToFormattedStr(LRookPath), LineEnding,
'** All pieces:', LineEnding, BoardToFormattedStr(LPieces)
));
{$ENDIF}
LPath := LKingPath or LRookPath;
with APos do
begin
Expand All @@ -74,17 +81,21 @@ procedure Search(const AKingToCol, ARookToCol: integer); { Colonnes d'arrivée.
and (CountSquaresOn(LPath and LRooks) <= 1)
and (CountSquaresOn(LPath and LKing) <= 1)
then
Log.Append('** No piece on the path (cond. 2/3)')
Log.Append('** Path free (cond. 2/3)')
else
Exit;

{ Dernière condition : aucune des cases sur lesquelles le roi se trouve ou se trouvera n'est menacée. }
LKingPath := CIndexToSquare[LKingFromIdx] or CPath[LKingFromIdx, LKingToIdx] or CIndexToSquare[LKingToIdx];
{$IFDEF DEBUG}
Log.Append(Concat('** Threats:', LineEnding, BoardToFormattedStr(LThreats)));
{$ENDIF}
if (LThreats and LKingPath) = 0 then
Log.Append('** No attacked square (cond. 3/3)')
else
Exit;


{ Enregistrement du coup. Le coup est noté comme s'il s'agissait de la prise de la tour par le roi. }
SaveMove(LKingFromIdx, LRookFromIdx);
end;

Expand Down

0 comments on commit 0a34919

Please sign in to comment.