Friday, September 23, 2011

New blog location

Please check out my new blog.

Sunday, June 27, 2010

Perl and "booleans"

Note to self:

While the value of

$maybeBooleanResult = (2 == 2);

is

1

as would be expected, the value of

$maybeBooleanResult = (2 == 3);

is

''

rather than

0


This is not what I expected, and caused problems when I was writing code like

print "flag = $maybeBooleanResult\n";

Tuesday, May 11, 2010

Anand retains World Chess Championship title!


He did it! Anand Vishwanathan won the final round (12th) of his match against Veselin Topalov in a thrilling victory as Black (the first time Black won a game in this match, actually), to win the match 6.5-5.5, and retained his world championship title.

Congratulations to Anand for his strong play, and congratulations to both Anand and Topalov for putting on a great show to chess players around the world with their intense, ingenious, and entertaining games, in the best world championship match I have seen in years. Every game was hard-fought, with many implicit draw offers declined. This was one of the great matches in recent chess history.

The game itself started with Anand using the venerable Lasker Defense of the Queen's Gambit Declined, a very solid defense whose goal is to exchange off minor pieces and then free the Queen Bishop with either c5 or e5 to try to achieve equality. A typical late opening position arose after Black played 13...b6:


The plans for both sides are clear out of this opening. White is ahead in development, has more space, has an extra center Pawn (d-Pawn), and will try to pressure Black on the Queen side, especially hitting Black's c-Pawn on the half-open c-file by doubling up Rooks on it, etc. Black, on the other hand, is planning to play c5 and Bb7 to develop by fianchetto his remaining Bishop and make it a powerful force aiming toward White's center (and also King side) along the a8-h1 diagonal.

A few moves later, the character of the middle game became radically transformed:


Anand deliberately allowed himself an isolated c-Pawn in return for getting the Bishop over the Knight. I have to confess that in this position, even though it is equal, I would rather be Black. Black's Bishop can potentially get very powerful. White can try to make progress by trying to win the c-Pawn, but I like Black's Bishop.

The next stage of the game was interesting psychologically. Both sides maneuvered around, with Anand moving his Bishop all over the place, even repeating moves in an implicit offer of a draw. Obviously, he was trying to say to Topalov, "OK, the position seems equal, and I am happy to draw and have the match go to the rapid tie-break match, where I expect to do well, so if you want to win, you might as well vary and take a risk to try to win." Topalov indeed chose to vary, aiming his Rook and Knight at the Queen side, at the expense of moving pieces away from his King side, which is just what Anand wanted, of course! A critical position arose when Anand started an attack on Topalov's center and King side with 30...f5:


The position is still completely equal, and all Topalov had to do was defend his e-Pawn with 31 Nd2. Unfortunately, he decided to open up his own King side to Black's Bishop with 31 exf5? e4 32 fxe4?? Qxe4+ 33 Kh3:


And now, the game was all but over and lost! Unbelievable. I do not understand why Topalov did this. Even without calculating a lot of variations, it must be obvious that White has little to gain from this opening-up of his own King's position. He has a Rook and Knight at the other end of the board that are not useful defenders. The monster Bishop at a8 prevents White's King from ever getting back to g2. Meanwhile, g4 and h5 are completely unprotected and if Black's Queen landed on either square, it would be checkmate already! I can only think that Topalov truly feared going into the rapid playoff match, that he was as good as lost if he didn't complicate this twelfth game, at all costs.

The win for Black is not that easy to find, of course. It took many moves, but Anand did it (he missed several opportunities when he did not play the most decisive continuation, but from a practical point of view, he did not need to, because all he needed to do was find one sure way to win, not necessarily the shortest, possibly more complicated, one). There were a lot of tactical threats involving the perpetual threat of checkmating on g4, and eventually Anand forced the win of material and liquidation into a won endgame, and Topalov resigned:


A brilliant and effective winning attack by Anand, to cap off a fine world championship match!

Sunday, May 9, 2010

Anand-Topalov, Round 11

As White in round 11, the penultimate round of the match, Anand surprised me by using the English. Topalov entered the Reverse Dragon, as might be expected. Personally, I do not like allowing the Reverse Dragon as White. I don't think White gets any advantage, and in fact I'd rather be Black. As White I'd rather try to get some advantage in the opening. But I presume Anand wanted to play safe, and force the game into a slow, positional grind with little chance of wild complications from Topalov. He may have wanted to encourage Topalov to press too hard, and meanwhile he may have been perfectly happy with the plan of drawing his final White game, then drawing his final Black game, and winning the rapid tie-break playoff match. But what if by squandering a possible White win, he loses the match in the final game as Black? He must be pretty confident about holding the draw as Black.

In any case, Anand got into an inferior position as White in the game, gave up a Pawn in the ending, and only by being very precise held the draw as White. I would not have wanted my last game as White to have proceeded in this way. We shall see whether it was a mistake for Anand to go defensive in the late stages of this match.

Saturday, May 8, 2010

"Better player" vs. "one who wins"?

An interview with Kramnik about the Anand-Topalov match has had excerpts translated in English. Nothing he said is surprising or new, but I thought it would as good a time as any to revisit a serious philosophical question, which every sports fan or stock market trader grapples with regularly: in a competitive enterprise, what is the nature of the distinction between someone who is "better" and someone who "wins" often (the implication being that someone could "just" be "lucky")?

Kramnik says that Anand is the "better" player, while Topalov "still has good results even when he doesn't play well." This is a somewhat biased, provocative way of summarizing the objective reality of the records of these two fine, top-level chess players. With computer-aided analysis of chess moves that occur in a game, it is easy to note the number of moments when someone has made a move that is so "bad" that with perfect responses by the opponent, the player should lose where the game should not have been lost otherwise. For example, round 9 was an ideal example of a game in which Topalov repeatedly made errors such that if Anand had played perfectly, Topalov would have lost. This is one way of expressing what it means for someone to not play "well" but still achieve a good result (in this case, a draw). But this is a biased criterion, because one could also say that in this game, it was Anand who did not play "well", because he failed to win when he could have.

A more "objective" criterion could be, summarize the computer-scored evaluations of the positions after each player's moves, and see who has the smallest average evaluation score deviation from the computer's "best" move. By this criterion, Anand might come out the better player in this game, or might not (I have not bothered to do any such computation). But this criterion is still flawed. In many of the games in which Anand drew as Black with the Slav, his "average" deviation might still be lower than Topalov's, because of the use of the passive, defensive opening whose entire goal is to try to "safely" ensure a draw while clawing back from an inferior endgame the whole way; various opening moves would be penalized, even if after the opening phase, Anand started playing many perfect moves. To use a criterion of "deviation" blindly would be to violate the whole spirit of chess, which is that computer scores are not a reflection of some kind of Platonic reality but are a tool for driving choice of a move, a strategy; and different computer engines assign interestingly different scores to the same moves. Different openings result in a different rhythm of how Black deals with White's initial "advantage". Since chess is undoubtedly a draw with best play anyway, the numbers are only a reflection of how well one can see the rest of the game at a given point. Changing the computer's evaluation depth and time limit results in different numbers.

In the end, chess is a sport, a "struggle", as David Bronstein put it. To speak of someone being a "better" player outside the context of proved competitive results again and again does not make sense. Kramnik knows this, of course, so what he is really saying is simply that he prefers to play in a particular way, minimizing the risk of forced loss (against any competitor, including a computer), while Topalov is willing to achieve good results by whatever means necessary, including being more physically and emotionally resilient, playing "bad" moves in order to confuse his human component and hope to swindle a draw or win, avoiding getting into time trouble. This is all part of the struggle.

All of us who play chess know this. I cannot count how many games I have won even though I "should" not have, simply because I stubbornly played on in a lost position and swindled a win. I also cannot count how many games I have lost even though I was winning the whole way and then made errors. Kramnik is basically implying that somehow there should be a notion of "justice" in the chess universe, such that there should be a limit to how much one gets "lucky", and somehow players like Topalov get "lucky" more than they should. I think he is in error in implying that there has to be this notion of justice. Was it fair that the dinosaurs went extinct on the earth while tiny little mammals survived what is thought to have been an asteroid collision? The question does not objectively make that much sense.

My final comment is that I personally prefer the Kramnik or Anand style of chess play to Topalov's. I did not always have this preference, but I grew into it. My best argument for my preference is simply that years ago, when I began appreciating it and adopting it in my own play (toning down the speculative attacks), I not only improved my results but also improved my enjoyment and "understanding" of chess.

There are two more rounds to go for Anand-Topalov. I hope Anand accepts the Nimzo-Indian challenge again as White.

Friday, May 7, 2010

Anand-Topalov, Round 10

Round 10 of the world chess championship match featured Topalov as White against Anand. As I predicted, Anand varied away from the Slav. However, I had not predicted that he would return to the Grünfeld, which he did use in round 1. Anand deviated first, avoiding the variation with 10...Na5 that had deflected his Knight away from the center and left his King vulnerable to Topalov's attack. Instead, Anand just developed normally while Topalov also developed normally, building up the classic center, resulting in a typical position:


The typical Grünfeld game, when it does not erupt in White embarking on a sacrificial attack on Black's King (which is no longer protected by a Knight because it was exchanged early on c3), winds up going into an endgame dictated by both sides' Pawn structures. White's advantage is having the center d-Pawn and center e-Pawn, particularly the d-Pawn, which Black lacks and therefore can often be pushed all the way to d8, possibly with an exchange of both sides' e-Pawns along the way. The d-Pawn is so key that it was given a mnemonic nickname, "Delroy", by Jonathan Rowson in his wonderful book Understanding the Grünfeld (which I can't believe is out of print at the moment of this post).

Black's advantage is the Queen side majority of the a-Pawn and b-Pawn against White's lone a-Pawn. White's Queen side is loose and weak because of not having a b-Pawn or c-Pawn. Black may end up pushing the b-Pawn all the way.

Topalov quickly got things going by committing to 15 d5, an advance of Delroy. After some inaccuracy by Anand, Topalov got an advantageous position and Anand chose to bail out into an inferior but drawable endgame:


One of the pleasures and mysteries of chess is how one can very often look at a real position and know instantly what opening was played. Here, with Delroy on d5, who would not guess that a Grünfeld was played? The problem in this particular position is that White has the two Bishops. Black has to be very careful not to let a breakthrough happen to either his Queen side Pawns or King side Pawns. As it turned out, Anand defended very well, and after some inaccuracy by Topalov, made the drawn outcome clear by the time this position was achieved:


White has gotten nowhere on the King side, White's King is centralized but has nowhere else to go, Black has blockaded Delroy with his Bishop on d6, Black's a-Pawn and b-Pawn are safely advanced, and finally, White's dark-squared Bishop is completely neutralized by Black's dominating Knight. After Anand's 48...Ba3, trading off that Bishop, the draw was obvious, because he could (and did) go for either White's a-Pawn or d-Pawn to liquidate all of White's winning chances.

The slightly weird thing to me is how Topalov seems to let his Bishops get pushed back to passivity by Knights. We saw this position in round 5:


These kinds of positions were never forced on Topalov. He entered them voluntarily despite their inferiority. Strange. I wonder whether he has been told about his habit, and whether Anand knows about it.

In any case, the match is still tied, and since Anand defended in this game without trouble, I think Topalov's momentum is stopped, and I give them fully even chances for the title. There are only two regular games left, and then if the match is still tied,  there is a tie-break match of rapid games. Now Anand has a fierce reputation for rapid chess, so perhaps if it comes to a tie-break, he has the advantage, but I don't know if that is necessarily the case. They wouldn't be playing a fresh rapid match, but would be playing it after being fatigued from twelve regular games. I don't know who would be more fatigued. So I wouldn't make any predictions right now.

Thursday, May 6, 2010

Anand-Topalov, Round 9

I expected Round 9 to be a tough fight, because with the match tied so far, and only four more rounds to go, there were not many more chances to play hard for a win.

As I suspected he might, Anand gave up on the Catalan and decided to invite the Nimzo-Indian, and Topalov took him up on the challenge. The Nimzo-Indian is a good choice for either White or Black to play for a win, because in almost all variations, there are clear imbalances, primarily of White obtaining the Bishop pair and Black having a sounder Pawn structure. Anand played the classic Rubinstein variation, and Topalov played what I suppose we could call the Karpov variation, simply because Karpov made it his primary defense as Black back in the day.

The following thematic position arose out of the opening:


But in the space of a few moves, Anand "allowed" Topalov to obtain a very unusual middlegame, in which Topalov gave up his two Rooks for Anand's Queen:


What is important to realize is that even though your favorite chess engine (I prefer Rybka and Stockfish) might think the game is now dead equal, in the hands of human beings, there is a huge amount of play left. Also, personally I would much rather be White in this kind of position, because I think it is White's game to lose. Two Rooks, if made to work together, would be much more dangerous against the opponent's King than one Queen. On the other hand, one Queen can be very effective in forcing a draw with perpetual check, if the opponent's King is too exposed. Therefore, if I were White, I would try to get my pieces to work together (not get accidentally forked or something by the Queen) and checkmate Black, while keeping my King safe. Black's practical task is much harder. Black's only way to win, really, is to somehow create a Queenside passed Pawn and promote it. In other words, whereas White to win has to finish Black off before an endgame happens (by checkmating or by winning material as a result of checkmating threats), Black to win has to protect the King and reduce White's checkmating capabilities and enter an endgame in which somehow Queening the a-Pawn or b-Pawn occurs. These are the structural constraints implied by this position.

The following position, only a few moves after the Queen/Rooks trade above, illustrates more starkly the dangers for both sides:


Both sides have played well, and Black is trying to trade off White's dangerous two Bishops, and also is aggressively aiming his Queen at White's isolated a-Pawn and d-Pawn. Note that Black's aggression with the Queen does leave his King less well defended, however.

After some less than perfect play, in which Topalov mistakenly grabbed White's d-Pawn, the following position arose:


At this point, Anand started going astray, undoubtedly partly because of time pressure. He may have felt (correctly) that the win was within his grasp, but could not decide how to follow through. Instead of something like 33 Nxe6 (followed by f4) or the "obvious" 34 Rc8+ (followed by Rec1), he played the terrible 33 Ne4, allowing Topalov to painlessly take the a-Pawn, and a new phase of the game began, in which Black's King was still in danger, but Black also has a connected pair of passed Pawns, that given a huge amount of time, could become a Queening threat.

Sadly, in the rest of the game, Anand repeatedly could not find the best moves at many points (one has to understand how many hours this game took to complete, and how the burden of proof of the win always lay with White), Topalov repeatedly made some blunders that should have resulted in a loss, and finally, the game was drawn, by perpetual check.

Here is one of the won positions Anand had (in which Topalov had sacrificed a Knight for swindling possibilities):


Anand seemed at a loss in this position, and in time pressure and probably extreme fatigue, shuffled his Rooks around, allowing Topalov to keep on pushing his Pawns, until Anand had to give up his Knight for the Queened b-Pawn, and then when he won the a-Pawn by taking with the wrong Rook (!), the position was a dead draw with obvious perpetual checks on White's King, which has no hiding place:


A very tiring and exciting game! Much could be said about the errors by both players, but these wide-open positions with two Rooks against a Queen are extremely difficult for human beings (with constraints of time and energy) to calculate out perfectly. Computers can "see" the truth of these positions in a split second, but what we're watching is human chess, not computer chess.

So, three more rounds to go. I stand by my assertion (before this round) that Topalov has an advantage. Anand cannot be feeling happy that he expended so much energy failing repeatedly to find a win in won positions, and he has only one White left. Topalov must be unhappy that he repeatedly played losing moves, but he got his draw, after all, and has two Whites left, so I would expect that he is less unhappy than Anand. What next? I imagine that Topalov would be pleased to try again to smother Anand's Slav defense, since he succeeded the last time. Furthermore, Anand may feel that he needs to get out of his "passive as Black" mode anyway, and avoid the Slav. It would be very exciting, but risky, if Anand decided to play the Semi-Slav and allow Topalov to go into the Anti-Moscow gambit. Or perhaps he too could go for a dynamic Nimzo-Indian or Queen's Indian? One thing I'm fairly confident of: Topalov will try to play some kind of gambit in the next round against whatever Anand plays!