]> code.delx.au - gnu-emacs-elpa/blob - chess-fruit.el
Proper file header.
[gnu-emacs-elpa] / chess-fruit.el
1 ;;; chess-fruit.el --- Play against fruit!
2
3 ;; Copyright (C) 2014 Free Software Foundation, Inc.
4
5 ;; Author: Mario Lang <mlang@delysid.org>
6 ;; Keywords: games, processes
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
20
21 ;;; Code:
22
23 (require 'chess-uci)
24
25 (defgroup chess-fruit nil
26 "The publically available chess engine 'fruit'."
27 :group 'chess-engine
28 :link '(url-link "http://www.fruitchess.com/"))
29
30 (defcustom chess-fruit-path (executable-find "fruit")
31 "*The path to the fruit executable."
32 :type 'file
33 :group 'chess-fruit)
34
35 (defvar chess-fruit-regexp-alist chess-uci-regexp-alist
36 "Patterns used to match engine output.")
37
38 (defun chess-fruit-handler (game event &rest args)
39 (unless chess-engine-handling-event
40 (cond
41 ((eq event 'initialize)
42 (let ((proc (chess-uci-handler game 'initialize "fruit")))
43 (when (and proc (processp proc) (eq (process-status proc) 'run))
44 (process-send-string proc "uci\n")
45 (setq chess-engine-process proc)
46 t)))
47
48 (t
49 (if (and (eq event 'undo)
50 (= 1 (mod (car args) 2)))
51 (error "Cannot undo until after fruit moves"))
52
53 (apply 'chess-uci-handler game event args)))))
54
55 (provide 'chess-fruit)
56
57 ;;; chess-fruit.el ends here