Showing posts with label Stockfish. Show all posts
Showing posts with label Stockfish. Show all posts

Monday, August 3, 2020

Jerome Gambit: Two Computer Programs Walk Into A Bar...

I put some work into maintaining this blog, but I never could do it without the ideas, analysis and games that Readers send me.

For example, here is an introduction and then some analysis that I recently received (thank you, Anastazja) concerning a chess game where Stockfish gave Fruit 1.2 "Jerome Gambit odds".
Interested in the Jerome Gambit, I decided to look into it a little bit. However since my own chess playing abilities are a little weak, and since I don't play chess myself and I am more interested in AI research (and that of course leads to chess), I decided to test it on some computer games. However, since the Jerome Gambit is a very hard line to hold as white, I needed to change things a little bit. Considering that you would usually play Jerome Gambit against unprepared opponents looking to surprise them, it in theory has no place in today's computer chess. Their deep search can easily spot tactics and not fall victim to early queen attacks. However it turns out, that if you look deep enough, even computers can be outplayed with the opening. In the game I wish to share, white managed to use the queen checks to create a blocked position with very long term plans, making it very easy for opponents to become overzealous. 
Since the evaluation of the top chess engine Stockfish is at -3.5 pawns black advantage and the same engine can't surprise itself, I decided to try something different. I put Stockfish as white and an old engine called "Fruit 2.1" as black. Fruit is an old engine, however it still is about 2800 elo in strength, which would put it near world champion level. Moreover, its strength mostly comes from tactical prowess, as engines back in the day were relatively weak positionally. One would think that the Jerome Gambit is a tactical line that looks for compensation in terms of attack on the king that is in the open, so an engine with superhuman tactics should easily hold it. It turns out that it's not so simple. 
The game is 150 moves long, however most of those moves are just "shuffling" moves waiting for 50 move rule to take effect. White of course wants the draw, as it's a piece down, however black doesn't want that to happen. Even though most of the game are "pointless" rook and king moves, the critical moments of the game are definitely very interesting in my opinion. 
Game starts in the Jerome Gambit Accepted position, after Kxf7. White develops its remaining pieces. This, combined with queen checks, has led black to a little chaos. Black tried to force the queen trade, however the little positional and development edges white gained earlier made it not so simple. When black finally got its pieces developed and queens off the board, the position was already blocked and white got its own fortress ready. 
After creating a blocked position, both engines just shuffled around for multiple moves. The "shuffling" starts at move 34.Rf2 and continues for about 100 moves. White, being a piece down, has held the position because black could make no progress. Black constantly looked for opportunities, however the preparation in the first 30 moves of the game has made it impossible for black to find any kind of an attack. 
First 50 move rule reset happens at [71]...axb4 and [72].axb4. This pawn exchange doesn't open the position however, so engines continue to shuffle around. It's on move [121]...Rxc6 that the game gains a new life. Fruit playing as black, sacrifices the rook for a knight to open up the position hoping for some kind of an attack. Black is still up in terms of pieces, bishop and a knight for a rook. White has one pawn more, however in engine games pieces are usually worth a lot more than pawns. It turned out to be a very serious mistake. White managed to showcase a beautiful temporary rook sacrifice that led to a creation of connected passed pawns which ultimately gave white the material back and ultimately won the game. 
This result surprised me. If a 2800 elo engine has fallen victim to impatience and being overzealous because of the material advantage, a human surely can too. I'm not an expert so I can't really evaluate the position after it got locked and I don't know how it would play out if it was two humans, however I can easily see humans sacrificing and going for even worse attacks way earlier. The mental advantage Jerome Gambit can definitely catch some humans off guard, however I would never it would happen to an engine as well.
When I raised the question of the exchange of Queens, I received

Fruit definitely wanted the queen exchange to happen at first, the king was still in the open and the checks could prove a little annoying, plus exchanging the pieces when up the material is definitely a good idea. After [10]...Qb4, Fruit expected [11].Qxb4, however Stockfish played the [11].Qb5 move. Even though Fruit wanted the exchange to happen, [11]...Qxb5 would be followed by [12].Nxb5 with an attack on the c7 pawn. The only way to defend that pawn is [14]...Ne8, however after [13].Bf4 the pawn is still most likely going to fall. Black's pieces are still not developed, the knight on e8 blocks the access to an open file for the rook (and the other open file is blocked by the king). Apparently the engine thought that it no longer has any time to trade the queens, as development is more important. Can't make the use of the extra piece when most of them are hidden behind pawns after all. White used all this crucial time gained that way to create a solid position which then turned out to be impenetrable.  
stockfish_20060616_x64_modern  - fruit_2.1
computer vs computer, 2020

1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. Bxf7+



4...Kxf7 5.O-O Nf6 6.Nxe5+ Nxe5 7.d4 
Bxd4 8.Qxd4 Nc6 



So far, following in the path of Demon 1.0 - Rybka 2.3.2a (0-1, 53) and La Dame Blanche 2.0c - Rybka 2.3.2a (0-1, 41) from the Torneo tematico GaJero00–A PC Intel Pentium 4 630 3000 1, in 2009. 

9.Qa4 Qe7 10.Nc3 Qb4 11.Qb5 d6 12.Qd3 Be6 13.b3 Rhf8 14.Bd2 Qd4 15.Rae1 Rae8 16.Be3 Qxd3 17.cxd3 Nb4 18.Rd1 Ng4 19.Bc1 a5 20.d4 Nf6 

21.d5 Bd7 22.f3 h6 23.Rf2 b6 24.a3 Na6 25.Rc2 g5 26.h3 Re7 27.Ne2 Nc5 28.Rc3 Rfe8 29.b4 Ba4 30.Rf1 Nb3 31.Ng3 Kg6 32.Bb2 Rf7 

33.Rd3 Nd7 34.Nf5 b5 35.g4 Nb6 36.h4 Nc4 37.h5+ Kh7 38.Rf2 Ra8 39.Kh2 Ra7 40.Kg3 Ra6 41.Kg2 Rf8 42.Rc3 Raa8 43.Kg3 Rfe8 

44.Rg2 Ra7 45.Rd3 Rf8 46.Rf2 Rf7 47.Kh2 Ra8 48.Kg3 Re8 49.Re2 Ref8 50.Rf2 Rb8 51.Kh2 Rff8 52.Kg3 Rbe8 53.Rg2 Ra8 54.Rh2 Rad8 55.Rf2 Rb8 56.Re2 Rf7 57.Rh2 Rg8 58.Rg2 Rd8 59.Re2 Re8 60.Rg2 Rff8 61.Re2 Rg8 62.Rf2 Ra8 63.Rg2 Ra6 64.Re2 Rga8 65.Rg2 Rf8 66.Re2 Rf7 67.Rg2 Rb6 68.Rf2 Rf8 69.Rh2 Rb7 70.Rf2 Ra7 71.Rg2 axb4 



The fifty-move rule states that a player can claim a draw if no capture has been made and no pawn has been moved in the last fifty moves. Fruit 2.1 assesses itself as better, and, although it can not figure out a breakthrough, it does not want to give up the 1/2 point.

72.axb4 Raa8 73.Re2 Ra6 74.Rg2 Rf7 75.Re2 Ra8 76.Rg2 Re8 77.Re2 Ref8 78.Rf2 Rb8 79.Rh2 Rg8 80.Re2 Re8 81.Rg2 Ra8 82.Rh2 Rd8 83.Rf2 Rdf8 84.Re2 Rg8 85.Kh3 Ra8 86.Kg3 Rff8 87.Rg2 Rae8 88.Rf2 Rb8 89.Rh2 Rbc8 90.Rf2 Rcd8 91.Rh2 Rb8 92.Rc3 Rb7 93.Rd3 Rb6 94.Rf2 Rg8 95.Ne7 Re8 96.Nf5 Rf8 97.Re2 Rg8 98.Rh2 Ra6 99.Rf2 Raa8 100.Re2 Rgd8 101.Rf2 Rd7 102.Rg2 Ra6 103.Bf6 Rf7 104.Bb2 Ra7 105.Rh2 Rb7 106.Rg2 Rb6 107.Re2 Rd7 108.Rf2 Rb8 109.Rh2 Re8 110.Rg2 Ra8 111.Rh2 Rf8 112.Rf2 Rg8 113.Rh2 Rdd8 114.Rf2 Rb8 115.Rh2 Rb6 116.Rf2 Rb7 117.Rh2 Rbb8 118.Ne7 Rge8 119.Nc6 Rb6 120.Rg2 Kg8 121.Rf2 



Black is bumping up against the 50-move rule again. Perhaps its programming has a "contempt factor" built in, that prohibits it to offer a draw in this kind of situation. Of course, one way to get by the 50-move rule here is to play 121...Nxb2. Instead, Fruit 2.1 sacrifices the exchange.

121...Rxc6 122.dxc6 Ra8 123.Rd5 Ra7 



I expected that Fruit 2.1 would continue with its sacrifice-the-exchange plan and grab the extra pawn, i.e. 123...Ra6, and if 124.e5, then 124...Nxe5 125.Bxe5 dxe5 126.Rxe5 Rxc6 and my buddy, Komodo 10, sees the position as even.

Stockfish now shows the kind of creativity we expect from Jerome Gambit players.

124.e5 Ne3 

This does not work, as Stockfish is ready for it.

125.Rxd6 cxd6 126.exd6 

Suddenly, the "Jerome pawns" make their appearance. Despite the fact that Black has two extra Knights, White is better.

126...Nd5 127.Re2 Ra8 128.Re5 Nxb4 129.c7 Na6 



130.c8=Q+ Rxc8 131.d7 Rd8 132.Re8+ Kf7 133.Rxd8 Ke7 134.Ra8 Nb8 135.Rxb8 Kxd7 



White is clearly winning, but some programs don't resign, they wait until they are checkmated.

136.Rh8 Na5 137.Rxh6 Nc4 138.Rg6 Bc2 139.Rxg5 Nxb2 140.Rxb5 Na4 141.Rb7+ Kc6 142.Rb4 Nc5 143.Rc4 Bd3



144.Rxc5+ Kxc5 

Black has an extra piece, while White has extra pawns, an echo of the position 100 moves earlier.

145.f4 Kd6 146.f5 Ke7 147.Kf4 Bc4 148.g5 Bg8 149.g6 Be6 150.fxe6 Kxe6 151.h6 Kf6 152.g7 Kf7 153.Ke5 Kg8 154.Kf6 Kh7 155.Kf7 Kxh6 156.g8=Q Kh5 157.Qg3 Kh6 158.Qh4 checkmate

Sunday, August 2, 2020

Leela's Positional Masterclass in the Jerome Gambit


Yesterday's blog post was not very encouraging for either the Jerome Gambit (1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.Bxf7+) or the use of neural networks in chess analysis engines.

However, about a couple of weeks later, I received an email from Bob Derpson titled "Leela's Positional Masterclass in the Jerome Gambit"
I have recently stumbled upon your blog concerning the Jerome Gambit and have become very interested in the opening. 
While the gambit is often played as a means to for a tactically superior player to display the extent of their might against a weaker opponent, an aspect of the opening that is often forgotten is the severe hindrance in development that it poses to black. 
As a result, I believe traditional engine evaluations of the position to be inaccurate as they are not able to effectively gauge positional advantage due to their overvaluation of material. Likewise, humans will find it difficult to properly exploit black's positional disadvantage simply due to the way we have been trained to play chess. 
I decided to experiment with chess neural networks to discern whether or not the positional advantage for white in the Jerome can truly be translated into stone cold results.In doing so, I eventually stumbled on a truly fascinating game, held between Leela ID 62143 and Stockfish 1.0, with time controls of 1 second on each side plus 50 milliseconds increment.    
Let me say, right up front, that I have no idea how strong either of the chess engines are, or how they normally (i.e. not the Jerome Gambit) function at that time limit.

I do have to say, however, that Leela's play in the Jerome Gambit is jaw-dropping. My insights will be quite limited.

Leela ID 62143 - Stockfish 1.0
2020

1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.Bxf7+



4...Kxf7 5.Nxe5+ Nxe5 6.Qh5+ Kf8 



Analyzed by Alonzo Wheeler Jerome in the July 1874 issue of the Dubuque Chess Journal, and played by him, successfully, in two correspondence games against Daniel Jaeger in 1880.

7.Qxe5 d6 8.Qf4+ Qf6 9.d3 



Fascinating. Leela is willing to allow the exchange of Queens, blunting its attacking chances and throwing its lot in with the two extra pawns, against the extra piece.

The Database points out that, previously, programs GNU Chess, DrunkenMaster 1.2, WB Nimzo 2000b, Zarkov 4.7 and Comet B48 played this way, with only the last one being successful. That was over a decade ago, however, when engines were much weaker, especially when it came to positional evaluations.

9...Bd7 

According to The Database, a new move, and equally interesting: Stockfish is not interested in the exchange, either.

10.Qg3 h5 11.h4 Ne7 12.c3 Qe6 13.Bg5 Qg4 



Now, Stockfish is willing to exchange. Perhaps it is influenced by its improved development.

14.Qh2 Bb6 15.Nd2 Bb5 



Komodo 10 prefers 15...a6 16.d4 Re8, which makes sense to me. Soon, it will struggle to understand, as well. 

16.f3 Qd7 17.c4 Ba4 18.b3 Bc6 19.O-O-O Ng6 



White's play reminds me of earlier times when humans would adopt "close" openings against computers, such as the Stonewall Opening, hoping to outplay them in slow strategic games, rather than tactical conflicts. As computer programs became more knowledgeable about positional play, this "anti-computer" strategy became less effective. Is Leela reintroducing the idea?

20.Nf1 Kg8 21.d4 Qf7 22.Ne3 Kh7 23.Kb2 a5 



24.c5 

A positional sacrifice.

24...dxc5 25.d5 Bb5 26.a4 Ba6 27.Rc1 



27...Rhe8 28.Rhd1 Ne5 29.Nc4 Nxc4+ 30.bxc4 



Black's King is safe, but his Bishops look like they are out of the game.

30...g6 31.e5 Qg7 32.Bf6 Qd7 33.Kb3 Qf7 



It is at this point that Komodo 10 (in blunder check mode) assesses Stockfish to have turned over the advantage to Leela. Unfortunately, it recommends 33...Qf5 34.Ka2 Rf8 which is beyond my comprehension

34.g4 hxg4 35.fxg4 Kg8 36.h5 Qh7 37.Qd2 gxh5 38.gxh5 Kf8 39.Rg1 c6 

Bob Derpson notes
Here, Leela's trademark ability to shut its opponent's pieces out of commission is displayed in its full glory, locking out both of black's bishops out of the game entirely, whilst simultaneously garnering a huge spatial advantage, dominating the center. 
Of course, it is impossible of human chess players of today to emulate such behavior. But, perhaps, one day in the future, in a world where neural networks have truly made their mark on chess and in the way players are conditioned to think about the game, where the Jerome Gambit can finally show its true potential.
Oh, and Komodo 10 points out that White has a checkmate in 16 moves, too.

40.Qf4 Re7 41.Bxe7+ Kxe7 42.Qf6+ Kd7 43.Rg7+ Qxg7 44.Qxg7+ Kc8 Black resigned


Very impressive!

Saturday, August 1, 2020

Jerome Gambit: The Future Is Here


Last month I received an email from Mitchell Jansen, who noted
I recently discovered your blog about the Jerome Gambit and I was surprised by the amount of research you have put into it. I was hoping that I could help add to that by submitting a game played by two of the top chess engines in circulation today. Hopefully, through careful analysis of this game, we will be able to understand better the intricacies of the Jerome Gambit in the Giuoco Piano.
The two chess engines in the game were Stockfish and Leela Chess Zero. I was not familar with the latter, so I sought an explanation from Wikipedia
 Leela Chess Zero (abbreviated as LCZero, lc0) is a free, open-source, and neural network-based chess engine and distributed computing project. Development has been spearheaded by programmer Gary Linscott, who is also a developer for the Stockfish chess engine. Leela Chess Zero was adapted from the Leela Zero Go engine, which in turn was based on Google's AlphaGo Zero project, also to verify the methods in the AlphaZero paper as applied to the game of chess. 
Like Leela Zero and AlphaGo Zero, Leela Chess Zero starts with no intrinsic chess-specific knowledge other than the basic rules of the game. Leela Chess Zero then learns how to play chess by reinforcement learning from repeated self-play, using a distributed computing network coordinated at the Leela Chess Zero website. 
As of 2020, Leela Chess Zero had played over 300 million games against itself, and is capable of play at a level that is comparable with Stockfish, the leading conventional chess program.
Interesting! Lc0 was listed as having an Elo rating of 3616, while Stockfish 11 was rated at 3604 - indeed, the highest rated Jerome Gambit game that I had ever heard of. I invited a third computer chess program, Komodo 10 (rated in the mere 3300s), along, and decided to take a look.

Lc0 - Stockfish 11
45 15 computer chess, 2020
Stockfish 11 was running on an Intel Core i7-8750H CPU at 2.20GHz with 16 GB of RAM while lc0 was running on an NVIDIA GeForce GTX 1070 GPU. 

1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.Bxf7+ 



4...Kxf7 5.Nxe5+ Nxe5 6.Qh5+ Ke6



7.Qf5+ Kd6 8.f4 Kc6 

Defenders, take note.

9.Qxe5 Nf6 10.d4 

This is a typically aggressive Jerome Gambit move, that, superficially, blocks Black's dark-square Bishop, which is essential for White to castle. However, Komodo 10 was suspicious, preferring 10.d3, realizing that castling will not be possible, and resisting what danger might come down the e-file.

The Database has only 3 previous games with 10.d4, all wins by Black. This may be a result of 8...Kc6, which also only appears in those games.

10... d6 11.Qg5 

This is a new move, and, again, Komodo 10 disagrees - it is rated 300 points lower, of course it would disagree. It prefers 11.d5+ Kb6 12.Qc3 and a pursuit of the enemy King on the Queenside.

11...Bxd4 12.Qa5 Bc5 13.b4 Nxe4 



Stockfish willingly returns a piece, as White's Queen switch to the other side of the board leaves White' King at great risk.

14.bxc5 Qh4+ 15.g3 Nxg3 16.Be3 Nxh1+ 17.Kd2 Qxh2+ 18.Kc1 Ng3 

19.Nc3 Ne2+ 20.Kb2 Nxc3 21.Qxc3 d5 22.Rd1


White plays on, down a Rook. It no longer matters that Komodo 10 suggested 22.Rg1, instead.

22...Qe2 23.Qd4 Qc4 24.Qxg7 Qb4+ 25.Ka1 Re8 26.Qf6+ Re6


27.Qd8 Rxe3 28.Qxd5+ Kb5 29.Rb1 Re1 30.a4+ Ka6 31.Rxe1 Qxe1+ 32.Kb2 Qb4+ 33.Ka2 Qxa4+ 34.Kb2 Qb4+ 35.Ka1 Qxf4 36.Qd3+ 

If this were a human vs human game, I suppose this would be referred to as a "spite check".

36...Ka5 37.c4 Qc1+ 38.Ka2 Be6 39.c6 Bxc4+ 40.Qxc4 Qxc4+ 41.Kb2 Rd8 42.Ka3 Qc2 43.cxb7 Rd3 checkmate.



To quote Sean Connery's character in the movie "Zardoz", "I have seen the future, and it doesn't work."

Saturday, July 25, 2020

Jerome Gambit: How's That For A Kick In The Head?



It is quite possible that playing the Jerome Gambit (1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.Bxf7) at slower time controls allows you to absorb enough knowledge about the opening that you can play it at a very fast speed, as well. Here is a third game from our featured anonymous player. It finishes with a bang that is overwhelming - maybe the defender could find a way out, if only he had enough time...

Anonymous - Anonymous
1 0 bullet, Chess.com, 2020

1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.Bxf7+ 




4...Kxf7 5.Nxe5+ Nxe5 6.Qh5+ Ng6 7.Qd5+ Ke8 8.Qxc5 d6
9.Qe3 Nf6 

This position goes back at least as far as the game Charlick - Mann, correspondence, Australia, 1881 (1-0, 72).

10.Nc3 Bd7 

This move is new, according to The Database. It develops a piece, modestly, and avoids percipitating f2-f4, which would have happened after 10...Be6, and avoids forcing White to strengthen his center, with 10...Bg4 11.f3.

11.d4 Kf7 12.f3 Re8 13.b3 Kg8 14.Bb2 



Black has castled-by-hand. White has a solid, but not particularly mobile, center.

14...a5 15.a4 c6 16.h4 

With aggressive intent.

16...Nh5 17.Ne2 Nxh4 

I don't think that the pawn is worth the risk.

18.O-O-O 

The reason he took Kingside liberties with his 16th move: His Majesty is going Queenside, a very reasonable decision that can be made in an eyeblink, even with the risks that sometimes occur when Kings find their homes on opposite sides of the board.

There was also the possibility of 18.Qf2 directly, but it leads to the kind of messy play you might want to avoid in bullet chess: 18...g5 19.g3 Rf8 20.gxh4 g4 21.Rg1 Qf6 22.Ba3 Qxf3 23.Qxf3 Rxf3 24.Bxd6 and it is not clear whose passed pawn is better, and if the whole thing is going to boil down to a Bishops-of-opposite-colors ending that would be quite drawish.

18...b5 19.Nf4 

Tricky, relying on the Rook on the open h-file, but 19...Ng3 is a proper response. Again, he could have considered 19.Qf2.

19...Nxf4

That's the thing about bullet play: aggression is often rewarded because defense takes time to figure out. 

20.Qxf4 Ng6 21. Qxd6 bxa4 22. d5 axb3 



There's aggression on both sides of the board.

23.Rxh7 

"How's that for a kick in the head?", as they used to say.

Stockfish 10 says that Black can take the Rook and still draw, but computers do not live in the real world. I'm pretty sure Black crossed his fingers for luck and played...

23...bxc2 

Grandmasters might play: 23...Kxh7 24.Rh1+ Nh4 25.Qg3 g5 26.Rxh4+ Kg6 27.dxc6 Rc8 28.f4 Rxe4 29.cxd7 Rxc2+ 30.Kb1 Rxb2+ 31.Kxb2 Qf6+ 32.Kb1 Rd4 33.Qg4 Qf5+ 34.Qxf5+ Kxf5 35.fxg5 Rxd7 36.Kb2 Rd2+ 37.Kxb3 Rxg2 38.Ka4 Rxg5 39.Kxa5 and each would then complain about "losing a point".

If it's any consolation, 23...Ne5 24.Rh5 bxc2 would probably lead to a draw, as well.

24.Rxg7+ Kh8 25.Rh1+ Nh4 26.Qh6 checkmate



Very, very nice.