21 May 2015

The Engines' Value of Castling

While archiving old support files on my hard drive, I found a strange PGN file and a related spreadsheet. 'What were those for?', I wondered, and used the files' datestamps to relate them to an unfinished post, The Value of Castling (August 2013). That post included a useful summary:-

1.0 - Value of castling : Where '1.0' is the well-known value of a Pawn. Ever since encountering that statement by GM Kaufman, I've wondered if there was any way to verify it. I've also wondered about the value of castling O-O as opposed to O-O-O. Armed with the three variations at the beginning of this post, I can plug the resulting positions into an engine and record the results.

Those three variations had afterwards expanded to 16, all of them using different paths to reach the position shown in the following diagram.


1.e4 e5

The 16 variations lead to different combinations of castling in the diagram -- (1) Both sides [i.e. wings: Kingside O-O & Queenside O-O-O] possible, (2) No O-O possible, (3) No O-O-O, and (4) Neither side possible -- for both White and Black. For example, the variation 1.e4 e5 2.Nf3 Nf6 3.Rg1 Ng8 4.Rh1 Nf6 5.Ng1 Ng8 leads to the diagram with White unable to castle O-O, but with Black retaining the option of castling to either side.

After constructing the 16 variations, I ran three engines -- Houdini, Komodo, and Stockfish -- on each of the resulting positions and recorded their evaluations after 15 ply had been reached. None of these engines is the most recent version -- I acquired all of them in the period 2013-2014 -- but that isn't important for this exercise.

The results are shown in the following table. White's four castling options are in rows 3 to 6, Black's are in columns B to E. Values are rounded off to a single decimal place. I know it's hard to read, but that's life. The many data points -- 16 variations x 3 engines -- handled manually mean there is potential for error. On top of that, 15 ply for Stockfish is perhaps not enough. If I ever redo the table, I'll make it more readable.

As an example to explain the data, cell B3 shows the results after the normal 1.e4 e5. The cell says,

H:0.1, K:0.2, S:0.3

meaning 'H' (Houdini) evaluated the position at 0.1, 'K' at 0.2, and 'S' at 0.3. Cell E3 shows the results where White retains both castling options, but Black has neither.

H:0.8, K:0.6, S:1.2

The results here are somewhat less than the hypothetical '1.0 - Value of castling', but are significantly greater than most of the other cells. Only cell E5, which is like E3 where White has lost the O-O-O option, comes close.

Note that four cells -- B4, D4, B6, & D6 -- contain '(*)'. This is to flag an anomaly I encountered during my investigation. Before, I explain it, let's make a brief detour.

I use all three engines in my chess research and have often noticed that they treat triple repetition differently. Houdini declares a repetition (value 0.00) after both moves of a pair repeat a position. That means if a move, e.g. 30.Nf3, repeats a position for White the repetition is confirmed if Black's next move, e.g. 30...Nf6, also repeats the position. Komodo and Stockfish declare a repetition after a single move repeats the position. Using the same example, they would assign a value of 0.00 to 30.Nf3, and stop calculating the line.

Getting back to the four cells (B4 etc.) Houdini calculated a negative value in all four, indicating that Black has the advantage. Komodo and Stockfish both assigned value 0.00, because they noticed that White could repeat a previous position and stopped there. A particularly surprising example is cell B6, 1.e4 e5 2.Ke2 Nf6 3.Ke1 Ng8, where White has lost both castling options, while Black retains them. K & S saw that White could play 4.Ke2(!), repeating the position, and then stopped without giving Black the chance to play something other than 4...Nf6.

In all of these '(*)' situations, I recorded the first non-zero value given by the engine to its second or third choice. Even with this tweak, Komodo still gave near-equality to White.

What does all of this show? First, that castling is indeed a valuable weapon to possess. Second, that O-O is valued significantly higher than O-O-O. It might be useful to extend this investigation to the full family of chess960 start positions, but that will have to wait for another time.

No comments: