
C source for CHESS

Here is a shar script containing source code in 'C' for a chess
program I've written. The following files are included:
  1. chess.c   : C source for CHESS
  2. chess.opn : Opening Library
  3. chess.001 : Sample problem

The file chess.c must be compiled with the -lcurses option. The
code is pretty generic (I think) and hopefully will run on a wide
variety of machines. The help command gives a list of the options
available.  To test out the program, enter 'get' and respond to
the file name prompt with 'chess.001'.  Type 'switch' and the
computer should find mate in 4 with Nf7.  This takes a few seconds
on an HP350 computer.

The program plays a fairly respectable game of chess, although it
is not competetive with a state-of-the art commercial program. The
search rate is typically 100-300 nodes/sec. on an HP Vectra (8 Mhz.
286) and about 300-900 nodes/sec. on an HP 350 (25 Mhz. 68020). I
am interested to find out what is achieved on other machines. I
would also be interested in any comments on playing strength,
weaknesses or bugs in the program, and suggested improvements in
the algorithm.

Here are a few comments on the program:

1. Opening Library
     I'm a terrible chess player and don't know anything about
     openings. I copied 70-80 random lines of play from MCO into
     the file chess.opn. I think there are a few mistakes in the
     translation. If anyone generates a better library please let
     me know.

2. Positional Heuristics
     I think that improvement in this area would help the program
     quite a bit. In most situations the computer cannot do
     anything forceful and the choice of a move is based on
     positional aspects. I haven't spent a lot of time on the
     heuristics and many times the program has no idea of what is
     happening and how to proceed. Perhaps optimizing the values of
     the existing heuristics would help, but to get a major
     improvement I think more chess knowledge will be necessary.

3. Search Algorithm
     This program uses a full-width alpha-beta searching technique
     with depth extensions on checks, check evasions, pawn promotion
     threats and threats to multiple pieces. Capture sequences are
     handled by a separate search routine. I imagine that much more
     efficient search routines exist, and would be interested to hear
     of any. Refinements of the search extension heuristics (similar
     to the extensions for pawn promotion threats) could have a major
     effect on the programs ability.

4. Move Generation
     There are probably better ways to do this, but they would
     likely change the data structure drastically and necessitate
     a complete re-write. Maybe some good hacks would speed things
     up, the ataks function would be the best place to start.

From bob  Fri Mar 20 07:34:35 1992 remote from dalek
Received: by mwcbbs.mwc.com (smail2.5-coherent) id AA07577; 20 Mar 92 07:34:35 
Received: by dalek.mwc.com (smail2.5.2-coh) id AA04448; 20 Mar 92 07:21:03 
Subject: Forwarded mail...chess
To: mwcbbs!bob
From: Bob Hemedinger <bob@dalek.mwc.com>
X-Mailer: ELM [version 2.3 PL11]
Message-Id: <9203200721.AA04448@dalek.mwc.com>
Date: 20 Mar 92 07:21:03 

Forwarded message:
From doug  Thu Mar 19 21:18:29 1992 remote from mwc
Message-Id: <9203191529.AA21592.V3.4@mwc.com>
Date: 19 Mar 92 15:29:38
From: doug@mwc.com (Doug Peterson)
To: bob

Article 571 of comp.os.coherent:
Path: mwc!chinet!machine!uchinews!ncar!elroy.jpl.nasa.gov!usc!rpi!think.com!cass.ma02.bull.com!mips2!bubba!sje
From: sje@xylos.ma30.bull.com (Steven J. Edwards)
Sender: news@mips2.ma30.bull.com (Usenet News Manager)
Reply-To: sje@xylos.ma30.bull.com
Newsgroups: comp.os.coherent
Distribution: comp
Subject: Quick color mod for Coherent chess program
Message-ID: <SJE.92Mar18142458@xylos.ma30.bull.com>
Organization: Bull HN, Worldwide Information Systems, Billerica, Mass., USA
Date: 18 Mar 92 21:24:58 GMT
Lines: 59


	The chess program available from mwcbbs and other sites plays
an interesting game.  However, it uses only monochrome characters to
display the board and pieces.  This makes it difficult for a player to
easily distinguish between the white and black pieces.  To improve
matters for those with color monitors, I have written a patch to
chess.c that displays the white pieces in red and the black pieces in
blue.  It uses ANSI escape sequences to do the trick.

	It's easy to install.  Simply replace the existing "DrawPiece"
routine with the following:

/**** Cut here */
/**** Cut here */

	Enjoy.

 [The above opinions expressed are my own; not necessarily held by others.]
      == Steven J. Edwards           Bull HN Information Systems Inc. ==
      == (508) 294-3484              300 Concord Road         MS 820A ==
      == sje@xylos.ma30.bull.com     Billerica, MA 01821          USA ==
"That Government which Governs the Least, Governs Best." -- Thomas Jefferson




--------------------------------------------------------------------------------
:) Happy Trails To You...			Mark Williams Co.
						708-291-6700 
Reply via --	uunet!mwc!htrails
--------------------------------------------------------------------------------



-- 
(====================]          _____		   MWC Technical Support
         \\             (===================)		NCC-1701-MWC
   (======\\======]         /// ~~~~~			bob@mwc.com
           \\/             ///				mwcbbs!bob
    ===========================	 Borg Busters!
     =========================(


printw("This program attempts to play CHESS\n\n");
printw("To make a move, enter the column (labelled 'a' - 'h') and\n");
printw("row (labelled '1' - '8') of the 'from' and 'to' squares.\n");
printw("For example, to move the kings pawn forward 2 squares, type e2e4.\n");
printw("Other commands are:\n\n");
printw("o-o           castle king side\n");
printw("o-o-o         castle queen side\n");
printw("set           set up a board position\n");
printw("switch        switch sides with computer\n");
printw("go            skip your move\n");
printw("reverse       reverse board display\n");
printw("redraw        re-paint display\n");
printw("both          computer plays both sides\n");
printw("time          change response time\n");
printw("post          post best line of play\n");
printw("hint          computer suggests your move\n");
printw("list          list moves to file chess.lst\n");
printw("save          save game to disk\n");
printw("get           get game from disk\n");
printw("quit          exit CHESS\n");
