Saturday, March 14, 2015

PGN Game Insertion With OoChess

The OoChess Template has a handy helper program that converts a PGN file into nicely formatted game(s) that are then inserted into the Writer document at the cursor. Inserting a PGN file is actually a two-stage process. In the first stage, the PGN file is read by the helper program to generate a list of the games that are in the file so that they can be displayed in the Insert PGN Dialog. In the second stage, the Dialog is presented to the user allowing him to select a number of games from the PGN file and to set a number of formatting options. Once the game(s) and the options have been set, the user can press the OK button to complete the insertion process.

To begin, click on the Insert PGN Icon on the Chess Insertion Toolbar:


Find the PGN file you wish to have inserted into your document, and then click Open. You will see a brief flash of a black window on the screen. Don't worry, This is the OoChess helper program. It is a simple Console program written in C. After a PGN file is selected, it gets called to generate a list of all the games in the file so that it can be used by the Insert PGN Dialog which appears next:



In the Dialog, you can see the games in the PGN file listed at the top. You can click on any one of these games to select it, or you can hold down the Ctrl key while you click on several games for selection. If you want all of the games, simply click on any one game, and then press Ctrl-A.

Under the game list, you'll find several options that allow you to control the appearance and formatting of the games. They are organized into five main groups: Game, Moves, Diagrams, Information and Text Font. (Information refers to the game's information, essentially the data you can see listed in the games list itself.)

We'll start with the Text Font section.

Text Font Section


This section allows you to select a font and a font size to use for the text of the PGN game to be inserted.


Initially, there are only four fonts available: Times New Roman, Polatino Linotype, Calibri and Gisha. If you have a font that you would like to use that is not in the list, simply type its name into the font-selector, say for example Georgia, and that font will be accepted and used. Any font name that you type in yourself will be remembered for the duration of your editing session and will be added to the list of available fonts. (It is also possible to modify the Basic code of the template to permanently add any font that you would like. For more on this, read the manual.)

 Moves Section


The Moves section refers to the formatting of the moves in the games inserted from the PGN file. When Bold is selected, only true game moves are written in bold, not variation moves. So you might ed up with something like this:

1 d4 Nf6 2 c4 e6 3 Nf3 b6 4 g3
4 a3 is the Petrosian System. It's usually countered with 4... d5.
4... Bb7 5 Bg2 Be7

Bold game moves are almost mandatory using the Modern Game Format Style (described below.)

When Figurines is selected, all the moves will be set to use chess-piece like Figurines, characters that look just like the chess piece itself. Here is an example:






The Period option determines whether a period is written after each game move number. When checked, you'll get this:

1. d4 Nf6 2. c4 e6 3. Nf3 b6 4. g3

Diagrams Section

 

This section refers only to diagrams generated from within the games inserted from the PGN file.

The Number option sets the initial value for diagram numbering. You can have diagrams automatically generated for you by the OoChess helper program. After each diagram is generated, the number is incremented for the next diagram. If you don't want to have your diagrams numbered, then simply set the value to zero to disable diagram numbering altogether.

Diagram numbers are written above the diagram itself. You can see an example of this in Captions below.

Reset Number: It may not be very useful to have all the diagrams of your inserted games number from, say 1, to the number of the very last diagram in the last game. What if you wanted to refer to the first diagram from within one of your later games but you didn't know its actual number? You could easily edit the document after the insertion, but that would be tedious. When the Reset Number is checked, after each game from the PGN file is inserted into your document, the Diagram Number counter (see above) is reset back to 1. Thus, every game's diagrams begin from 1 on, making it much easier to refer to any particular diagram from within the game.

Captions determines whether the OoChess helper program should write a caption under each diagram it creates, as in this example:

No. 1


Position after 3... b6

The diagram caption itself uses the last move played in the game. Notice in the above example that the move is preceded by the introductory text, Position after. (Note also that the game number is also preceded by some text, No. 1) You can set whatever text you want to use with both the game number and the diagram caption using a special format option string. See the section of the manual dealing with The OoChess Configuration File.

Cap Size, quite naturally, determines the test size to use for the diagram captions. You can choose a text size of 8, 10, 12 and 14.

Game Section

 

This section refers to the overall formatting of games inserted from the PGN file.

Number sets the initial value for game numbering. The first game to be inserted into your document gets this number. After each game is inserted, the number is incremented for the next game. This is convenient if you wish to refer to the games in your document by number.

The Format Style option determines the overall formatting of your inserted games. There are three options: Traditional, Classical and Modern.

Most chess books and magazines written today use the Traditional style to format their games. This seems to be the best for most games that have textual commentary interspersed with variations. It is a tidy format that is economical with space. The second, Classical style, was widely used in earlier years, before the 1980's, and is still sometimes used today, but infrequently. It uses columns for the game moves. This style should only really be used with at least a 2-column page, never with a single column as it would be a terrible waste of space. The last style, Modern style, is really only appropriate for sparsely annotated games, or games that exclusively use international chess symbols for annotations. A very good example of this are the books published by Informant. Notice that with the Modern style, it is all but mandatory to use Bold Game Moves in order to distinguish the actual game moves from all the surrounding variations.

An example of each of these three styles can be seen in the manual.

Information Section


This section refers to the formatting of the general information of the games inserted from the PGN file. The information is taken from the PGN Tags for each game. These Tags provide game information such as player names, date, event, site, round and game result (and still more.)

Size determines the text size to use when writing the game information. You can choose a text size of 8, 10, 12 and 14.

You can choose to have your game information written in a nice and tidy box, complete with border, or you can have the information written plain and simple. If you want the InfoBox, then check this option on.

An example of the InfoBox:


Here is an example of the game information without the InfoBox:

Game 1
Fischer, R GM - Camara  IM
Siegen Olympiad R3
Siegen, 1970


The Width option allows you to control the width of the InfoBox as a percentage of the width of the page or column in which the game is inserted. You can set a value between 50 to 100 percent of the width.

Any value you set for the Width will only be used if you have also checked the InfoBox option itself.

InfoBox Border allows you to select a border for the InfoBox, assuming that you have also checked that option. You have two choices here: Single, which you can see above, or Double.

Additional Parameters Passed to OoChess, the Helper Program

 

It's important to note that the current state of most of the options that are available from the Chess Toolbar are passed to the helper program along with the PGN file that you want to insert. This means that whatever your last chosen diagram or figurine font, board size, border style, selected language and 'flip' state was, these will be used in the formatting of the PGN file.

Along with the above set of chess state variables, the helper program is also sent page metric information taken from the current cursor position, such as page width and height, page margins, columns, etc. All this information is used by the helper program when generating the formatting of the material to be inserted into your document.

The helper program also reads a configuration file each time it is called upon to format a PGN file for insertion. This configuration file has a number of options that let the user tailor the formatting to meet his own requirements. The configuration file is an easily editable text file with easy to understand options. It will be discussed in the manual and in a later post to the blog.

Generating Diagrams within the PGN


The OoChess helper program can easily generate diagrams from the PGN games. Your chess database software should be able to indicate where diagrams are to be made and include that information in your PGN files. If this does not prove to be the case, then see the manual to learn how you can do this yourself.

The FENCap


There is one special form of PGN game that we should discuss; that is the PGN game fragment. Such a game does not begin from the initial position, like almost all other games, but from some other position in the middle of the game. These particular games are very valuable in chess books as a method of describing middlegame tactics or techniques, or even endgame positions. Such game fragments are universal in such chess books.

When we encounter a FEN game to be inserted, we will first check to see if the user has declared an of string. (The FENCap string.) If so, we then ignore writing the game info at the top of the game altogether, only writing the game number along with the game info, and then leave the rest to be written under the diagram in the FENCap. A example of a FENCap command is:

of = "*%w – %b*/~%s %y~ %c"

This results in the diagram below.



For all other normal games, that begin at the initial position, the selected info type will be used.

Note that the options available for this command are:

of = "FENCap String"

You can use any of these PGN tags as part of the FENCap string:

%w – White player (Last name only)
%b – Black player (Last name only)
%e – Eventually
%s – Site
%r – Round
%y – Year
%m – Move Number (As in 13... ?)
%c – Color to Move (Shown as a box)






No comments:

Post a Comment