Article View: gnu.chess
Article #6113Re: playing gnuchess against another program
From: Philip Leong
Date: Mon, 19 Nov 1990 00:22
Date: Mon, 19 Nov 1990 00:22
106 lines
4598 bytes
4598 bytes
In article <9011160518.AA22499@ucbvax.Berkeley.EDU> jlol@ee.byu.edu writes:
>... What I'm wondering is whether there is a
>convenient way to play gnuchess against another program, or itself,
>that might be running on the same or a different machine.
I wrote a GNU emacs program to play gnuchess against itself and it is
included in this posting. It was written in July 1990 and I'm not sure if
there has been a new release since then. If it doesn't work, let me know
and I'll fix any problems. It is called playchess.el. Another program
pchess.el (also included) plays against /usr/games/chess on Suns.
You must have gnuchessr as generated in the distributed makefile
WITHOUT -DCHESSTOOL (or else you can't see the board displays).
The program should be able to play on different machines by invoking the
chess progams with an 'rsh'. You probably only need to change white-program
or black-program to do this.
Hope that someone finds these useful.
Philip Leong.
--
Department of Electrical Engineering Tel. (+61 2) 692 3297
University of Sydney 2006 Fax. (+61 2) 692 3847
Australia Internet: phwl@ee.su.oz.au
;; playchess.el - plays gnuchess against itself
;;
;; Philip Leong (phwl@ee.su.oz.au)
;;
(defvar chess-buffer "chess")
(defvar white-program "gnuchessr")
(defvar black-program "gnuchessr")
(defun other-proc (proc)
(cond ((equal (get-process "white") proc) "black")
((equal (get-process "black") proc) "white")
(t (insert "bad proc"))))
(defun chess-filter (proc string)
(set-buffer (process-buffer proc))
(goto-char (point-max))
(insert string)
(if (not (string-match "[0-9]+\. \.\.\. ...." string))
nil
(let ((str (concat (substring string
(- (match-end 0) 4)
(match-end 0)))))
(insert ">" str "<\n" )
(process-send-string (other-proc proc) "bd\n" )
(process-send-string (other-proc proc) (concat str "\n")))))
(defun chess ()
(interactive)
(start-process "white" chess-buffer white-program)
(start-process "black" chess-buffer black-program)
(switch-to-buffer chess-buffer)
;; set startup options on each side
(process-send-string "black" "30 2\n1\nbeep\n")
(process-send-string "white" "30 2\n1\nbeep\n")
;; tell the white one that it is white
(process-send-string "white" "white\n")
(set-process-filter (get-process "white") 'chess-filter)
(set-process-filter (get-process "black") 'chess-filter))
-------------------------------------------------------------------
;; pchess.el - plays gnuchess against chess
;;
;; Philip Leong (phwl@ee.su.oz.au)
;;
(defvar chess-buffer "chess")
(defvar white-program "gnuchessr")
(defvar black-program "chess")
(defun other-proc (proc)
(cond ((equal (get-process "white") proc) "black")
((equal (get-process "black") proc) "white")
(t (insert "bad proc"))))
(defun chess-filter (proc string)
(set-buffer (process-buffer proc))
(goto-char (point-max))
(insert string)
(if (not (string-match "[0-9]+\. \.\.\. ...." string))
nil
(let ((str (concat (substring string
(- (match-end 0) 4)
(match-end 0)))))
(insert ">" str "<\n" )
(process-send-string (other-proc proc) "bd\n" )
(process-send-string (other-proc proc) (concat str "\n")))))
(defun chess ()
(interactive)
(start-process "white" chess-buffer white-program)
(start-process "black" chess-buffer black-program)
(switch-to-buffer chess-buffer)
;; set startup options on each side
;; (process-send-string "black" "30 2\n1\nbeep\n")
(process-send-string "white" "30 2\n1\nbeep\n")
;; tell the white one that it is white
(process-send-string "white" "white\n")
(set-process-filter (get-process "white") 'chess-filter)
(set-process-filter (get-process "black") 'chess-filter))
Technical Details
Message-ID:
<1990Nov19.002229.22387@metro.ucc.su.OZ.AU>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!usc!apple!uokmax!munnari.oz.au!metro!newsReferences:
<9011160518.AA22499@ucbvax.Berkeley.EDU>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d71d,d6b8ff302278d7a3 X-Google-Attributes: gid10d71d,public X-Google-ArrivalTime: 1990-11-18 16:22:29 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!usc!apple!uokmax!munnari.oz.au!metro!news From: phwl@ee.su.oz.au (Philip Leong) Newsgroups: gnu.chess Subject: Re: playing gnuchess against another program Message-ID: <1990Nov19.002229.22387@metro.ucc.su.OZ.AU> Date: 19 Nov 90 00:22:29 GMT References: <9011160518.AA22499@ucbvax.Berkeley.EDU> Reply-To: phwl@ee.su.oz.au (Philip Leong) Organization: Electrical Engineering, The University of Sydney, Australia Lines: 106 Posted: Mon Nov 19 01:22:29 1990 Nntp-Posting-Host: brutus.ee.su.oz.au