Archive for February, 2010


KO Semifinal

February 26, 2010

I drew white in our toss for colour. Replay the game here.

1. e4 c6 2. d4 d5 3. Nc3 dxe4 4. Nxe4 Nf6 5. Nxf6+ gxf6 6. Nf3 Bg4 7. Be2 e6 8. Be3 Bd6 9. Qd2 Nd7 10. O-O-O Qe7 11. h3 Bh5 12. Kb1 Bb4 13. c3 Ba5 14. Rhe1 b5 15. g4 Bg6+ 16. Bd3 Nb6 17. Qc2 Nd5 18. Nd2 O-O 19. f4 b4
Unlike in our previous game where I was surprised by 4…Nf6, I was better prepared for it. Surprisingly, given my opponent’s much higher rating, I have played very natural moves until this point and that’s been enough to leave me with a sizeable advantage. In the race between our pawn storms, white seems to be quicker!

20. f5! bxc3 21. fxg6!
Even before my twentieth move, I looked at this position and whether I could play 21. Nb3 instead. I saw the continuation 21… Nb4! 22. Qxc3 Nxd3 23. Qxa5 (Nxa5) Nxe1 24. Rxe1 exf5 25. Bh6 Qd7 26. Bxf8 Rxf8 (Kxf8) and the position is equal. After the game, my opponent said he hadn’t seen Nb4 – but I couldn’t take that chance!

21… cxd2 22. gxh7+ Kh8 23. Bxd2 Bb6 24. Qa4
(24. Qc4)

24… Rab8 25. h4 Bc7 26. g5?
Fritz evaluates this position as approximately +2.3, so I am obviously doing quite well. The only thing I need to do is to keep playing sensibly – and the most sensible thing to do is to get my king out of the open b-file as well as the impending fork of the king and queen if the black knight lands on c3.

26… fxg5 27. hxg5 Bf4 28. b3??
White still retains a small advantage after 28. Ka1 Bxg5 29. Bxg5 Qxg5 30. Re5 Qg4

28… Bxd2 29. Rxd2 Nc3+ 0-1


Finally, a win this year

February 6, 2010

It was a weird experience. Playing in a league match, the opposing team’s top board (who I was playing) was ranked lower than our board 5. Despite that, our game should have really been a draw but I squeaked by with a win in time trouble and we won the match 4-1. The game can be replayed here (I was black).

1. e4 c5 2. Nf3 d6 3. d4 cxd4 4. Nxd4 Nf6 5. Nc3 a6 6. Bg5 e6 7. Bxf6 Qxf6 8. g3 Nc6 9. Nxc6 bxc6 10. Bg2 d5 11. exd5 cxd5 12. Qf3 Qd8 13. a3 Be7 14. O-O O-O 15. Rfd1 Qc7
The opening has been quite dry and I was trying my best to keep as many pieces on the board and try and outplay my opponent. Here, I initially thought that he might be able to play 16. Rxd5?!. I run into trouble after 16… exd5 17. Nxd5 Bb7 but then realized that 16… Bb7 17. Rd7 Qxd7 18. Qxb7 and black is better.
16. h4 Rb8 17. Rab1 Bb7 18. Qe2 Bc5
I debated between the text move and 18… Bf6, unsure as to which diagonal the bishop should sit on.
19. Qd3 Rfc8 20. Ne2 Qb6 21. Rf1 a5 22. Qd2 Ba6 23. c3 Qc7
23… a4! never crossed my mind, but it fixes white’s pawns and gives me concrete targets to aim at. From this point on, my opponent loses the thread a bit, letting his pieces stay passive and allowing me to improve my position.
24. b4? Ba7 25. Kh1 Bxe2 26. Qxe2 Qxc3 27. Qb2 axb4 28. axb4 g6 29. Rfc1 Qxb2 30. Rxc8+ Rxc8 31. Rxb2 Kg7 32. b5 Bd4 33. Rd2 Rc4 34. Bf1 Rb4 35. Kg2 Kf6 36. Rd1 e5 37. Be2 h5 38. f3 Rb2 39. Kf1 Ke6 40. f4 Be3 41. fxe5 Kxe5 42. Ke1 Ke4 43. Kf1 f5 44. Rd3 f4?
44… d4 was probably better, not yet allowing the bishop check on d3, as happens later in the game.
45. gxf4 Bxf4 46. Rd1 d4?
And this is definitely an error, and now the position is a dead draw! 46… Rb3, not allowing Bd3+ was needed.
47. Bd3+! Kf3 48. Bxg6 Rxb5 49. Bxh5+??
My opponent now commits a fatal blunder, in deep time trouble – he was down to less than a minute by this point. 49. Rxd4 maintains the equilibrium.
49… Rxh5 50. Rxd4 Rxh4 51. Rd3+ Be3 0-1
Mate follows.

Lost on the 6th move

February 6, 2010

That’s what happened to me a week ago. I have played the same opponent 4 times before, but each time with black(here, here, here, and here). I was feeling optimistic that I would do well with white but fell for an opening trap, as you would have guessed, on the 6th move. I played on for a while longer, hoping for a blunder in return, but my opponent played solidly (as you would expect) and it was soon time to end the misery. Replay the game here.

1. e4 e5 2. Nf3 Nf6 3. Nxe5 Nc6?! 4. Nxc6 dxc6 5. e5
Now I knew my opponent played the very rare 3rd move, sacrificing a pawn for insufficient compensation. I had played this in a few friendly, rapid games before and always went for the “safe” approach with 5. d3 and tried to take the steam out of his counter-play in the opening. For this game, I decided to go for the move that Fritz advised!
5… Ne4?!
And of course he plays the one move that Fritz never even considered, and I didn’t take a look at this.
6. d3??
I only looked at 6…Nxf2 as his main sacrificing alternative and considered it ok. I completely missed his next move. 6. d4! and white holds a significant advantage.
6… Bc5!
I looked long and hard at 7. Be3 Bxe3 8. fxe3 Qh4+ 9. g3 Nxg3. It was a choice between 2 bad variations and I chose the one that I thought might lead to positions where I could try and swindle him. Alas, no such thing happened and he wrapped up the point efficiently.
7. Qf3 Nxf2 8. b4 Bb6 9. c3 Nxh1 10. g3 Nf2 11. d4 Ng4 12. Bc4 Qe7 13. h3 Nxe5 14. dxe5 Qxe5+ 15. Be2 Be6 16. Bf4 Qf6 17. Qe4 Qf5 18. Nd2 O-O-O 19. Qg2 Qxh3 20. Qxh3 Bxh3 21. Kd1 Rhe8 22. Bf3 Bf5 23. Kc1 Be3 0-1

What is your coding style?

February 6, 2010

I wanted to traverse a list of strings until a certain string occurred, then do something with that index. My code was:

int i;
for (i=0; i<list.size() && !("string".equals(list.get(i))); i++);
// do something with i

During the build, where we use several tools and metrics, Checkstyle complained that an empty statement in the for-loop was badness. Why?

This of course led to an argument about whether this is easy code to read. Checkstyle was happier when the above code was refactored to:

int i;
for (i=0; i<list.size(); i++)
  if ("string".equals(list.get(i)))
// do something with i

And another way to write the same code is:

int i;
while (i < list.size() && !(“string”.equals(list.get(i))))
// do something with i

The 1st and 3rd ways are crystal-clear to me and intuitively, the way I write (and think about) code.

Another example I have (and which is perhaps a deeper question about how you approach mathematical problems) is, “How do you compute a to the power of b?”. I would, instinctively, write a recursive method. Others I know would do it iteratively. What is your coding style?