Article View: gnu.chess
Article #1878Re: Need List of Legal Moves for Given Position
From: Simon Waters
Date: Tue, 15 Jan 2002 14:54
Date: Tue, 15 Jan 2002 14:54
40 lines
3086 bytes
3086 bytes
Ed Suominen wrote: > > I would like to use GNUchess (or something else) to generate a list of legal > moves for a given position. I plan to use TCL to interface with the program > via STDIN and STDOUT. The GNUchess command "test movelist" looks promising, > but I don't see how I can call GNUchess from the command line to execute > that one command, send the result to STDOUT, and return to TCL. > > Is there a simple change to the source I could make to have GNUchess do > this? Does anyone have any suggestions? If you use gnuchess, use version 5 and read cmd.c - it isn't so painful - I will document it better soon. You shouldn't try to restart GNUchess each time, you can use pipes, redirecting the stdin and stdout of GNUchess to you own program like xboard does. TCL is good at that sort of thing I believe. "new" to restart a game, "epd" to set a position, "show moves" to get a list of moves, there are various other commands. The "test" commands are mostly aimed at developers, and some are bust or require additional files. Since legal moves in a position requires history (enpassant and legality of castling) it is better to feed the moves in as they are played in most cases, although a correct EPD record can handle these cases it's easier just to use a program to supply all the chess brain. If you do decide to go with GNUchess, I suggest working with the CVS version on Savannah, so you get the benefits of current developments, indeed 5.03Beta has a legal move correction in the code be it ever so obscure. xboard is open source for a reason ;), although xboard does not do strict legal move detection as it plays variants, and will play back games with illegal moves in. There was one in the GNU chess 5.02 book.pgn where a player took enpassant when the pawn had moved one square! (Indeed a Bishop on the second rank made it clear that it couldn't have gone 2 squares....). Somehow Xboard knew just what was meant!
Technical Details
Message-ID:
<3C4442A4.3B0CB224@wretched.demon.co.uk>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!wretched.demon.co.uk!not-for-mailReferences:
<a20j69$n43$1@news.chatlink.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d71d,9700b52d8020e3de X-Google-Attributes: gid10d71d,public X-Google-ArrivalTime: 2002-01-15 06:55:03 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!wretched.demon.co.uk!not-for-mail From: Simon Waters <Simon@wretched.demon.co.uk> Newsgroups: gnu.chess Subject: Re: Need List of Legal Moves for Given Position Date: Tue, 15 Jan 2002 14:54:28 +0000 Organization: Eighth Layer Limited Message-ID: <3C4442A4.3B0CB224@wretched.demon.co.uk> References: <a20j69$n43$1@news.chatlink.com> NNTP-Posting-Host: wretched.demon.co.uk X-NNTP-Posting-Host: wretched.demon.co.uk:193.237.109.203 X-Trace: news.demon.co.uk 1011106469 nnrp-08:14897 NO-IDENT wretched.demon.co.uk:193.237.109.203 X-Complaints-To: abuse@demon.net X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.19 i686) X-Accept-Language: en-GB, en-US, en MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 40