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
This commit is contained in:
brian-ch
2012-07-04 18:07:07 +00:00
parent 4a89dd32e2
commit cd7611184d

View File

@ -637,7 +637,7 @@ begin
Result := not IsSquareOccupied(ATo); Result := not IsSquareOccupied(ATo);
end end
// Initial double move forward // 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 begin
Result := not IsSquareOccupied(ATo); Result := not IsSquareOccupied(ATo);
AEnpassantSquare := Point(AFrom.X, ATo.Y - 1); AEnpassantSquare := Point(AFrom.X, ATo.Y - 1);
@ -675,7 +675,7 @@ begin
Result := not IsSquareOccupied(ATo); Result := not IsSquareOccupied(ATo);
end end
// Initial double move forward // 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 begin
Result := not IsSquareOccupied(ATo); Result := not IsSquareOccupied(ATo);
AEnpassantSquare := Point(AFrom.X, ATo.Y + 1); AEnpassantSquare := Point(AFrom.X, ATo.Y + 1);
@ -913,11 +913,11 @@ begin
begin begin
ATo:=Point(ASquare.X,ASquare.Y+2); 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 (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); 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 (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); 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 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 else
begin begin
ATo:=Point(ASquare.X,ASquare.Y-2); 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 (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 (makeMoveAndValidate(ASquare,ATo,Point(-1,-1))) then exit(true);
ATo:=Point(ASquare.X,ASquare.Y-1); 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 (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); 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 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