Utility that converts FEN+move -> new FEN

Discussion of anything and everything relating to chess playing software and machines.

Moderator: Ras

titanD
Posts: 94
Joined: Sun Jun 29, 2014 5:41 pm

Utility that converts FEN+move -> new FEN

Post by titanD »

Would there happen to exist a tool (or a better way) that could get me from a FEN + a move to an updated FEN?

I was also thinking maybe just something that converts a PGN to an array of FEN's.

Then I could just turn the FEN + move into an array with starting position = FEN and a move list with the one move. Array would then be two FEN's, the last of which I wanted.
Ferdy
Posts: 4848
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Utility that converts FEN+move -> new FEN

Post by Ferdy »

titanD wrote:Would there happen to exist a tool (or a better way) that could get me from a FEN + a move to an updated FEN?
I can't understand that, describe more, give an example.

Let me think from your added description.

I was also thinking maybe just something that converts a PGN to an array of FEN's.
There is a tool called pgn2fen. This tool can also turn pgn to epd.

Then I could just turn the FEN + move into an array with starting position = FEN and a move list with the one move. Array would then be two FEN's, the last of which I wanted.
I can't understand this.
User avatar
Evert
Posts: 2929
Joined: Sat Jan 22, 2011 12:42 am
Location: NL

Re: Utility that converts FEN+move -> new FEN

Post by Evert »

titanD wrote:Would there happen to exist a tool (or a better way) that could get me from a FEN + a move to an updated FEN?
Sjaakii can do this easily if you're willing to run it on its own (for instance in a terminal).
Given this input:

Code: Select all

xboard

force setboard rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -
e4
fen
it produces the output

Code: Select all

rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
To get that directly from the command line, you'd run

Code: Select all

$sjaakii < fenmove2fen.in | tail -n1
where "fenmove2fen.in" contains the input I mentioned above.

One comment: as you can see from the FEN, Sjaakii sets the en-passant field "e3", even if the en-passant capture isn't actually legal. Strictly speaking this violates the FEN specification, but this ought to be harmless.
User avatar
hgm
Posts: 28382
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Utility that converts FEN+move -> new FEN

Post by hgm »

It all depends in which format you have the FEN + move. The standard format for storing moves is of course PGN. If you would have a file with such 1-move games, you could use it as a list of opening lines in WinBoard, for playing a match between two Resign engines (which resign as soon as they have to think up a move), and set WinBoard to save the final position of each game to a file.

The minimal requirement so that WinBoard still recognizes the input as a PGN game would be the FEN tag plus a move. Like

[FEN "1k6/7R/1K6/8/8/8/8/8 w - - 0 1"] h7h8

I am not sure I included the Resign engine in the WinBoard install, however. (I use it myself to extract starting positions from opening books.)