summaryrefslogtreecommitdiff
path: root/chess-crafty.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-07 08:44:00 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-07 08:44:00 +0000
commit2ef00c4beddb77e546cdc212cc502c5a9a4bba6c (patch)
treef20a250ce3e162fd5580696528d7b8251cdcfcf4 /chess-crafty.el
parentb148d84be1c3bd781c4fd11dd0a928fbeeda28fd (diff)
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.
Diffstat (limited to 'chess-crafty.el')
-rw-r--r--chess-crafty.el17
1 files changed, 10 insertions, 7 deletions
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 ()