Author: Pete Galati
Date: 09:48:49 08/28/99
Go up one level in this thread
On August 28, 1999 at 02:13:05, Scott Gasch wrote:
>
>What a brain dead standard! What's wrong with d2d4? It seems to me like alg
>notation is just needlessly complicated to parse.
>
>That said, question is: does anyone have a PGN->d2d4 conversion program? If not
>it's the next things I will write :)
>
>Scott
Next time their ftp server is working (who knows when) try going to
ftp://caissa.onenet.net/pub/chess/Unix/ and getting the code for a program
called "chessprn". I'm not really sure of it's capabilities but I'm betting that
it can do that. Below is the doc file that comes with it, I haope the guy
doesn't mind my pasting it in here, generally I don't think it's a well known
program.
Pete
NAME
ChessPrn - transform ascii chess notation into various formats
SYNOPSYS
chessprn [input file] [-o output file] [-options...]
DESCRIPTION
This program reads chess games, either full algebraic or
shortened (ie Nf1-g3 or Ng3) and is able to ouptut boards,
comments, moves and variations in a variety of different
formats. Under most output drivers, multiple games per input
file are allowed.
This program is also multilingual. It allows moves to be
translated from one language to another.
The program will run under UNIX and DOS, and probably many
other platforms as well.
OPTIONS
Command line options:
-a algebraic move notation output
-s shortened move notation output
-f <language>
specifies the chess symbol input language. The
language can be any of french, english, italian,
spanish, german, dutch, czech, hungarian, polish,
romanian, FIDE, swedish, portuguese, norwegian, finnish,
estonian.
-t <language>
specifies the chess symbol output language. Same
options as input language.
<inputfile>
specifies the input file. If none, keyboard is
assumed.
-o <outputfile>
specifies the output file. If none, screen is
assumed.
-c <number>[,<number>]
specifies the number of the moves after which to
display the board. If none, board is displayed at
end of file. Several numbers may be specified, as a
comma-separated list.
-e <number>
display the board at the move number and then stops
-b display only the board, not the moves
-d <drivername>
specifies the output driver. It can be any of the
following: ascii, postscript (cheq), tex (latex),
roff, xchess (xchess or xboard save format), gnu
(gnuan input format), cm (ChessMaster), zarkov
ps (Walker font), pgn (Portable Game Notation)
-i
suppress headers/footers printing. This is useful
with tex or ps drivers, if you want to include the
output in a larger file.
-v displays version number and exits
-h displays help screen
-n suppress final board display
-column output moves in column form:
1. e4 d5
2. c4 dc
etc.
The default is linear:
1. e4 d5 2. c4 dc etc.
INPUT LANGUAGE
The input language has four types of input: moves,
move numbers, comments and keywords. All these are separated
by blanks, TAB, CR, commas and semi-columns.
move format:
The moves are accepted in algebraic or shortened
algebraic notation. That means that the following
are equivalent and accepted Nf1-g3 N-f1xg3, Nxg3,
Ng3, Nfg3, f1g3, cd, cxd. The ugly english nota-
tion P-K4 is not understood, but I'm working on it.
The program allows and parses variations.
Note: provided you remove the first three lines,
xchess save format is accepted.
Also you can have move comments. So Kg4!!, Ra5++
are correct, as Kg4 !!, Ra5 ++, Qa1#. Castling is
recognized with the following 0-0 O-O o-o 0-0-0 O-O-O
o-o-o.
For "en passant", you just indicate the
move and it is correctly parsed ex: "d7-d5 e5xd6"
or "d5 e6 ep"
Promotion is indicated with the "=" sign followed by
the new piece name. So you just write "a7-a8=Q" or
"d8=K". If you omit the piece name, promotion is
made to Queen by default; so "a8=" is equivalent to
"a8=Q".
Note: If the "=" is absent the promotion is assumed
to be queen. (i.e. Ph2h1 will result in a
promotion to Queen.)
result strings:
result strings are used to signify the end of a
game when more than one game occurs in the input
file. Result strings can be one of the following:
1-0 1:0 1/2 1/2-1/2 0-1 0:1 1:1 1-1
The 1:1 and 1-1 are used when game outcome is
unknown.
move numbers:
move numbers are in the form 23 or 36. The full
point is optional. Move numbers are checked against
internal move counter and are optional.
comments:
chess codified comments can be put in the input.
There are two ways or doing so. The first one is to
use the usual chess notation !?, !, ,+, ++, #, ep,
etc ... However, international magazines use other
no-ascii symbols : triangles, squares, infinity and
so on. You can have these symbols on LaTeX and
Walker Font postscript output. (See symboles.txt for
definitons.)
text:
plain text, such as explanations etc... must be
enclosed in brackets or parenthesis [Here Karpov
made a very bright move ...] (this is also a com-
ment). Comments are not parsed, but directly
inserted in the output, for the ascii, nroff, ps and
latex drivers. The characters ']' '[' '(' and ')'
may be placed in the text as long as they are
balanced.
Comments in []'s have an automatic newline appended and
comments in ()'s have a newline appended and prefixed.
Note: For LaTeX and Walker Font postscript the leading and
trailing []'s or ()'s are removed.
e.g.
(What a great move (I think anyway))
results in
What a great move (I think anyway)
variations:
You can have variations in the source. Variation
are in enclosing { } . You can have up to three
level of variation. It would be enough for human
players. A variation always follows the move. Here
is an exemple of variation : 25. Rb2 { Ce4 de4 26
Fc3 Fa3! 27. Ff6 Tb3 } Fa3!
pgn strings:
Portable Game Notation (PGN) strings have special
meaing under certain drivers. Check driver details
for more information.
PGN Strings:
[Event "Event info"]
[Site "Site info"]
[Date "yyyy.mm.dd"]
[Round "round number"]
[White "White player"]
[Black "Black player"]
[Result "Result string"]
For ChessArc compatibility, the following string
has been added and is treated similar to PGN strings
[Comment "comment"]
Note: The double quote (") characters are part of the
PGN string.
keywords:
You can insert keywords in the input text to pre-
cisely define what you want: displaying the board,
configuring it... Keywords are detailled in the next
section.
KEYWORDS
all keywords are prefixed with @
@startplay
begins the play. Obligatory after a @configxxx key-
word.
@clearboard
clears the board. Used prior to any @configxxx.
@showboard
displays the board. Can be used anywhere
@whitesmove
tells the program that is the white's turn of play.
Useful after a @configxxx and @startplay
@blacksmove
tells the program that it is black's turn
@configwhite
initializes configuration of white side. Pieces are
then expected, in form of (optional for Pawn) name,
the position. Example @configwhite Ke3 Rg8 e4.
Note: It is currently possible to setup invalid
positions. This may cause serious problems
with the cm and zarkov drivers.
@configblack
initializes configuration of black side. Pieces are
then expected, in form of (optional for Pawn) name,
the position. Example: @configblack Ka8 Nf6 e6.
Note: It is currently possible to setup invalid
positions. This may cause serious problems
with the cm and zarkov drivers.
@default
resets the board to the default start configuration.
@special all following text up to the next cariage
return is not processed, but instead directly print.
This allows to insert comments in ascii files, or
tex commands when tex output is selected.
@null null keyword. Does nothing. Used for convenience in
programming.
See the file keywords.ntn for an example of keywords
use.
NATIONAL LANGUAGES
Here are the symbols used in the differents languages.
Pieces in () are optional in the input.
english-name King Queen Rook Bishop Knight Pawn
english K Q R B N (P)
french R D T F C (P)
italian R D T A C (P)
spanish R D T A C (P)
german K D T L S (B)
dutch K D T L P (O)
czech K D V S J (P)
hungarian K V B F H (G)
polish K H W G S (P)
romanian R D T N C (P)
FIDE K D T S N (P)
danish K D T L S (P)
estonian K L V O R (P)
finnish K D T L R (P)
norwegian K D T L S (P)
portuguese R D T L S (P)
swedish K D T L S (P)
DRIVERS
ascii this is the default driver, it outputs moves,
boards, and comments. PGN strings are treated
exactly as comments.
postscript
It generates a file using the font file Cheq
licensed for free by Adobe. It is only able to
display one board per run. Moves are NOT displayed.
You need the font "Cheq", freely distributed by
Adobe. Send a mail to "ps-file-server@adobe.com"
with the body "send Programs chessfont.ps".
ps
Postscript output using the Walker Font.
Not limited to just boards but column display does
not work. The Walker font is available at
valkyries.andrew.cmu.edu (128.2.232.4) with the path
/pub/chess/Unix/Chessfont.sh (Shell archive)
tex This is a latex driver. It uses the TeX/LaTeX
chess macros designed by Piet Tutalaers
"rcpt@urc.tue.nl". The complete distribution is
available on sol.cs.ruu.nl (131.211.80.5) with path
TEX/chess.tar.Z. Refer to your local latex guru to
install it.
roff This is a driver for nroff output. It is crude,
but it works. Moves and boards are displayed.
xchess This driver generates compatible xchess/xboard
save files, thus allowing you to replay a game with
xchess.
gnu This driver generates "bare" output, with only the
algebraic move. It is suitable for any low-level
analyser, such as gnuan.
cm This driver allows an input game to be converted to
ChessMaster save format. It only excepts the first
game in the input file. An output file should be
specified as redirecting stdout will NOT work due to
the nature of the output file. PGN strings can be
used to set data fields in the outfile.
The Event string will be the game name as appears in
the ChessMaster load game selection list. The White
and Black strings will set the appropriate fields.
Position setup and continuation are also allowable.
The naming of the output file is important. For the
ChessMaster 2100 (CM2100) saved game file names
are in the form "cmgame??.???" where ? is a letter
(and maybe a number?).
e.g. A valid CM2100 file name is: cmgameaa.aaa
However, if the file cmgameaa.aaa already exists
it will be over written. Check your saved game
filenames before selecting an output filename.
zarkov This driver allows an input game to be converted
to Zarkov save format. It only excepts the first
game in the input file. An output file should be
specified as redirecting stdout will not work due to
the nature of the output file. Position set and
continuation are also allowable.
pgn This dirver outputs games in Portable Game Notation
(PGN) format defined by Steven J. Edwards.
All comments (expect PGN strings), variations, board
display commands are surpressed.
EXAMPLES
Try the following commands:
chessprn algebraic.txt
this will read the Karpov-Kasparov game 13 (Lyon
1990) in algebraic form, display move in shortened
algebraic and display board at end of game.
chessprn algebraic.txt -s
this will do the same thing, as -a stands for alge-
braic output.
chessprn algebraic.txt -a -column
the game will now be output in full-length algebraic
im column form
chessprn shortalg.txt
there is no problem to read shortened algebraic.
chessprn shortalg.ntn -s -o result
the moves and board will be directed to file result
chessprn shortalg.ntn -s -t french
output will use french notation
chessprn a_dutch_file -f dutch -t spanish
game will be translated form dutch to spanish
chessprn shortalg.ntn -c 2
board after move 2 will be displayed, along with
moves and end-of-game board
chessprn shortalg.ntn -e 2
board after move 2 will be displayed, along with
moves. The program will then stops
chessprn shortalg.ntn -c 2,5,20
board after moves 2, 5 and 20 will be displayed,
along with moves and end-of-game board
chessprn shortalg.ntn -c 2,5,20 -b
board after moves 2, 5 and 20 will be displayed,
with end-of-game board, but no moves.
chessprn shortalg.ntn -c 9 -d tex
the output will be formatted to use with latex. You
can directly latex the output file.
chessprn shortalg.ntn -c 2,5,20 -d gnu -o out.gnu
you can now replay the game by using xchess -r
out.gnu.
chessprn shortalg.ntn -e 5 -d postscript -o out.ps
Now issue cat lib/Cheq out.ps | lpr to display on a
Laser Printer the board at move 5. You can also
issue sh print-ps out-ps. The postcript driver does
not support the -c option.
chessprn shortalg.ntn -c 9 -d ps -o fred.ps
Now issue cat Font fred.ps | lpr to display on a
Laser Printer the game with boards at move 9 and
at end of game.
chessprn boudy.ntn -d tex -o boudy.tex
This is the all-star, all-singing demonstration of
the chessprn program. Run latex on boudy.tex and
print result.
FILES
algebraic.ntn shortalg.ntn keywords.ntn boudy.ntn
these are examples of input files
chesssym.tex
This is the LaTeX file containing the definitions
of the codified comment. You can include it in your
own LaTeX files: you will be able to use the chess
comments. The file is stand-alone. To include comment
in LaTeX, just type \COM<three letter name>. For
instance \COMwsb inserts the symbol for "whites
stands lightly better".
chesssym.txt
explanation of codified comments
convsym.txt
used to produce chesssym.txt
($LIBDIR/)HELPFILE
this is the on-line helpfile
($LIBDIR/) Cheq Header.ps Footer.ps
these files are needed by the postscript driver
($LIBDIR/)Header.tex
these file is needed by the (la)tex driver
COMMENTS
The program is quite large, due to the extensive use of
tables and variables to control its features. The advantage
is you only need the modify these tables to customize it:
for instance adding a new language or tuning the output for-
mat to your own needs.
BUGS
The postscript driver *might* fail if you try to display the
board two times. Anyway, it is not designed to do this. Use
-e option to specify the move at which you want to display
board.
Do not enter two levels of variation without any move
between them. It will cause the crash of the program. For
instance, { { is wrong, but { Qd1 { is correct.
Illegal Positions are allowed to be setup.
King having moved before castling not checked.
En Passant move to avoid mate not checked.
AUTHOR
Original Notation Author:
Henry Thomas IRISA-Rennes, FRANCE. E-mail to
Henry.Thomas@irisa.fr or hthomas@irisa.fr up to version 4.7.
ChessPrn:
Extensively modified by Ed Maillet.
E-Mail: ip05872@portland.maine.edu or
maillet@golem.usmcs.maine.edu
THANKS
Henry Thomas:
Thanks to Jacques Schuurman for the piece names in Dutch,
Philippe Louarn for explaining me some TeX tricks, Lael for
czech, hungarian, polish, romanian and FIDE piece names, to
Steven Young. Thank also to Brian Molinari, Markus Geltz and
Jose Esquer Ruiz for pointing me to bugs Most of all, thank
to Jean-Luc Scharbarg for introducing me to chess.
Ed Maillet:
Thanks to Henry Thomas for versions 0.0 to 4.7 of Notation.
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.