From cd7611184deab79e24d68447a99e97bbaf2d5a30 Mon Sep 17 00:00:00 2001 From: brian-ch Date: Wed, 4 Jul 2012 18:07:07 +0000 Subject: [PATCH] Fix a bug in pawnHasValidMove and in the pawn initial double move forward validation. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2471 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/fpchess/chessgame.pas | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/applications/fpchess/chessgame.pas b/applications/fpchess/chessgame.pas index 1adaba668..ec8346666 100644 --- a/applications/fpchess/chessgame.pas +++ b/applications/fpchess/chessgame.pas @@ -637,7 +637,7 @@ begin Result := not IsSquareOccupied(ATo); end // Initial double move forward - else if (AFrom.X = ATo.X) and (AFrom.Y = 2) and (AFrom.Y = ATo.Y - 2) then + else if (AFrom.X = ATo.X) and (AFrom.Y = 2) and (AFrom.Y = ATo.Y - 2) and (not IsSquareOccupied(Point(AFrom.X,AFrom.Y+1))) then begin Result := not IsSquareOccupied(ATo); AEnpassantSquare := Point(AFrom.X, ATo.Y - 1); @@ -675,7 +675,7 @@ begin Result := not IsSquareOccupied(ATo); end // Initial double move forward - else if (AFrom.X = ATo.X) and (AFrom.Y = 7) and (AFrom.Y = ATo.Y + 2) then + else if (AFrom.X = ATo.X) and (AFrom.Y = 7) and (AFrom.Y = ATo.Y + 2) and (not IsSquareOccupied(Point(AFrom.X,AFrom.Y-1))) then begin Result := not IsSquareOccupied(ATo); AEnpassantSquare := Point(AFrom.X, ATo.Y + 1); @@ -913,11 +913,11 @@ begin begin ATo:=Point(ASquare.X,ASquare.Y+2); if (ASquare.Y+2<=8) and (CheckEndMove(ATo)) and ValidatePawnMove(ASquare,ATo,nullPoint,nullPoint) then //try to move 2 squares - if (makeMoveAndValidate(ASquare,ATo,nullPoint)) then exit(true); + if (makeMoveAndValidate(ASquare,ATo,Point(-1,-1))) then exit(true); ATo:=Point(ASquare.X,ASquare.Y+1); if (ASquare.Y+1<=8) and (Board[ATo.X][ATo.Y]=ctEmpty) then //try to move 1 square - if (makeMoveAndValidate(ASquare,ATo,nullPoint)) then exit(true); + if (makeMoveAndValidate(ASquare,ATo,Point(-1,-1))) then exit(true); ATo:=Point(ASquare.X-1,ASquare.Y+1); if (ASquare.X-1>=1) and (ASquare.Y+1<=8) and (CheckEndMove(ATo)) and (ValidatePawnMove(ASquare,ATo,nullPoint,nullPoint)) then //try to capture to the left @@ -930,12 +930,12 @@ begin else begin ATo:=Point(ASquare.X,ASquare.Y-2); - if (ASquare.Y-2>=1) and (CheckEndMove(ATo)) and ValidatePawnMove(ASquare,ATo,nullPoint,nullPoint) then //try to move 2 squares - if (makeMoveAndValidate(ASquare,ATo,nullPoint)) then exit(true); + if (ASquare.Y-2>=1) and (CheckEndMove(ATo)) and (ValidatePawnMove(ASquare,ATo,nullPoint,nullPoint)) then //try to move 2 squares + if (makeMoveAndValidate(ASquare,ATo,Point(-1,-1))) then exit(true); ATo:=Point(ASquare.X,ASquare.Y-1); if (ASquare.Y-1>=1) and (Board[ATo.X][ATo.Y] = ctEmpty) then //try to move 1 square - if (makeMoveAndValidate(ASquare,ATo,nullPoint)) then exit(true); + if (makeMoveAndValidate(ASquare,ATo,Point(-1,-1))) then exit(true); ATo:=Point(ASquare.X-1,ASquare.Y-1); if (ASquare.X-1>=1) and (ASquare.Y-1>=1) and (CheckEndMove(ATo)) and (ValidatePawnMove(ASquare,ATo,nullPoint,nullPoint)) then //try to capture to the left