summaryrefslogtreecommitdiff
path: root/chess-phalanx.el
blob: 270376d081ec44c15e644086b396b13512a33ac3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Play against phalanx!
;;
;; $Revision$

(require 'chess-engine)
(require 'chess-common)

(defgroup chess-phalanx nil
  "The publically available chess engine 'phalanx'."
  :group 'chess-engine)

(defcustom chess-phalanx-path (executable-find "phalanx")
  "The path to the phalanx executable."
  :type 'file
  :group 'chess-phalanx)

(defvar chess-phalanx-regexp-alist
  (list
   (cons (concat "my move is P?\\(" chess-algebraic-regexp "\\)\\s-*$")
	 (function
	  (lambda ()
	    (funcall chess-engine-response-handler 'move
		     (chess-engine-convert-algebraic (match-string 1) t)))))
   (cons "Illegal move:\\s-*\\(.*\\)"
	 (function
	  (lambda ()
	    (error (match-string 1)))))))

(defun chess-phalanx-handler (event &rest args)
  (cond
   ((eq event 'initialize)
    (let ((proc (chess-common-handler 'initialize "phalanx")))
      (process-send-string proc "nopost\n")
      proc))

   (t
    (apply 'chess-common-handler event args))))

(provide 'chess-phalanx)

;;; chess-phalanx.el ends here