Wednesday, December 07, 2022 11:09


FENGEN (Forsyth-Edwards Notation Generator) is a spreadsheet that allows a person to enter in a board diagram in ASCII, the way it appears in a diagram, and converts the ASCII diagram to Forsyth-Edwards Notation.

You can download it in Excel format here.
You can download it as an OpenOffice ods workbook here.

( )

(Note: I started working on this in Excel, then computer failures caused me to finalize it in OpenOffice.) I hope it’s still compatible to both.

It is free to download and use, though I retain Copyright to the sheet itself.

So why would you use it?

Let’s say you have ten or so diagrams that you want to load into ChessBase.

For a touch-typist (like myself, for about 28 years and counting,) it is faster and easier to accurately type out all 64 spaces of a board diagram than it is to use a mouse-based Board Setup in ChessBase. So, if you have a position like this:

An Italian game after 1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. b4

An Italian game after 1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. b4

You type eight lines by rank in the spreadsheet, using regular capital letter abbrieviations for White pieces (K,Q,B,N,R,P,) lowercase letters for Black pieces (k,q,b,n,r,p,) and spaces for squares with no piece. The graphic above looks like this in the entry section of the spreadsheet:

The diagram entry section of FENGEN.  I've highlighted the sixth rank just to show that one enters blank squares as spaces.

The diagram entry section of FENGEN. I've highlighted the sixth rank just to show that one enters blank squares as spaces.

Then answer some optional basic questions (like who can castle, what move you want the diagram to be, which color is on move, if there is any square that can capture en passant, and how many halfmoves have elapsed towards counting towards a 50-move draw limit. But these are optional…)

FENGEN then translates this into a line like this:
r1bqk1nr/pppp1ppp/2n5/2b1p3/1PB1P3/5N2/P1PP1PPP/RNBQK2R b KQkq – 0 4

Select this cell in the spreadsheet, press Ctrl-C to copy it to the clipboard. For myself, using ChessBase 2007 Light Premium, I set up a board (using S), and click the “Paste FEN” button. Then bingo! My position is ready to go, much more quickly then I could move all the pieces around – especially doing bulk sets of diagrams.

Actually, at this point I could probably type the FEN string even more quickly by hand – I will sometimes record a “live” OTB diagram via FEN organized by rank – but I’ve done a lot of FEN generation. ;)

One can also use FENGEN to generate the FEN string to directly paste into a raw PGN file in a text editor. A PGN like this would look like the following:

[Event "Test FEN Run"]
[Site "Colley's Chess Cafe"]
[Date "2010.01.01"]
[Round "1"]
[White "Goodpawn, Garry G."]
[Black "Badbishop, Boris B."]
[SetUp "1"]
[FEN "r1bqk1nr/pppp1ppp/2n5/2b1p3/1PB1P3/5N2/P1PP1PPP/RNBQK2R b KQkq - 0 4"]
[Result "*"]
1. *

And you’re off and running! [That PGN text above has been tested in ChessBase 2007 Light, and loaded just fine! I was wondering how it would work to have the move number as 4, Black on move, with only 1. numbered. But CB recognizes and starts at Black move 4! Your database/pgn viewer may vary.]

Other things to note about FENGEN:

* I suggest you download, open the spreadsheet, and then use the “Save As” command right away to save it under a different name for usage. Why? Because…

* Be careful using it… You can overwrite a forumula (such as the final FEN generation cell – itself a forumula) and mess everything in the sheet up. If you saved it as something different above, then you can re-open the ‘source’ and re-save it.

* The sheet also has a “reverser” switch – this is used so that if you have a ‘reversed’ or ‘flipped’ diagram where the top row is Rank 1 (upper right corner is a1) and the bottom row is Rank 8… You still just type the diagram as it appears, enter “1” into the reverser cell, and you still get “Clean” FEN – reversing the ranks and files automatically. (FEN itself *always* starts with Rank 8 as the first entry / square a8 is the first character in the FEN string and cell h1 is the last of the squares noted.)

* The sheet has a very rudimentary amount of error-checking capability, mainly to make sure you type 8 (and only 8) characters in each Rank – no more, no less. It will tell you which line is in error, if any. It does *not* check to make sure you have only 1 King per side, or not more than 8 pawns, more than 16 pieces per side, or characters nonsensical to a FEN notation. (Some diagrams do only have one King to illustrate a point. Or Bughouse diagrams! Whatever… It wasn’t worth it to code checking beyond that. Even though ChessBase is *very* fussy when it comes to stuff like this.)

If you are using ChessBase, and the “OK” button is greyed out and can’t be selected after pasting the FEN, there is something wrong with the diagram. Look at some of these things:
* There must be one King of each color, and only one King.
* There cannot be more than 8 pawns per color.
* If a color is in Check, that color *must* be on move.
* Both sides can’t be in Check.
* I don’t think ChessBase allows you to set up a board in Mate.
* Are the Castling options correct? CB does a good job checking this.
* Triple check that all pieces are set up in ChessBase the way they are on the diagram.
* Quadruple check the diagram itself is a legal position.

I’m not sure how useful this will be to others. I find it quite handy sometimes. I hope you will, too!

Enjoy your chess!