1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; Play against phalanx!
7 (require 'chess-engine)
9 (require 'chess-algebraic)
11 (defgroup chess-phalanx nil
12 "The publically available chess engine 'phalanx'."
15 (defcustom chess-phalanx-path (executable-find "phalanx")
16 "The path to the phalanx executable."
18 :group 'chess-phalanx)
20 (defvar chess-phalanx-regexp-alist
22 (cons (concat "my move is P?\\(" chess-algebraic-regexp "\\)\\s-*$")
25 (funcall chess-engine-response-handler 'move
26 (chess-engine-convert-algebraic (match-string 1))))))
27 (cons "Illegal move:\\s-*\\(.*\\)"
30 (signal 'chess-illegal (match-string 1)))))))
32 (defun chess-phalanx-handler (event &rest args)
34 ((eq event 'initialize)
36 (message "Starting chess program 'phalanx'...")
37 (unless chess-phalanx-path
38 (error "Cannot find phalanx executable; check `chess-phalanx-path'"))
39 (setq proc (start-process "chess-process" (current-buffer)
41 (message "Starting chess program 'phalanx'...done")
42 (process-send-string proc "nopost\n")
46 (chess-engine-send nil "quit\n"))
49 (and (chess-engine-game nil)
50 (chess-game-set-data (chess-engine-game nil) 'active t)))
53 (chess-engine-send nil "go\n"))
55 ((memq event '(abort resign))
56 (chess-engine-send nil "new\n")
57 (and (chess-engine-game nil)
58 (chess-engine-set-start-position nil)))
61 (chess-engine-default-handler 'decline-draw))
64 (when (chess-engine-game nil)
65 (dotimes (i (car args))
66 (chess-engine-send nil "undo\n"))
67 (chess-game-undo (chess-engine-game nil) (car args))))
70 (chess-engine-send nil (concat (chess-ply-to-algebraic (car args))
73 (provide 'chess-phalanx)
75 ;;; chess-phalanx.el ends here