28 November 2010

Another Chess960 Position Generator

Continuing with Chess960 Position Generators on the Web, I decided to adapt one of the existing chess960 position generators to do the job I had in mind. The only real candidate was the tool at Chess-960.org, because it incorporated the notion of a standard numbering system. Fortunately, it used Javascript, making it easy to adapt. On opening the Javascript file, I discovered that it was relatively straightforward, as the chess960 intelligence was coded in the form of IF/THEN tables: 'If position = BQNBNRKR, then ID = 001', or 'If ID = 959, then position = RKRNNQBB'. I could definitely work with that, even with my rusty programming skills.

The main task was to investigate the source of the problem mentioned in Impediments to Chess960 Acceptance. Did I just happen to stumble on the only error in the original code or were there more? I extracted the ID/position equivalences, compared them to my database of SPs, and found a dozen discrepancies. The most obvious error was the assignment of SP000 (BBQNNRKR) to no.960, because the standard numbering scheme starts at 000 and ends at 959. As for the other errors, they were all incorrect ID/position equivalences scattered at random in the IF/THEN tables.

I replaced all the original equivalences with my own, made a few other changes, and added the position generator to my page of Chess960 Start Positions. On top of a working chess960 generator, I have a foundation for any related ideas that might come along.

27 November 2010

Chess960 Position Generators on the Web

The low-tech method to generate a new chess960 start position is well documented on the web and I wrote about it when I set up my Database of Chess960 Start Positions. The low-tech method to determine the numeric value of a start position (SP) is less well known, so I described it in my recent post Calculate SP Numbers in Your Head.

While it's useful to know that you don't need technology to play chess960, it's also useful to rely on that technology when it's available. Generating a random chess960 start position is one obvious example where technology makes the process a lot easier; calculating the equivalent SP number is another. What tools are available on the web to accomplish these tasks? A search on 'chess960 position generator' appears to identify dozens.

The first on Google is the well known FISCHERANDOM CHESS: Random Position Generator at Chessgames.com. Along with a random start position, it returns a FEN string that can be used to create a PGN file to record the moves of a game starting from that position. Unfortunately, as I've mentioned several times, the 'position #' attached to the start position is nonstandard. This means you need a second tool to do the conversion.

A little further down the Google list is the Starting Position Generator at Chess-960.org. Once you discover its quirks (you have to click the 'generator' button before clicking the 'notation' button) it accomplishes the task it's billed to do. Unfortunately, as I pointed out in Impediments to Chess960 Acceptance, the tool has at least a couple of bugs, rendering it unreliable.

Another tool is the Chess 960: Starting Position Generator at Very.co.il. Unfortunately, like the Chessgames.com tool, it ignores the standard chess960 numbering scheme.

Along with these links, Google returns a variety of other tools for different platforms, including at least one calculator. It was hard to believe that nothing did the task I wanted, so I decided to adapt one of them to suit my needs. I'll cover that in another post.

21 November 2010

Calculate SP Numbers in Your Head

When I started writing Who Says 'Chess960 Array'?, my original objective was to show a simple method for determining the number of a chess960 start position (SP) from the arrangement of its pieces, or vice versa,
e.g. to determine that the traditional start position RNBQKBNR is no.518 in chess960 numbering, or that no.534 represents RNBKQBNR (the traditional start position with King and Queen switched),

without using a printed table. Then, as so often happens, I got sidetracked with another issue, this time it was the problem of jargon. In this post, I'll get back on track with the numbering.

1) Start with the KRN sequence

The first thing to notice about chess960 numbering is that the start positions are grouped according to the sequence of Kings, Rooks, and Knights (KRN). For example, the first 96 positions (SP000 through SP095) all have those pieces in the sequence NNRKR, the next group of 96 positions have the sequence NRNKR, and so on. This implies that there are 10 different sequences of KRN, as shown in the following table.

0 NNRKR 000
1 NRNKR 096
2 NRKNR 192
3 NRKRN 288
4 RNNKR 384
5 RNKNR 480
6 RNKRN 576
7 RKNNR 672
8 RKNRN 768
9 RKRNN 864

Although I've given the complete table, I could have derived it with the help of a description. The table starts with the Knights in the first two positions, NNRKR. Each subsequent entry shifts the rightmost Knight one more step to the right. When the right Knight reaches the end, the left Knight shifts one step to the right and the right Knight joins it on its right side. Right? Right!

It's also worth noting that with the left Knight in the first position, the other Knight has four possible positions. With the left Knight in the second position, the other Knight has three positions, and so on -- four, three, two, one. It adds up to ten just like the pins in a bowling alley.

The numbers in that table are for convenience. The left column is a sequence number, while the right column is that sequence number multiplied by 96, the start position of that particular KRN group. [If you have trouble calculating 96 times 5 in your head, remember that 96 is equal to 100 minus 4, so 96 * 5 = (100 - 4) * 5 = 500 - 20 = 480.]

2) Account for the Q

The second thing to notice is that within each group of 96 positions the Queen shifts through the KRN sequence from left to right, one step at a time. This is shown in the following table, where 'xxxxx' stands for one particular KRN sequence.

0 Qxxxxx 00
1 xQxxxx 16
2 xxQxxx 32
3 xxxQxx 48
4 xxxxQx 64
5 xxxxxQ 80

Since there are six possible positions for the Queen and 96 positions in a KRN group, there are 16 different positions with a specific sequence of KRN&Q. Putting this together means that the first 16 of the 960 positions (SP000-SP015) all have the sequence QNNRKR, the second 16 have the sequence NQNRKR (SP016-SP031), and so on.

3) Finish with the Bs

Now the only pieces missing from the start position are the Bishops. Since one Bishop starts on a light square and the other on a dark square, there is no duplication and we have 4 x 4 = 16 unique positions of the Bishops. The sequence is shown on the following table.

00 BBxxxxxx
01 BxxBxxxx
02 BxxxxBxx
03 BxxxxxxB
15 xxxxxxBB

The Bishop table could also be derived from a verbal description. The Bishops start on a1 and b1 (or a8 and b8 for Black). Then the light-squared Bishop shifts to d1, f1, and h1. When the light-squared Bishop reaches h1, the dark squared Bishop shifts to the next dark square on the right, while the light-squared Bishop jumps back to b1, then d1, etc. Combining the Bishop table with the 16 different positions having a specific sequence of KRN&Q gives 16 unique chess960 positions, all pieces present and accounted for.

4) Put it all together

Taking the first chess960 position (SP000) as an example, it is represented by the pieces BBQNNRKR. Its KRN sequence is 'NNRKR', placing it in the first group of 96 positions (SP000-SP095); the Queen is in the sequence 'Qxxxxx', placing it in the first group of 16 positions (SP000-SP015); and the Bishops are in the formation 'BBxxxxxx', placing it first overall (SP000). A similar analysis shows why the position RKRNNQBB is numbered as the last of the 960 positions, SP959.

We can also see why the traditional start position (SP518 RNBQKBNR) and its twin (SP534 RNBKQBNR) are exactly 16 numbers apart. They both share the same KRN sequence, 'RNKNR', and have the same formation of Bishops, xxBxxBxx. Only the start position of the Queen is different -- RNQKNR (xxQxxx) vs. RNKQNR (xxxQxx) -- placing them in adjacent groups of 16 positions.


Here's a practical test. I've noted in the past that the Random Position Generator on Chessgames.com doesn't use the standard chess960 numbering system. It uses instead some proprietary scheme concocted by its software developer. I just accessed the page and it gave me 'position #334' as RQBBKRNN. What would the standard equivalents be?

First, let's take RQBBKRNN. Its KRN sequence is RKRNN, placing it in the last group of 96 positions, starting at SP864. Its Queen position is xQxxxx, placing it in the second group of 16 positions after SP864 (relative positions 16-31). Its Bishops are in the formation xxBBxxxx, making it the sixth position in the group of 16 (relative position 5). Adding these numbers together gives 864 + 16 + 5 = 885, which is indeed the SP number for RQBBKRNN.

Second, let's take 'position #334'? What does that represent in the standard numbering scheme? Dividing 334 by 96 and discarding the remainder gives 3, which places it in the group of 96 positions starting 288, i.e. NRKRN. Subtracting 288 from 334 gives 46; dividing this by 16 and discarding gives 2, which works out to xxQxxx. Subtracting 32 from 46 gives 14, which is the second to last of the Bishop formations, or xxxxxBBx. Combining NRKRN with xxQxxx gives NRQKRN; combining that with xxxxxBBx gives NRQKRBBN. A table lookup confirms that SP334 is indeed the number for position NRQKRBBN.


The title of this post is 'Calculate SP Numbers in Your Head'. Whether or not you can really do this depends on how agile you are with mental arithmetic. I find it helps to jot down the intermediate results -- 864, 16, and 5, as in the first example -- before combining them. The upshot is that if some day you are stranded on a desert island, you will be able to calculate chess960 SP numbers without having a reference table. As helpful as that might be, I suspect that you will have more important things to do on that island than play chess960.

20 November 2010

Who Says 'Chess960 Array'?

A little thing that's always irked me about chess960 is that it takes a big table (*) to derive the start position number from the start position string, e.g. to determine that the traditional start position RNBQKBNR is no.518 in chess960 numbering, or that no.534 represents RNBKQBNR (the traditional start position with King and Queen switched).

I've already demonstrated that a chess960 start position (I'll call it 'SP' for the rest of this post) can be generated without any technology -- see Some Arguments Against Chess960 for the details -- so why should determining the SP number be more complicated? I had already worked out part of a promising method, but was stuck on one point when, as a followup to How *NOT* to Play Chess960, I checked the origin of the term 'array':-

'[Howcast.com video] 0:29 - Step 1: Learn Chess960 terms. "Array" is the initial arrangement of pieces on a board.' • Who says "array"?

There are enough obstacles to promoting chess960 without introducing unnecessary jargon into the explanation. The term 'start position' means the same as 'array' and is immediately understood without defining it.

A search on 'chess960 array' returned my 'How *NOT* to Play' post at position no.3 (proof that the term 'array' is not widely used), the Howcast.com video that was the object of scorn in that post at no.2, and (drum roll...) a Wikipedia page at no.1: Chess960 numbering scheme. This was the source I had expected to find. Wikipedians have done a terrific job of documenting the complete range of human experience, but sometimes they go too far.

The Wikipedia page gave two complicated algorithms to go from SPs to their numbers and vice versa, and it would be impossible to follow the algorithms without referring to the page. I was looking for a method that could be used on a desert island. While that page wasn't the answer, it did provide a helpful clue that solved the point I had missed in searching for a promising method. I'll give that method in another post.

At position no.4 in the search results was a post from Rybkaforum.net, Kasparov on Chess960, etc., which used the term 'array' in a different context:-

[Kasparov] suggests choosing a subset of Fischer Random that would include only natural positions. I have tried to promote a similar idea where, for instance, 25 positions can be selected from the chess960 array

This apparently uses 'array' to mean the complete set of all 960 legal SPs, as opposed to a single SP. Since there is no generally accepted term for this -- I just used the mathematical word 'set' to mean the same thing, but I could have used 'catalog' -- the word 'array' is as good as any.

The Rybkaforum.net post wades into the jargon swamp a bit later when it uses the term 'orthochess' to mean traditional chess. This is another concept that really needs a generally accepted term. I'm in the habit of writing 'SP518 RNBQKBNR' to keep the meaning precise, but I'm sure that very few chess players would understand that shorthand out of context, making it jargon at its worst.


(*) My own table is here: Chess960 [Fischer Random Chess] Start Positions.

14 November 2010

How *NOT* to Play Chess960

No.19 in my list of Top-25 Chess960 Resources (I should have ended that title with a '?') was this gem: How To Play Chess960 [howcast.com]; embedded here:-

How many mistakes can you make in a video that runs less than two minutes?

  • 0:15 - Shows White Bishops on the same color squares.
  • 0:24 - 'You will need ... a computer with Internet access.' • No, you won't. Use the die mentioned at 0:26.
  • 0:29 - 'Step 1: Learn Chess960 terms. "Array" is the initial arrangement of pieces on a board. A "starting piece" is a chess piece that’s part of the initial array.'• Who says "array"? Is that "starting piece" as opposed to "non-starting piece"? Those would be which pieces?
  • 0:40 - 'The "960" in chess960 refers to the 960 possible starting moves in the game.' • No, it doesn't. It refers to the number of possible start positions.
  • 0:47 - 'Step 2: Study a numbered chess board diagram in order to notate chess piece positions.' • Looking at a chess960 diagram is enough. The numbers are irrelevant for setup. What does 'to notate' mean?
  • 1:00 - 'Step 3: Place the Pawns in their traditional board positions'. • Should be preceded by step 2+: Position the board correctly before placing Pawns. ('White on right')
  • 1:05 - 'Step 4: Use online position generators to set up each player's back row.' • Shows the Chessgames.com forum, which uses a non-standard, proprietary system to number the start position. (Although I can't really expect Howcast.com to know that)
  • 1:12 - 'A randomizer might display the Black Knight in the traditional Black Queen position'. • The position doesn't show that. And what holds for Black also holds for White.
  • 1:26 - 'Bishops are on opposite colored squares'. • Shows the same position as at 0:15.
  • 1:33 - 'Step 6: Learn how to castle in chess960'. • Shows White castling O-O while in check.

A few weeks ago I used another Howcast video in How To Use Rybka?!. How many mistakes are in that clip?

13 November 2010

Top-25 Chess960 Resources

I started a recent post, Chess960 Universität, with, 'After writing about chess960 for more than two years I don't know how I could have overlooked a major source of instruction, but so I have.' Have I overlooked anything else of importance? Let's look at the top-25 Google results for 'chess960'.

Two of my own resources occupy two positions in a list of top-25 resources for chess960. Where are Chess.com and Schemingmind.com?

07 November 2010

GM Yusupov : Lesson 1

I ended my previous post, Chess960 Universität, with a promise to look more closely at one of the sample lessons offered by Chess Tigers. Any of the lessons would have been suitable, but I chose IPS 2100: Lektion 1 from 2005, because it is aimed at more expert players (Elo ~2100) and because it is signed by Artur Jussupow, better known to English speakers as GM Artur Yusupov, a candidate for the World Championship in the 1980s.

I used Yusupov's work in a recent post on opening theory -- Yusupov's 'General Principles of Opening Play' -- making it appropriate to examine his thinking about chess960. Lektion 1 (Lesson 1) is titled 'Unprotected Pawns / Weak Points' and starts with the same small table I gave in Undefended Pawns in Chess960 Start Positions, showing the number of start positions with specific counts of undefended Pawns. This is followed by an example game, Bacrot - Lanka, from the 2005 FiNet Open at Chess Classic Mainz (CCM5). The start position is shown in the following diagram.


Here are Yusupov's comments on the first few moves. (I used Google Translate for a basic translation, then cleaned it up based on my own limited understanding of German. It's still a rough translation, but the meaning comes through.)

If we look closer at this start position, we see that the Pg2 and of course its counterpart on g7 are unprotected. These Pawns [Google: 'farmers' (!)] are currently considered weak. Of course, it is not necessary to defend them immediately, but you should not forget them!

1.e4 c5? - 1...e5 would have been better, but Lanka gladly plays the Sicilian defense in traditional chess, and can not resist to achieve this structure here. His reflex move leads to big difficulties.

2.f3! - White now attacks the Pawn on c5 with the Bg1 and at the same time opens the diagonal e1-h4 for his Queen.

2...Bb6? - Overlooks the second and far more serious threat. After the better 2...d6 follows also 3.Qg3 Ng6 4.Bxc5, and if 4...Qb5, White can protect both attacked pieces: 5.Nd3, and it is very questionable whether Black can demonstrate enough compensation for the Pawn.

3.Qg3+ - Wins neatly the Pg7.

Here GM Yusupov ends his analysis of the game. The second example in the lesson is an analysis of the complete game Shirov - Naiditsch from the same event. It starts with SP897 BRKBQRNN, one of four start positions with three undefended Pawns at the beginning.

The first lesson is followed by 39 more lessons. The complete course of 40 lessons is just one of eight courses, ranging from beginner to expert level. Is there a better exposition of chess960 available in any language?

06 November 2010

Chess960 Universität

After writing about chess960 for more than two years I don't know how I could have overlooked a major source of instruction, but so I have. The page Chess Tigers Universität (no translation required, I trust) has lots of links to chess960 instruction mixed in with instruction for Traditionelles Schach (ditto). The lessons are all in German, but with access to Google Language Tools and minimal understanding of the language (which is what I have) the material is there to be perused.

I've written about Chess Tigers before -- use the search box in the right sidebar to find specific posts -- and even if you've never heard about them, you've certainly heard about their annual event Chess Classic Mainz (CCM), where one of the regular participants is World Champion Anand. The lessons date from 2004, and using the explanation at the top of the page, 'Jeder der unten angegebenen Kurse besteht aus 40 Lektionen...' (Google Translate : 'Each of the following courses consists of 40 lessons ...'), we learn that the materials available here are just samples ('Inhalt, Lektion 1, Lektion 2' = 'Content, Lesson 1, Lesson 2').

Some of the lessons are classified by IPS (e.g. 'IPS 1800' for 2004), which is defined in the lessons as 'Individual Player Strength', and which undoubtedly corresponds to the Elo ratings of traditional chess. I poked around the sample lessons, liked what I saw, and will present a snippet in my next post.