Tuesday 26 June 2012

Changes in the meaning of 'Equals' in NUnit 2.6 for IEquatable

Yesterday I wanted to upgrade the NUnit testing framework we use in our project to the latest stable version. We used 2.5.10 and it had reached 2.6.0. I simply removed the old version and replaced it with the new. Some of the tests failed.

Investigating revealed all tests had something in common: they were testing if two collections are not equal (meaning not the same instance) then that the collections are not equivalent (meaning none of the items in one collection is found in the other), yet that the values in the items are the same. Practically it was a test that checked if a cloning operation was successful. And it failed because from this version on, the two collections were considered Equal and Equivalent.

That is at least strange and so I searched the release notes for some information about this and found this passage: EqualConstraint now recognizes and uses IEquatable<T> if it is implemented on either the actual or the expected value. The interface is used in preference to any override of Object.Equals(), so long as the other argument is of Type T. Note that this applies to all equality tests performed by NUnit.

Indeed, checking the failing tests I realized that the collections contained IEquatable types.

Monday 25 June 2012

Avatar: The Legend of Korra

I loved the first Avatar animated series. It was deep, funny and yet innocent. A perfect kid show, but one in which an adult could find finer underlying levels of understanding. So it is no wonder that I eagerly awaited the release of Legend of Korra.

Now, that the first season is over, I can have an opinion on it. The show is not about a little kid anymore, it's about a teenager avatar. She, for she is a female, lives in a technological steampunkish world, something that is pretty hard to understand, considering she is the granddaughter of Ang, the hero of the first series, and it all happens merely 70 years afterwards. The innocence of childhood is replaced by the impetuosity of teen age, complete with mood swings, romantic feelings and a strong false sense of infallibility. The elemental countries are now united, so the only possible threat can come from a terrorist organization. There are moments of real fun, but not that many.

Bottom line: it's a completely different show! While in the first Avatar one could find strong moral values underlying what the characters did and the viewer would watch the show waiting to see what would Ang do next in the face of overwhelming adversity, now the focus is on what the avatar girl is feeling when she is not the center of attention and how she gets angry and motivated to use power to solve things. Not something terribly surprising in an American show, but really disturbing in a sequel to such beautiful a series.

So, while the show is nicely animated, the world interesting and the story passable, the overwhelming feeling I get is disappointment. I really do hope something will come out of the next seasons, which I will watch religiously, but let's face it: I do it for Ang.

Sunday 17 June 2012

The Polish or Sokolsky Opening

I was not going to write a chess post so soon, as I haven't really been playing lately and it might give the impression that I am either a good player or that I lost interest in other areas, like software developing. (I assure you, I did not, as I still waste spend most of my time at work, coding).

However, this opening seems a natural continuation of my previous post on the Sicilian Wing Gambit. There the b pawn was moved to b4 to counteract Black's attempt to control the center with c5. In the Polish opening, White starts directly with b4, denying Black moves like c5 and even hindering the development of their queen side knight.

The Polish, Sokolsky or Orangutan opening has been successfully used by international master Alexey Sokolsky, hence the name. He was not Polish though :) and I don't even care why someone would name a chess opening from an ugly orange ape (the video below explains it, though).

I will attempt to use several resources in this post. First, a PGN of the opening as a statistic of chess games played starting with b4.

1. b4 e5
(1... d5 2. Bb2 Nf6 3. e3 Bf5 4. Nf3 e6 5. a3 {This line ignores the White pawn on b4 and develops normally.}
(5. b5 {Moving the b pawn forward hinders the development of the queen's knight. Black is forced to either challenge the pawn, easily defended by the a and c pawns, as well as the bishop and knight, or develop their knight to d7.})
)
(1... Nf6 2. Bb2 e6 3. b5 {With White's pawn on b5 and Black's on d7, the knight on b8 is effectively out of the game.} d5 4. e3 c5 {Taking en passant would be a mistake, as it would free White's knight.}
(4... Be7 5. Nf3 O-O 6. c4 c6 {White has a thematic move: c4, with Black forced to protect the d5 pawn and lose avenues for development.})
5. bxc6
(5. c4 {Now it would be Black's turn to blunder in taking the c pawn and helping the White bishop develop while losing a center pawn. Black is not looking good with most their pieces having reduced mobility.} Be7
(5... Nbd7)
(5... b6)
)
5... Nxc6 {At this point Black is looking good, controlling the center and having more minor pieces developed.})
2. Bb2 d6
(2... Bxb4 3. Bxe5 Nf6 4. Nf3 O-O 5. e3 {The other common continuation. Black takes the pawn on b4, but loses a center pawn. At the same time Black develops a piece while forcing White to move twice - and later three times, maybe - the strong fianchettoed bishop.})
(2... f6 {Protecting the e pawn and blocking the White bishop's attack diagonal might look good, but it is robbing the Black night of its natural development square and weakening g6.} 3. b5 d5 4. e3 Be6 {Here Black has control of the center with a strong pawn structure, but can they hold it? The knights can only be developed on awkward 7th rank squares, the bishops have to wait for them and the queen has nowhere to go. The computer gives a complete equality between sides, but is it?})
3. e3
(3. c4 Nf6 {Transposing to the English opening} 4. e3 Be7)
(3. b5 {The natural continuation of b4, blocking the Black knight.} Nf6 4. e3 Be7 {Again, an awkward position for Black: everybody has to wait for the knight on b8.})
(3. e4 Nf6 4. Nc3 Be7 5. Bc4 O-O {Two bishops aimes straight at Black's king.})
3... Nf6 4. c4
(4. Nf3 Be7 5. Be2 O-O 6. O-O {Another variation similar to many before.})
4... Be7 {Consider this the main line, yet with less than 100 games played in this move order.} *


What we can see is two major thematic moves for White: b4-b5, blocking the development of the Black knight. The other is c4, protecting b5 and challenging d5. If Black takes (d5xc4), it loses a center pawn and helps develop White's light bishop. Also, after b4 and the dark bishop fianchetto, a common White move is e3, helping in completely domineering the center dark squares.

As Black, one can observe a tendency to go for the light squares. If White's pawn reaches b5, the only real square where the Black queen knight can develop is d7. That means that the d pawn cannot depend on the protection of the queen all the time and the light bishop will have to develop first or remain blocked by the knight. In the last game in this post, for example, one can notice Black immediately sacrificing the light squared bishop for White's king knight, relieving some of the pressure on Black's king side and giving freedom for pawns to occupy e6 of even f5.

A second resource is some real life games:
Sokolsky - Byvshev - 1951
[Event "URS-ch sf"]
[Site "Lvov"]
[Date "1951.??.??"]
[Round "?"]
[White "Sokolsky, Alexey"]
[Black "Byvshev, Vasily Mikhailovich"]
[Result "1-0"]
[ECO "A00"]
[PlyCount "75"]
[EventDate "1951.??.??"]
[EventType "tourn"]
[EventRounds "19"]
[EventCountry "URS"]
[Source "ChessBase"]
[SourceDate "1998.11.10"]

1. b4 Nf6 2. Bb2 e6 3. b5 d5 4. e3 a6 5. a4 Nbd7 6. Nf3 Bd6 7. c4 c5 8. d3 O-O
9. Nbd2 b6 10. Be2 Bb7 11. O-O Qc7 12. h3 Rfe8 13. Rc1 axb5 14. axb5 Ra2 15.
Qb3 Rea8 16. Nb1 Qd8 17. Rfd1 R2a4 18. Nc3 R4a5 19. d4 Bb8 20. cxd5 exd5 21.
dxc5 bxc5 22. Nxd5 Nxd5 23. Rxd5 Bxd5 24. Qxd5 Qe7 25. Rd1 Nf8 26. Bc4 R8a7 27.
Ne5 Bxe5 28. Bxe5 Ra4 29. Bd6 Qe6 30. b6 Rd7 31. b7 Rb4 32. Qxc5 Rxd6 33. Rxd6
Rb1+ 34. Kh2 Qe7 35. Bd5 g6 36. f4 Kg7 37. Qd4+ Kh6 38. Rb6 1-0


A more recent game, Kutuzov (2277) - Burkmakin (2571) - 2004. Kutuzon wins with the Polish.
[Event "RUS-chT2"]
[Site "Sochi"]
[Date "2004.04.28"]
[Round "9.1"]
[White "Kutuzov, Denis"]
[Black "Burmakin, Vladimir"]
[Result "1-0"]
[ECO "A00"]
[WhiteElo "2277"]
[BlackElo "2571"]
[PlyCount "87"]
[EventDate "2004.04.20"]
[EventType "team"]
[EventRounds "9"]
[EventCountry "RUS"]
[Source "ChessBase"]
[SourceDate "2004.07.06"]
[WhiteTeam "13"]
[BlackTeam "02"]
[WhiteTeamCountry "RUS"]
[BlackTeamCountry "RUS"]

1. b4 e6 2. Bb2 Nf6 3. a3 d5 4. e3 Bd6 5. Nf3 Nbd7 6. c4 c6 7. Be2 e5 8. cxd5
cxd5 9. O-O O-O 10. Nc3 a6 11. Qb3 Nb6 12. Na4 Nc4 13. Bc3 b5 14. Nc5 e4 15.
Nd4 Qc7 16. h3 Re8 17. a4 Bxc5 18. bxc5 bxa4 19. Rxa4 Nd7 20. Bb4 Rb8 21. Qc3
Nde5 22. f4 exf3 23. Nxf3 Nxf3+ 24. Bxf3 Bb7 25. Qd4 Rbd8 26. Bc3 f6 27. Rb1
Ne5 28. Bh5 Nc6 29. Ba5 Qe7 30. Bxd8 Rxd8 31. Qb2 Bc8 32. Qb6 Ne5 33. c6 Nc4
34. Qd4 Qc7 35. Rc1 Rd6 36. Bf3 Kf8 37. Qc5 Nxd2 38. Bxd5 Qe7 39. Kh1 f5 40.
Rd4 Ne4 41. Bxe4 Rxd4 42. Qxd4 fxe4 43. Rf1+ Ke8 44. Rf4 1-0


We must have a loss. Meijers (2507) - Naiditsch (2641) - 2005.
[Event "BL2-Ost 0506"]
[Site "Germany"]
[Date "2005.10.23"]
[Round "1.1"]
[White "Meijers, Viesturs"]
[Black "Naiditsch, Arkadij"]
[Result "0-1"]
[ECO "A00"]
[WhiteElo "2507"]
[BlackElo "2641"]
[PlyCount "67"]
[EventDate "2005.10.23"]
[EventType "team-tourn"]
[EventRounds "9"]
[EventCountry "GER"]
[Source "ChessBase"]
[SourceDate "2006.11.23"]
[WhiteTeam "Nickelhuette"]
[BlackTeam "Bindlach"]
[WhiteTeamCountry "GER"]
[BlackTeamCountry "GER"]

1. b4 c6 2. e3 Nf6 3. Nf3 d5 4. Bb2 Bg4 5. h3 Bxf3 6. Qxf3 Nbd7 7. a4 e5 8. b5
Bd6 9. g4 O-O 10. Be2 Ne4 11. Qg2 Bb4 12. Bd3 Nd6 13. O-O e4 14. Be2 Qe7 15. f4
exf3 16. Bxf3 Nc4 17. Bd4 Nde5 18. d3 c5 19. Bxe5 Qxe5 20. dxc4 Qxa1 21. Bxd5
Qe5 22. e4 Rad8 23. g5 Ba5 24. h4 Kh8 25. Rf5 Qd4+ 26. Kh1 g6 27. Rf1 f5 28.
gxf6 Rxf6 29. c3 Bxc3 30. Nxc3 Qxc3 31. Bxb7 Rdf8 32. Rxf6 Rxf6 33. Kh2 Qd4 34.
Qg3 0-1


Note that even if I have a huge database at my disposal, most of them are not annotated at all (like these three). There is a lot of chess knowledge out there that just waits to be analysed, digitized and shared. Help me out if you can!


In this game Black quickly realizes the light bishop is going to be hindered by the queen side knight and trades it off immediately, then develops the knight to d7 while the d pawn is protected by a pawn chain.

And the final resource, a video from YangsterNo9, who, despite the gangish nickname, has some decent chess videos. This one has some annoying sound clicks on it, but it is one of the few embeddable videos on the Polish I could find on short notice. In this video, Yangster is explaining how one should play against the Polish, from Black's perspective.


As a conclusion, I liked this opening. It is uncommon for a reason, as it is rather slow and risky. White has the advantage of the first move, they should not waste it on side pawns. However it does seem more manageable than the Sicilian Wing Gambit and can easily transpose in the English opening, which I haven't played, but is in heavy use. What I did't like at either this or the wing gambit is a lack of traps. There probably are a few, but I would have to find them myself. I hope you liked it, too.

Please let me know which formula for a chess blog post you like more. I've tried several and I will continue to try in the future, but I would like some feedback from people who read about chess on my blog. Thanks!

Update October 2014:
Sergio Zaina, from Brazil, sent me this trap in the Polish:
1.b4 c6 2.Bb2 Qb6 3.a3 a5 4.c4 axb4 5.c5 Qxc5 6.axb4 1-0

Thursday 14 June 2012

Fast game against my Nokia

Sometimes, in the subway or when I get a little bored I take out my trusty cellphone and play a little game of chess. The games are not spectacular or even smart, but I feel I learn a lot by the subsequent (and a lot longer) computer analysis of the game. Without further delay, here is one of them:
1. b4 {The Polish opening. I plan on doing a post about it, I find it interesting and deliciously unappreciated} c6 2. d4 e6 3. c3 d5 4. Bf4 a5 5. a3 (5. b5 {The chess engine suggested this move sequence} cxb5 6. e3 Bd7 7. Bd3 b4 8. Nf3 Nf6 9. O-O Be7) 5. .. axb4 6. cxb4 (6. Bxb8 {computer suggested} Rxb8 7. axb4) 6. .. Nf6 (6. .. Bxb4+ {When I played the game, I wondered why Black didn't move like this. Apparently it was a better move.} 7. Bd2 Bd6 8. Nc3) 7. Nd2 Bd6 8. Bg3 O-O 9. e3 Qc7 10. f4 {The computer keeps nagging about developing pieces, but I moved the pawn} Re8 11. Bd3 Qb6 12. Ngf3 Nbd7 13. O-O Nf8 14. h3 Ng6 15. Ng5 h6 16. Ngf3 Nh5 17. Bf2 Ne7 18. Ng5 {Computer says this achieves equality, over its solution of 0.2, however it seemed a good idea to exchange knights and ruin Black's pawn structure.} Nxf4 {Ill advised by
the computer, Black accepts the exchange.} 19. Bh7+ (19. Nxf7 Kxf7 20. exf4
Kg8 21. g3 {I didn't like the computer suggestion: giving Black a semiopen
file and blocking my own rook.}) 19. .. Kf8 20. exf4 hxg5 (20. .. g6
{interesting suggestion by the computer: trap the bishop instead of taking
the knight.} 21. Ngf3 Kg7 22. Bxg6 Nxg6 {But I also did not enjoy the
resulting position}) 21. fxg5 (21. Qh5 {Computer suggested this,
considering my own move a blunder that would have lost 1 point.} Bxf4 22.
Nf3 Ng8 23. Nxg5 Bxg5 24. Qxg5 Qd8 25. Qc1) 21. .. Bf4 (21. .. g6 22. Qf3
Nf5 23. g4 Kg7 24. Bxg6 fxg6 25. h4 (25. gxf5 exf5 26. Nb3 Qd8 27. Qg2
{With all my pieces harrassed away and uncoordinated, the computer sees an
advantage of 3 for Black, even if material is the same.}) 25. .. Qc7 (25.
.. Nxd4 {This would have been an incredible blunder, leading to a quick
mate} 26. Qf6+ Kh7 27. Qf7+ Kh8 28. Qxe8+ Kh7 29. h5 Ne2+ 30. Kh1 Qxf2 31.
Rxf2 Ng3+ 32. Kh2 Nf5+ 33. Kh1 Kg7 34. gxf5 Bf8 35. hxg6 Ra5 36. Qf7+ Kh8
37. Qxf8#) 26. Rac1 Bd7 27. gxf5 exf5 {Strange suggestions from the
computer. Look at the variations to understand why!}) 22. Bh4 {I blundered!
Didn't see that d4 would be undefended and resulting in check. Advantage
for Black: 1.5.} Qxd4+ 23. Rf2 {Another blunder: +7 for Black!} (23. Bf2
Be3 (23. .. Qxd2 {Taking with the Queen seems to win a quick free knight,
but moved ahead show it to be otherwise} 24. Qh5 Nf5 25. Rad1 Qb2 26. Bxf5
exf5 27. Rde1 Be6 28. Bc5+ Kg8 29. Rxf4) 24. Qe1 Bxf2+ 25. Rxf2 g6 {Again
the thematic g6}) 23. .. Bxd2 24. Qxd2 Qxa1+ 25. Rf1 Qxa3 26. Qf4 f5 {It's
Black's turn to make a mistake. From 7 advantage to -4 in a single move.}
(26. .. Nf5 27. Qc7 g6 28. Rxf5 (28. Bf2 e5 29. Bxg6 fxg6 30. Qh7 d4 31.
Qxg6 Qa2 32. Qh5) 28. .. gxf5 29. Kh2 Bd7 30. g6 (30. Qxd7 Qxb4 31. g6 fxg6
32. Bg3 Re7 33. Qd6 (33. Bd6 Qf4+ 34. Kg1 (34. Bxf4 Rxd7) 34. .. Ra1#) 33.
.. Qxd6 34. Bxd6 g5 35. Bg6 d4 36. Kg3 b6 37. h4 gxh4+ 38. Kf4 c5 {White
can't stop a promotion.}) 30. .. Qxb4 31. Bg5 Qc3 32. gxf7 Qg7 33. Qd6+
(33. fxe8=Q+ Kxe8 34. Bd2 Qxh7) 33. .. Kxf7 34. Qxd7+ Kf8 35. Qd6+ Re7 36.
Bg6 c5 37. h4 c4 38. h5 c3 39. Qc5 Qe5+ 40. Kh3 Qc7 41. Qd4 e5 42. Bh6+ Kg8
43. Qxd5+ Rf7 44. Kh2 {And the dance goes on. What happened? Again, see the
variations for the most obvious moves. Black has 9.3 points ahead at this
moment.}) 27. gxf6 Nf5 28. fxg7+ Kxg7 29. Bxf5 {Oops! Equality again. The
mistakes of both players balance perfectly} (29. Qc7+ {This would have been
the best course of action} Bd7 30. Bxf5 Qe3+ 31. Kh2 exf5 32. Qxd7+ Kh6 33.
Rxf5 Rg8 34. Rh5+ Kxh5 35. Qh7+ Qh6 36. g4+ Kxh4 37. Qxh6#) 29. .. exf5 30.
Qg5+ Kh8 {Equality would have been preserved if the king would have moved
Kf8. As such, defeat is unavoidable.} (30. .. Kf8 31. Qf6+ Kg8 32. Qg6+ Kf8
33. Bf6 Qe3+ 34. Kh2 Re7 35. Rf3 Qe6 36. Rg3 Ra2 37. Qh6+ Ke8 38. Qh8+ Kd7
39. Bxe7 Kxe7 40. Rg7+ Kd6 41. Qd8+ Ke5 42. Re7 d4 43. Rxe6+ Bxe6 {And this
is again complete equality.}) 31. Qh6+ {Instead, I almost equalize AGAIN!}
(31. Qh5+ Kg7 32. Qxe8 Qb2 33. Qe7+ Kg6 34. Rf3 Ra3 35. Qd6+ Kf7 36. Qc7+
Kg6 37. Qxc8 Rxf3 38. Qg8+ Qg7 39. Qxg7+ Kxg7 40. gxf3 Kf7 {The computer
version leads to a long endgame, but the advantage is clearly White's.})
31. .. Kg8 32. Qg6+ Kf8 33. Bf6 {and I allow Black to get into the Kf8
variation described above, only instead of Qe3, they do a Qa7, which seals
Black's fate.} Qa7+ 34. Kh1 Qg1+ 35. Rxg1 Re7 {Black's rook, undefended by
the Queen, is only delaying the inevitable. Of course, my ineptitude delays
it even more, so see the computer variation for a short ending.} 36. Bxe7+
(36. Qh5 d4 37. Qh8+ Kf7 38. Qg7+ Ke6 39. Qxe7+ Kd5 40. Rc1 Be6 41. Qc5+
Ke4 42. Qxd4#) 36. .. Kxe7 37. Re1+ Kd8 38. Qf7 Bd7 39. Qf8+ Kc7 40. Qxa8
c5 41. bxc5 f4 42. Re7 f3 43. gxf3 Kc6 44. Qa4+ b5 45. Qa6+ Kxc5 46. Rxd7
b4 47. Qd6+ Kc4 48. Qxd5+ Kc3 49. Qd4+ Kb3 50. Rb7 Kc2 51. Rxb4 Kc1 52.
Qb2+ Kd1 53. Ra4 Ke1 54. Ra1# *



Update April 2016: Here is the same game on the Lichess server, complete with computer analysis and human readable mistakes and blunders.

Monday 11 June 2012

In javascript, switch and if are not equivalent. The switch statement is type exact.

It was not a complete surprise, but I did not expect it, either: the switch statement in Javascript is type exact, meaning that a classic if block like this:
if (x==1) { 
doSomething()
} else {
doSomethingElse();
}
is not equivalent to
switch(x) {
case 1:
doSomething();
break;
default:
doSomethingElse();
break;
}
If x is a string with the value '1' the if will do something, while the switch will do something else (pardon the pun). The equivalent if block for the switch statement would be:
if (x===1) { 
doSomething()
} else {
doSomethingElse();
}
(Notice the triple equality sign, which is type exact)

Just needed to be said.

Sunday 10 June 2012

Chess board, video tag and overlays over YouTube videos

As part of the blog revamp I've modified the styling and code for the board that displays chess PGNs and added file letters and rank numbers as well as highlighting of the last move. I've also sped up the move animation a little. Hopefully it will be more helpful this way.

Also, I noticed that the link overlay I added for external links was behind the YouTube videos. Thankfully there was a relative simple fix, albeit one that had to be made on each post. On this occasion I've created the new 'video' tag that complements the old 'picture' tag which applies to anything visual, be it video or just images, I've refreshed the videos that were removed, updated all the links to the new YouTube iframe embedding mode.

The tag system is something that evolved organically on this blog, starting with 'programming' and 'misc' (which actually is anything not related to programming) and ending with such ridiculous stuff like the 'picture' tag or the 'essay' and 'personal' tags, for which even I get confused about what they are. Perhaps some day I will reorganize it, but until then (and until Blogger finds a way to remove the restriction that only up to 50 posts can be affected by tag changes) try to remember the main tags on the blog:
  • programming - refers to anything related to software development
  • misc - unrelated to software development
  • software - posts about specific software
  • music, movies, books - relating to music, movies and books
  • picture - containing embedded images or video
  • video - containing embedded video
  • administrative - related to this blog

Friday 8 June 2012

The Sicilian Wing Gambit

A wing gambit is a way for one of the players in a game of chess to sacrifice a pawn on the b or g files in order to deflect defenders of the center. Like all gambits, it is an aggressive attempt to gain position by sacrificing material, in this case, an attempt to control the center of the board. Today I want to talk about a gambit that occurred to me while I was thinking of a way to play against the Sicilian Defence. It involves moving a pawn to b4 to counteract the Black move c5, which is also, in a way, a sort of wing attack. I liked the concept: you outflank the opponent. Looking in the chess database, this is called the Sicilian Wing Gambit.

The first thing to notice is that the b pawn is irremediably lost. Declining the gambit brings no advantages to Black whatsoever, so they must take. After c5xb4, you have lost a pawn and also blocked the c3 square, the traditional best starting point of the queen's knight. So, as white, you have moved two pawns, lost one and also the best square for one of the minor pieces, while developing none. It doesn't look good and, for that reason, this gambit has been scorned in the past as unprincipled. It has made a comeback, though. It is not something you should expect to see at world chess championships, but it is good for blitz games and for throwing your opponent off track.

Even if White appears to have lost time, material and positional advantage, there is no clear way for Black to punish them. We will examine some of the options that Black has and where they led in various database and computer simulated games. The next move of White's is a3, attacking the pawn and preparing to open the a file. Another option of White's is to immediately challenge the center with d4. We will examine both options, as well as some rare variations (of such a rare gambit), like Nf3. So here is the PGN file I've compiled. Move carefully through all variations and read the comments. It might intrigue you enough that you would adopt the Sicilian Wing Gambit as a permanent part of your chess repertoire:
1. e4 c5 2. b4 {challenges c5 in order to deflect it from d4} cxb4
(2... b6 3. bxc5
(3. Bc4 {White is not forced to take.} e6)
(3. Nf3 {A normal development plan can be attempted while deciding what to do on c5} Bb7)
(3. b5 {Or even push the pawn forward, blocking the b knight and the rook for a while} Bb7
(3... a6 {although I don't particularly like the possibilities after a6.})
4. Nc3 e6 5. Nf3 Nf6)
3... bxc5 {Here Black declined the gambit and maintained a pawn on c4.} 4. Nc3 Nc6 5. Rb1 {But White gets first to control the open b file.} g6 6. g3 Bg7 7. Bg2 Ba6 {Black has tried to revert to their original Sicilian plan, but some parts are clearly different because of the lack of the b pawns})
3. a3
(3. d4 {White might want to move for the center immediately} d5 4. e5 {But here the engines give almost one full pawn to black}
(4. exd5 Qxd5 {while here the Black queen is safe from harassment because the b4 pawn is still there.})
4... Nc6)
(3. Nf3 {This is the line suggested by a chess engine. I'll follow it through a little more.} Nf6 4. e5 Nd5 5. a3 d6 6. Bc4 dxe5 7. Nxe5 e6 8. axb4 Bxb4 9. Bb2 O-O 10. O-O Qg5 11. Re1 Nc6 12. Qf3 Bd6 {No humans have played a game like this. From here the engine mercilessly simplifies the situation.} 13. Nxc6 bxc6 14. g3 Qf5 15. Qxf5 exf5 16. Bxd5 cxd5 17. Ba3 Bxa3 18. Rxa3 {Black has managed to control the center, even if the White rooks are really active.} Be6 19. Ra5 d4 20. Na3 Rfc8 21. d3 {At this point I ended the simulation. Clearly White has failed to control the center and gained only limited mobility. Black has an extra doubled pawn and the game will probably draw.})
(3. c4 {Santasiere variation: an even more gambity move, baiting b4xc3 followed by Nc3 and gaining development and center control. The few games that played like this did not finish well for White, though.} bxc3 4. Nxc3 g6 5. Bc4 Nc6 6. Nf3 Bg7 7. O-O Nf6 8. e5 Ng4 9. d4 O-O 10. h3 Nh6 11. Bf4 d6 12. Qe2 Nf5 13. Rfd1 Qa5 14. Rac1 e6 {This is an entire game that ended in an agreed draw - Rainer-Guenter 1995})
3... bxa3
(3... d5 4. exd5 {this is the main move}
(4. f3 e5 {A single game with this situation. White has delayed too much piece development and pushing of the d pawn. Black won.})
(4. e5 {But this is met more and more in Blitz games.} Nc6 5. d4 Bf5
(5... Qb6 6. Be3 Bf5 7. Bd3 Bxd3 8. Qxd3 e6 {This is the recommendation in the video, with Black having a better game.} 9. Ne2 Nge7 10. O-O Nf5 11. axb4 Bxb4 12. c3 Be7 13. Nd2 O-O 14. Nf4 Rfd8 15. g4 Nxe3 16. Qxe3 {Black is better with the a and b passed pawns.})
6. axb4 Nxb4 7. Bb5+
(7. Na3 e6 8. c3 Nc6 {This is the situation covered in the video, Black has extra development, but difficulty in continuing it. White eyes b5 and has everything wide open.})
7... Bd7)
4... Qxd5
(4... Nf6 5. axb4 Nxd5 6. Nf3 Nxb4 7. d4 Bf5 8. Na3 e6)
5. Nf3 {Marshall variation}
(5. Bb2 {Marienbad variation} e5 6. axb4)
5... e5 6. axb4
(6. Bb2 Nc6 7. c4 {en passant would be a bad move, due to Nc3} Qe6 8. Bd3 Nf6 9. O-O Bd6 10. Re1 O-O 11. axb4 Nxb4 12. Bf1 e4 13. d3 Qd7 14. dxe4 Bc5 15. Bxf6 Qxd1 16. Rxd1 gxf6 {Another variation from the video, stopped here as it didn't look very promising for Black.})
6... Bxb4 {White's plan backfired. Instead of a strong center and fast development, Black has the center and a strong center queen. The engines, however, show a mere 0.2pawns in advantage for Black.})
(3... e6 4. axb4 Bxb4 5. c3 Be7 {Another win for Black: a silly dark bishop, a blocked knight, but White keeps control over part of the center and controls one open semifile.})
(3... Qa5 {A possible annoying move} 4. Bb2 {But this solves most of the issues.} Nc6 5. Nf3 Nf6 6. Bd3 {Yet not all. The d pawn is effectively pinned.})
(3... Nf6 4. e5 Nd5 5. axb4 Nxb4 6. c3 N4c6 7. d4 {Black has a knight out, but White has a monster pawn chain, an open semi file and a lot of open avenues. Black will attempt to control the light squares, while White will be busy trying to achieve some sort of king safety.})
4. Nxa3 {A knight on the rim is dim, but here it prepares to go to b5, where it would force the queen to defend c7 and threaten a7} d6 5. d4 {Black wanted to stop White from having a two pawn center. Instead, even a three pawn center is possible.} Nf6 6. Bd3 {this seems to be the mainline, but even so, there are only 43 games starting like this in my game database} Nc6 {From here, engines and database, all three games, show equality between players.} *


Take notice that I am still a beginner in chess and my analysis is based on what I've compiled from the database of chess games and a video. Here is a video and the PGN of a game that played along the main line in my analysis (Vladimir Grabinsky 2361 - Albert Lyubimtsev 2148, from 2003) where White won.



1. e4 c5 2. b4 cxb4 3. a3 bxa3 4. Nxa3 d6 5. d4 Nf6 6. Bd3 Nc6 7. c3 g6 8. Ne2 Bg7 9. O-O O-O 10. f4 Ne8 11. Kh1 Nc7 12. Qe1 a6 13. f5 b5 14. Nc2 Bd7 15. Qh4 Ne8 16. Rf3 e6 17. Qg3 {White missed an opportunity here, according to the chess engine.}
(17. Bg5 f6 18. Rh3 fxg5 19. Qxh7+ Kf7 20. Qxg6+ Ke7 21. Qxg5+ Rf6 22. Nf4 exf5 23. Re1 Kf8 24. exf5 Rh6 25. Rxe8+ Bxe8
(25. .. Qxe8 {This would have been a blunder leading to massive material loss and/or mate in about 15 moves.})
26. Qxh6 Bxh6 27. Ne6+ Ke7 28. Nxd8 Nxd8 29. Rxh6 {A much simplified position, where White has two extra pawns and Black has an exposed king.})
17. .. e5 18. Be3 Bf6 19. Raf1 Ng7 20. Bh6 {This move maintains both sides to a near equality, with a slight advantage for White.}
(20. d5 {The computer sees this option, which wins almost a pawn immediately and locks the king side from the defence of Black's pieces} Bh4 21. Qh3 Nb8 22. g4 Ne8 23. Bh6 g5 24. f6 b4 25. Ne3 a5 26. cxb4 Qc8 27. bxa5 Na6 28. Ng3 Qc5 29. Ngf5 Ra7 30. Ne7+ Kh8 31. Bxf8 h5 32. Bh6 Qxe3 33. Rxe3 Bxg4 34. Qg2 Kh7 35. Bxg5 Rxe7
(35. .. Bxg5 36. Rh3 Nxf6
(36. .. Bxh3 37. Qxg5 Bg2+ 38. Qxg2 Nxf6 39. Rxf6 Rxe7 40. Qg5 Re6 41. dxe6 fxe6 42. Rh6#)
37. Rxf6 Kg7
(37. .. Bxf6 38. Qxg4 h4 39. Qg8+ Kh6 40. Nf5+ Kh5 41. Be2#)
(37. .. Rxe7 38. Qxg4 Kg8 39. Qxg5+ Kf8 40. Rxh5 Ke8 41. Rxd6 f6 42. Qg8#) 38. Rxh5 Rc7 39. Qxg4 Rc1+ 40. Rf1 Rxf1+ 41. Bxf1 f5 42. Qxf5 Bxe7 43. Rh7+ Kg8 44. Qf7#)
36. Bxh4 Nac7 37. fxe7 f6 38. Be2 f5 39. Bxg4 hxg4 40. Rxf5 Ng7 41. Qxg4 Nce6 42. Rh5+ Nxh5 43. Qxh5+ Kg8 44. dxe6 d5 45. Rg3#)
20. .. Qe7 {-2.11/15 10 The engine recommends Ne3, which leads to a variation where for more than 20 moves white appears to be a minor piece ahead, only the score is positional only. Queens come off the board, too.} 21. Qf2 {+0.26/14 10 Alekhin's Gun always looks impressive. From here it goes downhill for Black.} gxf5 22. Rg3 f4 23. Nxf4 exf4 24. Qxf4 Nd8 25. e5 *


Update: I've updated the above game with some computer analysis.

It is important to understand that Black did not lose because of the wing gambit, but because of their own mistakes further on. According to the computer, both players had almost complete equality up to almost the 20th move, which does not bode well for White. Most chess engines give about 0.25 points to White for having the first move, so somewhere that advantage was lost. However, we are not computers.

For what I see in the various games that were played using this anti Sicilian opening, I see several key points where each side is trying to reach. A common theme is the pushing of the e pawn from e4 to e5, defending it with d4 and defending that (while cutting access to the White king) with c3. Other variations see a strong three pawn center for White, making a sham of Black's attempted Sicilian. Moving the e pawn prematurely, before getting rid of the Black b4 pawn seems to be a mistake, though, even if it immediately achieves the classic two pawn center. The a3 move seems to want to open up the a file for the rook, but in the simulations I've run, the rook doesn't seem to have an important role. Also to note is that the queen side knight will most likely take the Black pawn on a3, which takes it to the rim of the board and away from the center. So even if control of the center is achieved, maintaining it might become problematic. Gutsy c4 pawn push, goading Black to take it en passant, only works if Black falls for it and even so, not very well: the knight on c3 will remain undefended on a move like d4. The computers recommend Black ignoring that pawn and pushing to e5 with more than half a point advantage.

On Black's side, it appears as there are several strategies as well. Defending with b6 declines the gambit and leads to something similar to the original Sicilian, regardless of the desired flavour of it. Even if White is pushing the pawn to b5 and hinders the development of the Black queen side knight. While the Black pawn is still on b4, attempts to break out the center, like the Scandinavian looking d5 work better, as an exchange on that square can end with a comfortable Black queen on d5 without the threat of Nc3. In general, taking the pawn on a3 seems to be a mistake, as White will only aid in the dark bishop's development if they take and the Black pawn on b4 can be defended in multiple ways further on, invalidating the gambit. A possible annoying move for White is moving the Queen to a5 and the recommendation of the guy in the video is to move it on b6, an intriguing strategy that seems to break the opening principle of not bringing the queen out too soon. Moving the e pawn at least to e6 seems to bring benefits as well.

Even if the Sicilian Wing Gambit is not very common and thus not analysed in depth so much, it doesn't mean it can't be a useful tool. I know that most chess opening videos have more to offer than what I posted above, but given the rarity of the gambit, it only makes sense to have less information on it, no tested traps, etc. If you play this opening, please let me know. I could update this post with your real life experience playing it.

Update: I've found a page where GM Roman Dzindzichashvili considers the Wing Gambit in the Sicilian a reason to seek psychiatric help :) Here is the link.
Also, I have updated the PGN with the official names for some of the variations of the gambit.

Update 8 March 2016: I've revisited this gambit with more research and computer analysis, check it out: Sicilian Wing Gambit - Revisited

Tuesday 5 June 2012

The Passage, by Justin Cronin

Book coverI started reading The Passage because of an Internet review. It was so exuberantly positive that I thought I would have a great time reading the story. It said "I don’t think I’m exaggerating when I say that almost everyone has heard about The Passage by Justin Cronin by now. At least the people in the booking world have." The only explanation I have now, having read the book, is that the reviewer is a bookie and they have some sick sense of choosing what they read. Ok, I am a little mean. Truth is that other people that I respect have blogged about the book and recommended it; I just can't fathom why.

Partly to blame is the writing style. Justin Cronin needs to make you understand what everyone is feeling by describing the most mundane parts of their lives and what they experienced. It's not the good type of description, where you get to know the people because of their thoughts and actions, it's just a lot of internal monologues on subjects I couldn't care less about. I feel that a good book is the one that contains mostly ideas relevant to the subject of the book and most of what these people thought or did was not. I am not very good with other people's feelings, so I thought it was all me and I continued to read through the book as a virus from South America that made people into blood thirsty immortal creatures was brought in the US in order to study how it could be used to create weapons. Not the best plot device ever, but I was already forcing myself to suspend my disbelief. (Cronin, that was your job, not mine!) Naturally, the virus escapes containment, unleashing chaos and destruction on the face of the world. I was a third into this rather long book when all the characters so painstakingly described disappear. They all die. Fast forward almost a century later. Now you see my dilemma? How can that be good writing?

Anyway, now people are living inside a high walled colony (because vampires can't enter a makeshift colony defended by lights and crossbows, but they have defeated armoured vehicles and military bunkers) and believe themselves to be the last remains of humanity. All 100 of them. I have to, again, read all about the feelings of people and how they see themselves and the world. Here we get some chapters extracted from people's diaries that are presented at some future outbreak conference. So, halfway through the book, we know it will end well. In case I was starting to enjoy the story. There are some heroic characters around, they do heroic stuff, then, another third in the book, they leave the colony. About a dozen or so. They go through vampire infested territory, losing a few people and the opportunity to know how they felt about it, and find out some important information on how to defeat the vampires. They were not the only remnants of humanity, no, humanity was nice and well fighting the vampires in the most ridiculous and inefficient manner possible. So, after completely removing another 95% of all the characters we got to know uselessly, we have a Mad Max kind of ride to other people. Lucky for me, these other people were pretty much empty plot devices so I didn't get to know how they felt one way or the other. Blessed joy!

At this point I was barely containing my impatience for the book to end. Some sort of bloody resolution to the mess I had read until then. They kill a master-vampire, they get a powerful version of the virus that makes people hybrids and retain their memories, they use a nuke! Wonderful. Then some idiotic woman decides she knows what is best and makes a completely unilateral decision based on "humanity" which pretty much dooms them all and separates the main character from his love forever, but they all accept it as "what should be". Fuming with frustration, I speed it up in order to get to the end of the book, mere tens of pages coming. And it comes. With a little religious crap and a sort of lame cliffhanger and a complete stop. Guess what? It's a bloody saga! See the book cover, there is more coming!

So I am sorry, Axe! I am sorry, Wertzone! I hated the book. It was as pointless as it wasn't making any sense. Maybe the guy can write, but I couldn't notice it because of all the ridiculous premises of the book and all the feely descriptions. I will not read the rest, I will not recommend this book and, if for some strange reason OMG, everybody is talking about this book, tell them you read it here: read something else!

Friday 1 June 2012

Blog revamp

I don't often have time to work on my blog so I took the opportunity of this personal time out to tweak the blog a little bit. Here are the new changes:
  • I've added a new way of exploring the links in the posts, meaning that you click on them and a dialog appears and opens the link. It has the advantage that you get to stay on the page, without opening a million tabs. It has the disadvantage of looking a little off and using extra javascript. It only applies to left button clicks, so if you want to open the link in another tab or window, middle click or right click and select your option. This introduced jQuery UI to the blog, so you might have a little more javascript and CSS payload, but taken from the Google CDNs.
  • The flies and cats have amused countless visitors, but I've decided to remove them. It streamlines the blog and makes it more accessible. You can still get them if you click on the Tools link "Bring back the animals!"
  • Finally, I've removed the blog chat. It didn't work for quite some time and the Plugoo people just didn't offer any support.
  • Some extra visual effects on the blog were removed as well.

Again, any suggestion on how you would like to improve the quality of your visits on my blog is very welcome and I am happy to implement all the reasonable requests.

The evolution of blog spam

When I first created my blog (oh, almost seven years ago), spam was something that automated software was posting, mindless comments that I can't imagine would inspire anyone to do anything. Cialis, Viagra, cheap fake Rolexes (as opposed to the expensive ones, I guess), pleasing my woman in bed, lasting longer; how could anyone imagine that, wanting all of these, I searched on the net, tried all the options, then still needed more? How much pleasing does my wife need anyway?(I'll have to look into that). Back then, I didn't even have a method to see all the comments for the blog and/or to delete the spam. Or any way to report it. I had to go to each post and remove them manually, even if they were identical texts and any tool could have noticed they were complete clones and, therefore, spam. Anyway CAPTCHAs were and are being used to stop these evil machines from polluting blog posts, yet sometimes they were not enough.

This was the first step in the blog spam evolution: if machines are stopping the spam machines, let's use humans. Getting so low that you need to have to write spam on people's blogs in order to win some money is something I thankfully never experienced or even understood and I hope I never will, but this is what I suppose happened. Some guy was randomly exploring the web, finding blogs that had enough visitors, then writing spammy comments in the hope that the blog master is not active enough to delete them as they are written. I hope I was active enough and, for those annoyed by post spam, I apologize. So, it didn't work too well for spammers on Siderite's blog.

Another mutation and the spam comments were now aimed at soothing my ego. "Thank you!","This info was great!","I am so glad that I read this post.". I felt wonderful the first few seconds before getting a comment email and opening it to see it riddled with links that had no connection to the content of the post. I felt so cheated that I created a javascript code to recognize any comment with the links I found and replace it with words acclaiming my work against spam. Now, THAT soothed my ego a little longer, thank you very much.

One of the feature of Blogger is that someone posts with a URL, their username appears as that link and goes to the person's "blog". So here I was, reading this comment that contained nothing bad, no links, but seemed a little too general. I mean, I know I am great and that my blog is wonderful, but how did other people find that out? I even replied to one or two such comments. My confusion was soon dispelled when going to see who wrote generic posts of praise for me and my blog. Cialis and Viagra were long gone. Instead, I had freemium software packages, trojan scams and fake antivirus packages. I deleted comments like that, even if, for a split second, I had the feeling that the text of the comment was OK and worth preserving. Oh, well.

And here I am, prompted to write this post by the latest wave of mutant spam: comments that are related to the content of the post! They seem very legit, at the limit of being vague. The links from the user name go to a site, but it is not necessarily a spam site. Today, for example, it was a completely free utility to help you play Scrabble. I don't know that it was a Trojan or was filled with ads; it could have been legit, an attempt by some Scrabble enthusiast to make himself known by attaching his web site to the Blogger comments. I always add the link of this blog to my comments elsewhere. I deleted it, anyway, but sometimes I find comments that are so far on the edge of legitimacy, that I don't have the certitude I need to delete them. So, I am pretty convinced that there are still spammy comments on the blog, but so well crafted that I failed to properly detect them.

This also means another thing, that sometimes there are false positives. I apologize to real people who found their comments removed. Try to leave more meaningful messages next time. And yes, it all boils down to that, doesn't it? If you have nothing to say, don't say it! It doesn't help anyone. And I already know the blog is great, tell me in what way it is so wonderful to you. Do tell :)

This is the point I've reached in my war against spam. It is still ongoing and far from over. I wonder when comments that will discuss real philosophical issues will appear, from people that were paid to have meaningful conversations on blogs and link to some site or another. I also wonder when, as people who can actually carry a conversation are expensive, I will find myself have a meaningful conversation with a spam bot.