Not logged inRybka Chess Community Forum
Up Topic Rybka Support & Discussion / Aquarium / i-Book Tutorial 3: Database-bound articles
- - By Zruty (*****) [ru] Date 2009-03-06 13:08
1. Preface.

As I said in the previous article, Sample Endgame Study, you can write Aquarium i-Book pages in two different ways: database-bound and free.

This article will mostly describe the possibilities of putting database-bound chess information into the page text. I will also touch some other subjects, namely, sections.

For my exercised I selected the 10th round of Linares tournament. I've created a LinaresSample database with 8 games:
1) Grischuk - Ivanchuk commented
2) Anand - Dominguez commented
3) Radjabov - Aronian commented
4) Carlsen - Wang Yue commented
5) Grischuk - Ivanchuk raw
6) Anand - Dominguez raw
7) Radjabov - Aronian raw
8) Carlsen - Wang Yue raw

I'm not trying to give good analysis: all the examples below are intended to show i-Book possibilities :)

2. Loading games from the database.

There are two run-time commands I'm going to tell you about now: load_game() and set_position().
* load_game(GameID) command loads the corresponding game into the page notation and positions before the 1st move.
* set_position(EPD) searches the corresponding position in the page notation and positions to it. If the position is not found in the page notation, the command does nothing.

These two commands are already enough for simple articles. For example, this page will briefly cover Radjabov-Aronian game:
Example 1:

= Example 1 =
The ["load_game(7)", game] between Radjabov and Aronian was, probably, decided by two inaccuracies in the rook ending: on ["set_position(r3r1k1/1p3pp1/2p5/4p2q/7P/2P1Q1P1/PP3PK1/R3R3 b - -)", 28th move] and  on ["set_position(4r1k1/1p3pp1/2p5/4p1P1/r7/2P3P1/PP3PK1/R3R3 b - -)", 30th move] that gave away the d-file.

After this, Radjabov has converted his one pawn advantage to a win in 26 more moves.


3. OnLoad instructions.

As you might have noticed, there was a 'glitch' in the Sample Endgame Study article: when the article was loaded, the initial position was displayed on the board.

The same problem is present now with our 'Example 1' page: the notation is empty, but it should contain the game we are speaking about.

These problems are both solved by using the 'OnLoad instructions' field in the Page Options dialog. It works as follows:
Any time the reader opens the page, the OnLoad instructions are all performed as if he just clicked the hyperlink with these actions.

This means that you can put any amount of semicolon-separated run-time commands into OnLoad instructions field.
I'm putting the 'load_game(7)' instruction there and saving it as Example 2.

As for the Saavedra position case, I would have to add a new game to the Saavedra database containing the Saavedra position, and put 'load_game(1);set_position(...)' into the OnLoad field. This is because set_position only works when the position is present in the notation.
However, the need for adding a game to the database is an unnecessary limitation, and we'll get rid of it in future Aquarium versions.

4. More complex database-bound commands.

Of course, it isn't very convenient to write 'set_position()' each time I need a positioning hyperlink. The write_line() (see Sample Endgame Study for details on generation commands) command is much more convenient in most cases.

That's why there are database-bound versions of set_line() command:

* db_set_line(anchor,style,gameID) - loads the line from STARTING position of the game #gameID to the position marked by the ANCHOR into the internal game with a selected style.
The anchor mentioned here is a 'long after' type annotation of the form '//anchor_name//'.
* db_set_line_epd(EPD,style,gameID) - same as db_set_line, but uses the EPD of the enidng position instead of anchor. This means that it won't work in some cases (namely, transposition), but it doesn't require alterations to the game.

The gameID parameter must be added to all db_* commands, but it's mostly the same number. So there is ome more generation command: main_game(gameID). Once this command is executed, you may skip the gameID parameter in all db_* commands.

Note that main_game() and load_game() look similar, but they do completely different things! Also, main_game() is a compile-time command, and load_game() is a run-time command.

Now, when we know more database-bound generation commands, I can transform the 'Example 2' article into more convenient form:
Example 3:

= Example 3 =
[main_game(7);db_set_line_epd(4k3/2R5/2p5/1p2K1P1/1P6/2P5/8/r7 b - -,0)]
The ["load_game(7)", game] between Radjabov and Aronian was, probably, decided by two inaccuracies in the rook ending: on ["jump(28...)", 28th move] and on ["jump(30...)", 30th move] that gave away the d-file. Aronian could have avoided the defeat by playing, respectively, [push_line;line(28...Ra5);pop_line] and [push_line;line(30...e4);pop_line].

After this, Radjabov has converted his one pawn advantage to a win in 26 more moves.


5. Combining several games in one article.

What if I want to combine several games in one article? For example, I would like to write an article about all four Linares round 10 games. Now that's easy, right? We just load and display one game, then another one etc.

Wrong. Let's see how this may turn out:
Example 4:

= Example 4 =
== Grischuk - Ivanchuk ==
[main_game(1);db_set_line(main,0)]
These two grandmasters produced a pretty boring ["load_game(5)", draw] in 41 moves. Rybka engine thinks that [push_line;line(24...hxg5);pop_line] gives Black more winning chances than [write_line(24...)], and it also evaluates [write_line(35.)] as an inaccuracy, but the draw was inevitable.

== Anand - Dominguez ==
[main_game(2);db_set_line_epd(3r4/5pkp/1R1P2p1/pp6/8/5PK1/PP5P/8 b - -,0)]
This ["load_game(6)", game] was even more uneventful than the previous one. The last chance for an interesting game disappeared with [write_line(25.)], which caused a cascade of exchanges and left only two rooks on the board at ["jump(32.)", move 32].

== Radjabov - Aronian ==
[main_game(7);db_set_line_epd(4k3/2R5/2p5/1p2K1P1/1P6/2P5/8/r7 b - -,0)]
The ["load_game(7)", game] between Radjabov and Aronian was, probably, decided by two inaccuracies in the rook ending: on ["jump(28...)", 28th move] and on ["jump(30...)", 30th move] that gave away the d-file. Aronian could have avoided the defeat by playing, respectively, [push_line;line(28...Ra5);pop_line] and [push_line;line(30...e4);pop_line].

After this, Radjabov has converted his one pawn advantage to a win in 26 more moves.

== Carlsen - Wang Yue ==
[main_game(4);db_set_line_epd(8/8/8/6pp/4qp1k/2RR3P/3K4/8 w - -,0)]
This ["load_game(8)", game] was dynamic and interesting, with Carlsen first blundered with [write_line(29)], allowing Black to chase his king: [write_line(29...,32...)], but then Wang Yue almost gave it away with [write_line(34...)].

Carlsen, hovewer, couldn't find the drawing continuation with [push_line;line(38.Qd7);pop_line], and played [write_line(38.)] instead, which allowed Wang Yue to force profitable exchanges and led to an opening won for Black with Queen vs two Rooks: [write_line(38...,44.)]


You will easily see what is wrong when you start browsing this example: after a few clicks all the games are joined into one notation, creating an unreadable mess in the notation window, which can only be fixed by refreshing the page.

That's why we implemented sections.

You can define the section the following way:
{section(game1):load_game(5)}
Section text
{endsection}


Then whenever the user clicks the hyperlink located inside the section, he is 'switched' to this section, and the section commands are executed before the link actions. In our case, load_game(5) will be called.

After I enclosed each game into its own section, I've got an article I am satisfied with, an Example 5.

6. Conclusion.

I've pretty much done with the command system for Aquarium i-Book pages.
I'm planning one more article on i-Books, where I'll talk about the classifier, trees, images, book options and editing simplifications that didn't yet make it into the user interface.

Here's the LinaresSample i-Book I created: LinaresSample.rar.
Parent - By riprap (**) [gb] Date 2009-03-06 15:50
Hello Zruty

This is all great stuff.  Perhaps you would be good enough to describe in your next article how to generate HTML from the info - particulary how to combine the games with the text.
Up Topic Rybka Support & Discussion / Aquarium / i-Book Tutorial 3: Database-bound articles

Powered by mwForum 2.27.4 © 1999-2012 Markus Wichitill