The PHP Chess Diagrammer is s PHP script which creates
chess diagram images on the fly, based on an algebraic notation called
"Fairy FEN" (FFEN).

This script is based on the PHPdiag script by Joost de Heer, see
Joost's mail from 2002. Joost also invented the FFEN notation.##
Fairy FEN

Fairy FEN is an extension to the usual FEN notation. Additionally
to the traditional chess pieces, Fairy FEN supports pieces and markers
used in fairy chess:

• Normal chess pieces, e.g.:

• Fairy pieces, i.e. normal chess symbols rotated by 90°, 180° or
270°, e.g.:

• Neutral pieces, which are neither black nor white, e.g.:

• Markers of different shapes in white and black:

• Upper case letters (A to Z), lower case letters (a to z) and numbers
(0 to 99):

With Fairy FEN is is possible to specify most (if not any) fairy chess
problem.

## Fairy FEN Specification

The following specification assumes that the reader is familiar with
the traditional FEN notation. A complete specification if traditional
FEN can be found
HERE.

• A chess diagram is specified by a sequence of letters an digits,
row by row and column by column, starting in the upper left corner.
The rows are separated by "/" signs:

row8/row7/row6/row5/row4/row3/row2/row1

Note that FFEN supports also larger and smaller chess boards, i.e.
a chess board can have the dimensions 4x4 or 11x11, for example.

• Chess pieces are denoted by the letters K (King), Q (Queen), R (Rook),
B (Bishop), N (kNight) and P (Pawn); lower case letters denote black
pieces; upper case letters denote white pieces; a sequence of empty
squares is denoted by a one-digit number specifying the length of the
sequence. The starting position is thus specified by:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

• A marker is specified by the letters C (circle), X (cross), S (square)
and T (triangle); lower case letters denote black markers; upper case
letters denote white markers. Technically, there is no difference between
normal pieces and markers.

• A neutral piece or a neutral marker is denoted by prefixing a piece
or marker symbol with a "-" sign, e.g. -B or -b denotes a neutral Bishop.
There is no difference between upper and lower case letters.

• A rotated piece or marker is denoted by prefixing a piece or marker
symbol by a »*« sign, followed by a one-digit number specifying how
often the piece should be rotated clockwise in 90° steps. For example,
»*1B« denotes white Bishop rotated by 90°, »*3q« denotes a black Queen
rotated by 270°, and »-*2r« denotes a neutral rook rotated by 180°.

• A letter is denoted by prefixing it by a »'« sign, e.g. 'a or 'A.
There are black lower case letters and black upper case letters, but
no white or neutral letters. Letters can be rotated.

• A number is denoted by prefixing it by one »'« sign (one-digit number)
or two »'« signs (two digit number), e.g. »'7« or »''23«. Note that
»'2'3« and »"23« are different: »'2'3« denote two squares with the numbers
2 and 3 respectively; »''23« denotes a single square with the number
23. There are black numbers only, no white or neutral numbers. Numbers
can be rotated.

Note: Why are two »'« necessary? To avoid ambiguity:
»'32« is a square with the number 3 followed by 2 empty squares, while
»''32« is a square with the number 32. Unfortunately, »"« cannot be
used to denote two-digit numbers because »"« is a HTML delimiter.

## How to use

Embed an image in the HTML file or HTML mail as follows:

<img src="http://www.janko.at/Retros/d.php?ff=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR">

That's all!

## Examples

Starting position:

http://www.janko.at/Retros/d.php?ff=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR

Some rotated pieces, markers, letters and numbers:

http://www.janko.at/Retros/d.php?ff=rnbqkbnr/p*1p*2p*3pp*1p*2p*3p/'a'b'c'd'w'x'y'z/-p-P-r-R-n-N-b-B/cCsSxXtT/'A'B'C'D'W'X'Y'Z/'0'1'2'3'4''11''22''33/RNBQKBNR

F307 - Reto Aschwanden

*Probleemblad* 2, Mar/Apr 2002

Mate in 3 moves.

http://www.janko.at/Retros/d.php?ff=3*2r3*3N3/*3n6*2r3/*3N*2bp3*2bQ3/2*2b*2r3p3/1*2r2P1p4/4N4p1/1K*3n5p2/3*3Np1B1P2/3pN1p4/3B*2rkb2*3nR/6*3rbN2

3874 - Jean-Michel Trillon

*diagrammes* 123, 10/1997
Ortho-reconstruction in 25.0 moves (white starts)

http://www.janko.at/Retros/d.php?ff=k1B5/-p1PP4/K1-p5/p1-p5/p7/2p1-p3/4P3/8

G161 - Petko Petkov

*feenschach* 1993, Prix spécial

*FIDE Album* 1992-1994

Mate in 2 moves (Circe)

http://www.janko.at/Retros/d.php?ff=4n3/1-*2q2b-qp-*2n/4p-*2qp1/2*2q1pkp-r/4pP*2q1/1p2P2p/1-*2q6/*2q2KB3

G148 - T. Wakashima

*Phénix* 1993, 2e Prix

*FIDE Album* 1992-1994
ser-s#11 (2 solutions)

http://www.janko.at/Retros/d.php?ff=8/1Q6/4c3/4cc2/8/8/6K1/8

G106 - Thomas Maeder

*feenschach* 1987, 2e Prix

*Fide Album* 1986-1988
h=2 (Imitator e5)

(a) diagram (b) wK->g5 (c) Ie5->c5 (d) Ie5->a7

http://www.janko.at/Retros/d.php?ff=8/1P6/1k6/4cK2/8/8/8/8