]> code.delx.au - gnu-emacs-elpa/blob - chess-phalanx.el
Try to improve the promotion situation on ICS by allowing chess-ply to query for...
[gnu-emacs-elpa] / chess-phalanx.el
1 ;;; chess-phalanx.el --- Play chess against phalanx!
2
3 ;; Copyright (C) 2002, 2004 Free Software Foundation, Inc.
4
5 ;; Author: John Wiegley
6 ;; Maintainer: Mario Lang <mlang@delysid.org>
7 ;; Keywords: games, processes
8
9 ;; This file is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; This file is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 (require 'chess-common)
25
26 (defgroup chess-phalanx nil
27 "The publically available chess engine 'phalanx'."
28 :group 'chess-engine
29 :link '(url-link "http://phalanx.sourceforge.net/"))
30
31 (defcustom chess-phalanx-path (executable-find "phalanx")
32 "The path to the phalanx executable."
33 :type 'file
34 :group 'chess-phalanx)
35
36 (defvar chess-phalanx-regexp-alist
37 (list
38 (cons (concat "my move is P?\\(" chess-algebraic-regexp "\\)\\s-*$")
39 (function
40 (lambda ()
41 (funcall chess-engine-response-handler 'move
42 (chess-engine-convert-algebraic (match-string 1) t)))))
43 (cons "Illegal move:\\s-*\\(.*\\)"
44 (function
45 (lambda ()
46 (error (match-string 1)))))))
47
48 (defun chess-phalanx-handler (game event &rest args)
49 (unless chess-engine-handling-event
50 (cond
51 ((eq event 'initialize)
52 (let ((proc (chess-common-handler game 'initialize "phalanx")))
53 (when (and proc (processp proc)
54 (eq (process-status proc) 'run))
55 (process-send-string proc "nopost\n")
56 (setq chess-engine-process proc
57 chess-engine-opponent-name "Phalanx")
58 t)))
59
60 ((eq event 'resign)
61 (chess-game-set-data game 'active nil))
62
63 (t
64 (apply 'chess-common-handler game event args)))))
65
66 (provide 'chess-phalanx)
67
68 ;;; chess-phalanx.el ends here