Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Legal moves generation

Author: Russell Reagan

Date: 10:50:50 04/27/02

Go up one level in this thread


On April 27, 2002 at 11:15:00, Marek Mahdal wrote:

>Hi everybody !
> Can somebody help me to find a function, which will generate all possible legal
>moves for a given position (any chessboard representation) in PHP or any other
>scripting non-type programming language ? I am not looking for a chess engine,
>only for the move generatino routine.
>
>Example:
>input parameters could be:
>
>- current chessboard representation
>- ep status
>- castle status
>- maybe history of moves
>
>output:
>- array of all possible move in the given position.
>
>Thank you a lot !
>
>Marek Mahdal, Slovakia

This depends on your specific needs. For example, do you want a list of 100%
legal moves? Most chess programs don't generate all of the legal moves. For
example most don't detect pinned pieces and often move them, and they catch them
when they make the move and see that the side not to move is in check. So if you
want 100% legal moves you'd have to either write a pin detection function or a
function to make a move, find if one of the king's is in check, and eliminate
the illegal moves.

I assume that you're trying to do some kind of web interaction. If that is the
case, I would suggest writing this in C or C++ and maybe write a script that
will parse the form data, then call the C/C++ program and store it's output in a
variable, then output it back to the user. That's what I would do rather than
write this kind of thing in a scripting language.

Russell



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.