From 2ef00c4beddb77e546cdc212cc502c5a9a4bba6c Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Sun, 7 Apr 2002 08:44:00 +0000 Subject: Simplified the event model, and removed session objects. Now everything just revolves around a game. Gnuchess is now playable to the end, except don't make moves that leave your king in check! The engine still doesn't check for this yet. --- chess-crafty.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'chess-crafty.el') diff --git a/chess-crafty.el b/chess-crafty.el index d9038db..a88a831 100644 --- a/chess-crafty.el +++ b/chess-crafty.el @@ -14,13 +14,16 @@ chess-algebraic-regexp "\\)\\s-*$") (function (lambda () - (let ((position (chess-engine-position nil))) - (if (string= (if (chess-pos-side-to-move position) - "White" "Black") - (match-string 1)) - (funcall chess-engine-response-handler 'move - (chess-algebraic-to-ply position - (match-string 2)))))))) + (let ((position (chess-engine-position nil)) + (move (match-string 2)) + ply) + (when (string= (if (chess-pos-side-to-move position) + "White" "Black") + (match-string 1)) + (setq ply (chess-algebraic-to-ply position move)) + (unless ply + (error "Could not convert engine move: %s" move)) + (funcall chess-engine-response-handler 'move ply)))))) (cons "Illegal move:\\s-*\\(.*\\)" (function (lambda () -- cgit v1.2.3