From 7d9cde1a4e295bbe2ecd76cf9d71f8818995471c Mon Sep 17 00:00:00 2001 From: sekelsenmat Date: Tue, 30 Aug 2011 15:42:10 +0000 Subject: [PATCH] fpchess: Had forgotten to make AI moves in its board git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1877 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- applications/fpchess/engines/kcchess/mod_kcchess.pas | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/applications/fpchess/engines/kcchess/mod_kcchess.pas b/applications/fpchess/engines/kcchess/mod_kcchess.pas index 8674c5144..02c2d5748 100644 --- a/applications/fpchess/engines/kcchess/mod_kcchess.pas +++ b/applications/fpchess/engines/kcchess/mod_kcchess.pas @@ -255,6 +255,8 @@ begin StartupInitialize(); DefaultBoard(); + Game.GameFinished := false; + if vChessGame.FirstPlayerIsWhite then begin ComputerColor := C_BLACK; @@ -277,6 +279,7 @@ var UserMovement, AIMovement: MoveType; Escape: boolean; Score: Integer; + lMoved: Boolean; begin // initialization Escape := False; @@ -301,12 +304,16 @@ begin { Now get the computer move } GetComputerMove(ComputerColor, False, AIMovement, Escape); + MakeMove(AIMovement, True, Score); { And write it to our board } - vChessGame.MovePiece( + lMoved := vChessGame.MovePiece( Point(AIMovement.FromCol, AIMovement.FromRow), Point(AIMovement.ToCol, AIMovement.ToRow)); + + if not lMoved then raise Exception.Create(Format('Moving failed from %s to %s', + [vChessGame.BoardPosToChessCoords(AFrom), vChessGame.BoardPosToChessCoords(ATo)])); end; initialization