Is there any way to use chess engines (by commands or GUI tools) to find the sequence of moves need to transform an initial position(P1) to a target position(P2) while the count of moves is exactly N?

For example, after giving it a FEN as P1 and another FEN as P2, it outputs a list of N legal moves that transforms P1 to P2.

Assume it's possible to do N moves to transform the initial position to target position.


1 Answer 1


Yes and No, but be warned, the possible paths to search through grows exponentially as your N increases.

The short answer is NO, unless you find someone who is doing research on chess and is using an engine for the special case like you are describing.


If someone were to do research on this special case he would setup his experiment probably like this:

First set an engine to calculate at a fixed depth 1 for the current position and make it return all variants it is evaluating. In effect this will return all possible legal moves from the current position.

All you need to do now is write your own breadth-first search algorithm, set to depth N, that can go from one state to another by using the cofigured engine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.