Archive for November, 2008

h1

A great endgame to analyse

November 26, 2008

I played in the second of two games mentioned here on the 17th, again as black. White gave up a pawn in the opening in exchange for the center. I was always looking to return the pawn under favorable circumstances but my opponent didn’t want to cede the initiative to win the pawn back. We finally got into a very tricky bishop vs knight endgame which I managed to eke out. Here is the game.

1. d4 d5 2. Nf3 e6 3. c4 c6 4. Nc3 Nf6 5. g3 Nbd7 6. Bg2 dxc4 7. O-O Be7 8. e4 O-O 9. Qe2 Nb6

I also thought about playing b5 here but was worried about the weakness of c6 and a8. On hindsight though, I should have probably played that – to expose the c6 weakness, both the pawn on e4 and the knight on f3 would need to go to e5. With that not possible, I should have been safe!

10. a4 a5 11. Rd1 Nfd7 12.  Ne5 Nxe5 13. dxe5 Qc7 14. Be3 Rd8 15. h4?!

At the time I thought the idea with h4-h5-h6 was quite slow. This gives me the time to unravel myself somewhat and trade off some pieces. He explained later that he believed that with pawns on h6 (and probably f6), my king would have a hard time getting into the game and that he would hold the advantage.

15…Bd7 16. h5 c5?! [Be8] 17. f4 Bc6 18. h6 g6 19.  Nb5 Bxb5 20. axb5 Rxd1+ 21. Rxd1 Rd8 22. Rxd8+ Qxd8 23. f5 Qd7

My opponent later said that he was expecting Qd3 here with an advantage for white and that Qd7 was almost losing. The two moves were also my main options – I went with Qd7 because I was worried I wouldn’t be able to hold on to the extra pawn after the swap of queens. It turns out that after 23…Qd3 24. Qxd3 cxd3 25. Kf2 a4 26. Bf1 Nc4 27. Bxd3 Nxb2 28. Bb1 Nd1+ 29. Kf3 a3, black’s passed a-pawn is very strong.

24. Bh3 exf5 [Qd3] 25. exf5 Qd5?!

Again, Qd3 was the only way to maintain the advantage.

26. fxg6

f6! was probably stronger, like he had been intending to play a few moves earlier (see notes to white’s 15th move)

26…fxg6 [hxg6!] 27. e6 Qe5?

Nc8, bringing it back into defense was better.

28. Qf3 Bf6 29. g4?

This again tilts the balance in my favour. Fritz shows 29. Bf2 Nd5 30. Bf1 and the black queen-side pawns are collapsing and the bishops then attacking the king-side with even more venom. As it is, white’s move allows some simplifying tactics from black.

29…Qxe3+ 30. Qxe3 Bd4 31. Kf2  Kf8 32. Bg2 Ke7? [Bxe3+] 33. Bxb7?

33. Bxe4 Bxe3+ 34. Kxe3 c3 35. bxc3 a4 36. Bxg6 a3 37. Bb1 Kxe6 should lead to a draw with correct play.

33…Bxe3+ 34. Kxe3 Kxe6?

34…c3 bxc3 was much stronger, creating a passed a-pawn.

35. Ke4??

The last move to make the time control, with seconds left on the clock. Be4 was much better.

35…Na4??

Returning the favour with a lot more time left on my clock to make the time-control. Analysing after the game, we deemed this now to be a draw. Again, Fritz shows the line 35… a4 36. Ke3 c3 37. Be4 cxb2 38. Kd2 Nc4+ 39. Kc3 a3 40. Bb1 Na5, and black has a completely won game.

36. Bd5+ Kd6 37. Bxc4  Nxb2 38. Ba2?

The start of a wrong plan. The draw could have easily been gained by 38.Bg8 c4 39. Bxh7 c3 40. Ke3 Nc4+ 41. Kd3 Ne5+ 42. Kxc3 Nxg4 43. Bxg6 Nxh6

38…a4 39. b6?

Completely losing the plot. Now I can just walk over and grab the pawn with no delays in tempo.

38…Kc6 40. Ke3 Kxb6 41. Kd2 Kb5?

Now, giving up the win and allowing a forced draw. 41…c4, preventing the bishop from going to g8 was critical.

42. Bb1?

Not taking advantage. 42. Bg8 Nc4+ 43. Kc3 Ne3 44. Bxh7 Nxg4 45. Bxg6 Nxh6 46. Be8+ Ka5 47. Bxa4 Kxa4 48. Kc4 is a dead draw. Now, the win is quite easy.

42…Nc4+ 43. Kc1 Ne5 44. g5 Kb4 45. Be4 c4 0-1

Advertisements
h1

Tournament victory

November 19, 2008

After a month and a half of no serious chess games (I did play 4 rated blitz games in the interim, with 2 wins and 2 losses), I have now played two in one week. The first of these was last Thursday in the final round of the Swiss tournament mentioned in my previous chess-related post. With a win in the game, I finished the tourney with 4.5/5. My opponent from round 2 is yet to play his final round and he still has a shot at tying me for first place. Nevertheless, this is a pretty good achievement for me.

The game itself was remarkable. We replayed the same opening we had played earlier. I quickly got myself into trouble and was lucky to parry his threats through the opening and middle game. When we got into the endgame, my opponent had a very passive rook and a horrible bishop against my very active rook and wonderful central knight, leading to a very easy conversion.

1. e4 c5 2. Nc3 e6 3. f4 d5 4. e5 d4

Knowing that I threw away our win in our previous encounter, I was fully expecting him to go for the same suspect line grabbing a rook and pawn for his knight and bishop and this time making him suffer for it. If it weren’t for this misguided thought, I should have probably played Nc6 and played with a more French-like structure. This now allows him to mount a serious initiative against my king-side.

5.  Ne4 Nh6 6. Nf3 Be7 7. Bc4 O-O 8. O-O Bd7

This is the first variation from our previous game. Previously I had played 8…a6.

9. Nfg5 Bc6?

Already, my position is getting quite dicey. The computer only gives white a half-pawn advantage but it is quite nerve-racking to see him bring so many pieces into the attack so quickly! I think I should have preferred Nc6, allowing the bishop to go to e8.

10. Qh5 Bxe4 11. Nxe4 Nc6  12. a3 a6?

The start of a not-so-good plan. My idea was to follow up with b5, and if he kept his bishop on the a2-g8 diagonal, I could play d3, blocking the d2 pawn and seriously hampering his queen-side development. What the computer now shows me is that d3 was playable straight away with the same goal. He cannot play Bxd3, because after …c4 Bxc4 Qd4+, I win a piece for 2 pawns.

13. Rf3 b5 14. Ba2 c4 15. d3 Qd5 16. Rg3 Nf5 17. Rh3 h6 18. Qg4 Kh8  19. Ng3 Ne3 20. Bxe3 dxe3 21. Nh5 g6

Until this point, the game had proceeded along reasonably logical lines. Rg8 was my other big choice here. I was feeling the pressure of constantly defending and wasn’t sure how much counter play I could muster after Rg8. While waiting for my opponent’s move, I started panicking. I was worried that after 22. Nf6 Bxf6 23. Rxh6+ Kg7 24. Qh3, I couldn’t see any lines where I would not be losing at least a rook. After checking with the computer, it turns out that had my opponent gone for this line, I could have in fact played 24…Nxe5, with an advantage for black – though I don’t know if I could have spotted it over the board.

22. Nf6 Bxf6 23. exf6!?

My opponent had a long think here about the same line discussed above. Though he couldn’t remember after the game why he chose not to go in for that variation, he said he saw a refutation that led him to just quietly recapture the piece.

23…h5 24. Qg5?

White should not have offered the trade of queens and gone for something like Qe2. Now his position becomes very hard to defend.

24…Qxg5 25.  fxg5 cxd3 26. cxd3 Nd4! 27. Re1 e2 28. g4 Kg8 29. gxh5 gxh5 30. Kf2 Rac8 31. Rh4 Rfd8 32. Bb1 Rc5! 33. Rxh5 Rf5+ 34. Kg2 Rdd5! 35. Rh3 Rxg5+ 36. Rg3 Rxg3+ 37.  hxg3 Rf5

The game is pretty much decided. His bishop has nowhere to go, his rook is hemmed in at e1, his king is cut off from the e2 pawn, while my pieces dominate the position. I felt so good about my position that I even turned down his offer of a piece on the next move to go grab a pawn!

38. Bc2 Rxf6 39. Bd1 exd1=Q 40. Rxd1 Rf3 41. Rd2 Kg7 42. Rd1 a5 43.  Rd2 a4 44. Rd1 Kg6 45. Rd2 Kg5 46. Rf2 Rxf2+ 47. Kxf2 f5 48. Ke3 e5 49. Kf2 Kg4  50. Kg2 Ne2 0-1

h1

Post Processors in Spring’s Autowired world

November 9, 2008

I have been a huge fan of the Spring Framework ever since I came across it. I have trouble remembering how I overcame all the obstacles of dependency injection (not to mention thread pooling, jdbc access etc) in the pre-Spring era. While building Aloha, I had gotten quite used to the idea of post-processors (in addition to the init-method and destroy-method attributes on each bean), enabling me to write setup code for my application once all the beans had been instantiated and initialised.

Now, as part of the Ribbit team, I am working for the first time with Spring 2.5, with beans being autowired using annotations*. A few days ago, I wrote my first post-processor for the application. Unit tests passed with no issues, but when Uros tested the post-processor against our test environment, it turned out the post-processor executed BEFORE all the beans had finished their initialization. This was, without a doubt, a shock to the system. He got around the problem by implementing the same solution on receiving a Spring ContextRefreshedEvent.

Though this solved the problem, I was stumped by the fact that a post-processor no longer behaved like its very name suggested. The only explanation I could think of was that the post-processor executed after the beans in applicationContext.xml were initialized, but before the initialization of the autowired ones. A quick search gave me the “autowired” way of post processing: the @PostConstruct and @PreDestroy annotations**. I just tried them out locally and they work without a hitch. However, since we already have a working solution, I won’t be checking this in, but will definitely keep it in mind for the next time!

* I am yet to make up my mind on whether I am for autowiring or not – the obvious benefit is that everytime you add a dependency to a bean, you are not required to go edit an xml file somewhere to wire everything together. On the flip side, it is sometimes convenient to go look up a listing of all beans and their dependencies in one place!

** These annotations are part of Java 6, but since we still use Java 5 in our project, we need to include common-annotations.jar, available as part of the Spring download, in our lib directory.