# Question
Title: Information request for new FIDE certified ‘electronic scoresheet’
According to the latest FIDE Laws of Chess a FIDE certified ‘electronic scoresheet’ may be used instead of a regular old fashioned paper scoresheet.

> 8.1.1 In the course of play each player is required to record his/her own moves and those of his/her opponent in the correct manner, move after move, as clearly and legibly as possible, in one of the following ways:
>
> 8.1.1.1 by writing in the algebraic notation (Appendix C), on the paper ‘scoresheet’ prescribed for the competition.
>
> 8.1.1.2 *by entering moves on the FIDE certified ‘electronic scoresheet’ prescribed for the competition*.

Is there any more information on these electronic scoresheets?

# Answer
> 3 votes
According to this press release from FIDE:

> The International Chess Federation has approved allowing the use of Clono electronic scoresheet to record the moves of the games at official chess competitions, in replacement of traditional, paper-based scoresheets.
>
> The Clono scoresheet app runs on a tablet, and the input is done on a graphical chess board where the scoresheet is presented in standard algebraic format.
>
> The system offers smooth integration with other existing tools. For instance, it can automatically create a tournament profile with tournament info, time control, groups and players, simply importing the tournament xml-file directly from the tournament management service. It can receive the player’s and game info, pushed directly from the pairing program. Likewise, Clono can send the PGN live feed to its own broadcast server and multigame viewer, as well as to third party websites.

FIDE have also published a document called call TESTING REPORT – ELECTRONIC SCORESHEETS which presumably indicates the tests which the Clono device has passed which are FIDE requirements.

There is more information on the Clono website.

Currently traditional scoresheets are "the property of the organizer" and appear next to the board for the players' use during the game. The new electronic scoresheets, which are tablets running an app, will be also provided by the organizer and set up in conjunction with the pairing program, if it is the right one. For now only TournamentService, no Swiss Manager as far as I can see!

**DGT Killers**

Their ability to broadcast the game in the same way as a much more expensive DGT board is going to introduce serious competition for DGT. Currently I know of only two clubs and one organizer who have invested in DGT boards. This is going to open up this technology for lots more small organizations.

This is spelled out on the Clono site:

> Clono combines electronic chess notation with live broadcast of chess tournaments in an easy, affordable and secure way. It is easy to use and set up, and there is no need for electronic chess boards, cabling or an on-site engineer.

Pre-Covid the ECF (English Chess Federation) ran occasional courses on setting up and using DGT boards for broadcast. This was a complicated process involving wiring up the boards, attaching them to a laptop with the right software set up, configuring the software to get it to collect the data from the boards and to broadcast it. Finally the laptop had to be monitored for errors (user and internet drop out, etc.) and manual intervention done to keep it all working. This new device could make all that obsolete.

**Costs**

Two killer lines from Clono:

> Clono is approved by FIDE for use in official chess tournaments.

> Clono is free to use.

It looks like the only cost for the moment is a cheap (or at least not too expensive) Android tablet. Let's see how long that lasts.

Here's what they say about hardware requirements:

> For best user experience for the players, we recommend using the app on 10-inch tablets. The app is thoroughly tested on Lenovo Tab 10 and Tab4 10 tablets, which are in the lower price range with a price around 120 Euro. Clono Scoresheet can also be used on 7-inch tablets and is thoroughly tested on Lenovo Tab 7 with Android 7.0 and 7.1.

Update 2022: Lenovo Tab M10 HD Plus (2nd Gen) is a new model in the lower price range. It has good battery performance with Clono, and it is tested thoroughly in many tournaments.

> The app is only available for Android, not iOS (iPad) as iOS devices are much more expensive and considered less relevant for tournament use

**Information for organisers**

> The tablets should have an administrative lock to prevent any malicious software from being installed on the tablets. In our Help center, you will find articles on how to easily lock down the tablets.
>
> The WiFi for Clono tablets should be protected with WPA-encryption or better (not WEP).

Clono has very low power consumption, and on most tablets, it is no problem running a double round before recharging the tablets.

> An administrator can easily monitor the battery status in the Admin Panel. In case of low battery, a warning will appear in the Admin Panel.
>
> In case of a malfunction, a tablet ca be quickly replaced with a spare tablet. The replacement procedure takes approximately one minute, and the new tablet will resume to the latest game state (no need for manual recreation of the game).
>
> When needed, it is possible to define a custom delay of the live feed in the Admin Panel. A logged in administrator can still watch the games without delay.
>
> If the network breaks during the games, the only consequence is that the live transmission is delayed. The scoresheet used by the players will work regardless of network status.

**Information for arbiters**

> It is recommended to do a short intro of Clono to the players before round 1.
>
> Additionally, a paper printout with user instructions can be put on the tables (download paper printout).
>
> It is recommended to let players opt out and use pen and paper scoresheet if they feel uncomfortable using Clono electronic scoresheet (e.g because of age or disabilities).
>
> In case a player wants to bring a paper copy of the game home, a standard scoresheet with the algebraic notation can be printed from clono.no.
>
> In case of game investigation, a copy of all game states is saved on the tablet and available under the recovery menu.
>
> If the players sign for the result in a result protocol, it is recommended to add a remark to the protocol that in case of a dispute of the signed result, the electronic game documentation prevails.

**Tournament and Tablet Set Up**

> For tournament use of Clono, a user account on Clono Admin Panel is required. If you do not have an account, register here. Please note that the account is subject to manual approval.
>
> In the Admin Panel the tournament is set up with tournament details, groups, players and games. If you are using TournamentService for tournament management and pairing, the data can be imported directly to Clono. If you use other tournament management software, the tournament creation and pairing can be configured manually in Clono Admin Panel.
>
> The tournament is automatically given a pin code in the Admin Panel, and this pin code is used for connecting the tablets running Clono to the server. Each tablet is allocated to a fixed table or a player, and when everything is ready set up, the game details are transmitted to the tablets.

---
Tags: fide, scoresheet
---


# Question
Title: Can the games in Chernev's Logical Chess Move by Move be played in any order?
In Chernev's Logical Chess Move by Move, can the chapters and games be absorbed in any order, or are they intended to be played through in order?

# Answer
> 2 votes
It helps to know something about the structure of the book. There are just 3 chapters in which 33 games are fully annotated. That is every move, even ones like 1. e4 or 1. d4, is annotated with comments, sometimes copious and often anodyne.

These are the chapters:

1. The King-Side Attack (16 games)
2. The Queen's Pawn Opening (7 games)
3. The Chess Master Explains His Ideas (10 games)

It's worth noting that in chapter 3 the "Chess Master" explaining "his" ideas is not the player playing the game. It is Chernev.

With every move "fully" annotated, sometimes in painful detail, there is no need to read / absorb any one game before any other.

For instance, the first game (game 24 in the book) in chapter 3 starts with over half a page of annotation for the first move of the game, 1. d4. I was tempted to reproduce that in full, but life is too short and I would likely fall asleep half way through. So, here is just the last paragraph:

> White's move of the Queen Pawn begins the process of getting *all* the pieces into play as quickly as possible. Two of them are now free to make their debut, while the Pawn which released them occupies the center of the stage.

I'm sure those cliched (if true) sentiments have been expressed several (if not many) times previously in this book. Note that this paragraph is preceded by two much longer paragraphs on the general idea of queen's pawn openings despite the fact that the previous chapter was all about - queen's pawn openings.

No, it really doesn't make any difference what order you tackle these chapters and games.

---
Tags: books
---


# Question
Title: How did the Grand Prix Attack get its name?
The moves 1. e4 c5 2. Nc3 Nc6 3. f4 characterize the Grand Prix Attack in the Sicilian defense.

```
[Title "Grand Prix Attack"]
[StartPly "5"]
[FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"]

1. e4 c5 2. Nc3 Nc6 3. f4

```

How did the Grand Prix Attack get its name?

# Answer
> 8 votes
From this page, I quote

> The Grand Prix Attack got its name from the many strong British players who used it on the Grand Prix Circuit in the 1980's

As Remco Gerlich said, It was used by British players on the British Grand Prix circuit. Weekend tournaments that also have a combined standings.

# Answer
> 1 votes
Whilst the other answers are not wrong, I'd like to draw specific attention to FM David Rumens, who won a series of Grand Prix tournaments in the 70s and 80s using this "Grand Prix" opening.

He always said it was his favourite opening to play against the Sicilian and it's not unreasonable to suggest that the name came about due to his success with it.

He taught me chess as a child and was a phenomenal mentor and character and I don't see enough references to him in discussions about the Grand Prix.

---
Tags: opening, history, sicilian-defense
---


# Question
Title: When to weaken king's position to attack opponent's king with pawns?
I have seen few times, masters use their f,g,h pawn to attack opponent's king (even if the player castled kingside). Whenever I see a weak position of king, I suspect, king is "under attack" (not now, but sooner it will be). What's the philosophy behind the attack?

My thought process :

1. **Center has to be closed** (closed-center favors the attackers. In one of my Magnus's game, his opponent started attacking with pawn storm and center was closed so Magnus, at first, started opening up the center then attack, nonetheless he lost. In that game, they castled opposite side. Magnus queenside and opponent kingside. I am not that professional to memorize the whole game neither I don't remember when it was played, perhaps recently).
2. Opponent's attacking piece should be on the opposite side.
3. Player's minor piece will defend the king and pawns will attack the opponent king.

(After writing the question, I remembered another thought process, but I didn't have time to open up the site)

4. When player puts a bishop on b2 or g2 square (b7 or g7 from black's perspective), they can throw their pawns. Opponent most of the time tries to exchange the bishop, to weaken the bishop's square (In Silman's book, he even mentioned to trade the bishop unless sometimes, it might be stuck by tall pawn). (I generally don't put my bishop there and I try to open up the file for rook by throwing only f pawn, g and h pawn forever remains there until endgame)

Is there anything else, I have to keep in when attacking with pawns? Even when Stockfish says to use pawn storms to attack the opponent king, I just scare that king is open.

I remember once, (I was much more weak player that time, around 1100 in chess.com), I used my pawns to attack the king while weakening my king. But the opponent managed to close the kingside then started attacking on queenside, I had huge advantage for advanced pawn but I lost, cause I was scared of my weaken king and opponent managed to hunt my weak king, even I tried to won the game (when the eval dropped-down to equal), that's why I just lost.

# Answer
The strategy isn't same at all level. I was playing in a tournament (rapid tournament so I forgot the game, can't even recall a single position (middlegame) to analyze) where I pushed kingside pawn.

My strategy was simple :

1. No minor or major pieces is traded (trading few pieces doesn't affect it).
2. Major pieces are attacking (and defending) from large distance of the enemy king.
3. 1 or 2 minor pieces are defending (sometimes 1 is enough depending on the position (when opponent's attack isn't strong enough)).
4. It's better if center is closed (The following example is also valid)

```
[FEN "8/8/8/2p1p3/2PpP3/3N4/8/8 w - - 0 1"]

```
5. You should ask yourself does my opponent have any counter play on the Queenside to create some attack from opposite side of the board. Not instantly but after 5-10 moves later (if your attack takes much more time).
> 0 votes

# Answer
Abstract questions hardly ever have final answers in chess. Specific threats will always take precedence over deeper strategic concepts. Still:

You're right in your principles. For example if the kings are castled on opposite sides of the board, players can be a bit more careless about the way they storm the enemy king with pawns. For instance, in this example White doesn't have any trouble attacking with the "g" and "h" pawns, even if that requires a sacrifice, in order to open the "h" file and harass the enemy king (note also the trade of the dark-squared bishops to remove defenders around the Black king).

As for pushing pawns on the side your own king is castled, it's true that one must be more careful. It's not really about the center being closed but rather about the opponent not being able to make a significant strike against it:

This is a typical example where White struggles to open up the center while Black hits hard on the kingside.

Here you can see a game where White attacked with the "g" pawn in front of their king. The reactions on e5 or d5 by Black don't achieve much and by playing g4-g5 White is also kicking away a knight that had influence on the center. Eventually White can bring their pieces to the kingside and start an attack.
> 1 votes

---
Tags: pawns, attack, king-safety
---


# Question
Title: Why taking the knight on d5 in Alapin Sicilian is not so good for white
I'm going through some preparation of the Alapin Sicilian. Studying the opening I reached this position:

```
rnbqk2r/pp2bppp/3pp3/3nP3/2BP4/5N2/PP3PPP/RNBQK2R w KQkq - 2 8

```

In which I wonder why it isn't good for white to take on d5 and give black doubled pawns.

Is because giving the bishop pair in this position is simply too much to just cause doubled pawns to black or are there other reasons? Could you please come up with an example explaining why Bxd5 here is a bad idea?

# Answer
> 3 votes
> I wonder why it isn't good for white to take on d5 and give black doubled pawns.

There are a number of problems with this:

1. First, the doubled (and isolated!) pawns are at best temporary because white has a pawn on e5 which black can take to eliminate the doubled pawns. (Note, by the way, that the suggestion that black can avoid doubled pawns in the first place with the intermezzo Qa5+ and then Qxd5 is wrong. White counters the check with Nc3 protecting the d5 bishop and black has wasted a move forcing white to play a good developing move that was going to be played anyway)
2. Giving black the opportunity to move the e6 pawn improves black's position because it unblocks the bad c8 bishop which otherwise has restricted mobility.
3. A much better move is Nc3 which threatens to win a pawn. O-O is also better.

Here is what is likely if white plays Bxd5

```
[fen "rnbqk2r/pp2bppp/3pp3/3nP3/2BP4/5N2/PP3PPP/RNBQK2R w KQkq - 1 1"]

1. Bxd5 (1. Nc3!) (1. O-O!) exd5 (1...Qa5+? 2. Nc3) 2. Nc3 dxe5 3. dxe5 Be6

```

The resulting position is probably very even.

# Answer
> 0 votes
Yes, it doesn't favor white. I am assuming it's white to move.

1. Bxd5 exd5

What's your next move? You can play exd6 but Qxd6 and now you both have isolated pawn. I believe (don't know what does engine say) it's in black's favor (black have slight advantage for the bishop pair; perfect play might draw the position). ~~You should note that there's Qa5+ which can take d5 instead of exd5. (It doesn't work for Nc3.)~~ So you don't doubled the pawn. Hence why giving up the bishop for nothing (which isn't in your favor)?

---
Tags: sicilian-defense, evaluation
---


# Question
Title: Does a reinforcement learning style model actually need to be combined with a search algo to produce the best moves?
I have recently been studying up on Machine Learning based chess engines and have begun to develop one of my own. I was wondering, realistically, doesn't the board technically contain all of the data used to predict any number of moves into the future? From what I can tell, models like AlphaGo use a search algorithm to pick which moves it should investigate further in order to make its move.

what if a RL model were to just be trained on the current position, not any other data besides what anyone could see from looking at the board. through training, would the model develop its own method of searching for future moves in order to maximize its reward potential in a game naturally?

I assume that if the model developed its own algo it would be significantly faster and more optimized at returning good moves with a depth level that would make it competent at the game.

Is there something I am missing?

# Answer
Are you talking about static evaluations? No it’s not sufficient to play a good game. In chess, even a single pawn push might change the evaluation of the position. There are too many possibilities, so no engine will be successful without a search algorithm. What’s the point of a good pawn structure if your opponent can force a checkmate? A good model can guide a search algorithm better but it’s not a replacement.
> 1 votes

# Answer
Pure reinforcement learning with current neural network architectures for chess will, if done well, produce an opponent that is surprisingly strong; I can certainly see such a program beat master level players, especially if they are unaware of whom they are playing against. It will however fall far short of chess programs that incorporate some form of search. Typical machine learning algorithms (here: neural networks) are fundamentally limited by being algorithms that process a given input in a fixed time, i.e. they cannot by themselves take advantage of more time to think. Algorithms that combine good static evaluation with look-ahead, on the other hand, will get a lot better when allowed to do some search. Competitive programs therefore use search.

That said, it is possible to try out in practice just how well a naked neural network can play, for instance by playing LC0 while requiring an instant response at each turn. To illustrate, I have just generated a game of LC0 under such conditions against the *hard* level of *Shredder Chess Online*; I would estimate that that opponent is roughly low candidate master level:

```
[FEN ""]
[Event "Test game"]
[Date "2023.01.08"]
[Round ""]
[White "Player"]
[Black "LC0"]
[Result "1/2 - 1/2"]

1.e4 c5 2.c3 Nf6 3.e5 Nd5 4.Nf3 Nc6 5.d4 cxd4 6.Bc4 Nb6 7.Bb3 d5 8.exd6
Qxd6 9.O-O Be6 10.Na3 Bxb3 11.Qxb3 e6 12.Nb5 Qd7 13.Nxa7 Rxa7 14.Qxb6 dxc3
15.Be3 Ra6 16.Qb3 cxb2 17.Qxb2 f6 18.Rfd1 Qc8 19.Rd3 Be7 20.Rb3 Na5 21.Rc1
Qd7 22.Rbc3 O-O 23.Rc7 Qd8 24.Qb5 Ba3 25.R1c3 Qd1+ 26.Qf1 Qxf1+ 27.Kxf1
Bd6 28.Rd7 Rf7 29.Rc8+ Rf8 30.Rc1 Rf7 31.Rc8+ Rf8 32.Rc1 Rf7 33.Rc8+ 1/2-1/2

```

The Maiabots on lichess are, as far as I know, another example of pure policy network opponents that are publicly available. They do, however, play significantly weaker than the LC0 policy.
> 1 votes

---
Tags: engines, learning, alphazero, chess-algorithms, chess-ai
---


# Question
Title: How can I get a chess engine to play custom chess variants?
How can I get a chess engine to play custom chess variants, for example Los Alamos chess, anti-chess, or chess where pawns can only advance one square?

# Answer
Your best bet is Fairy-Stockfish, which is built on Stockfish 14 and supports dozens of piece and board variants, including custom variants! For example, here is how the "Indian Great Chess" variant, played on a 10x10 board, is defined:

```
# Indian great chess
# https://www.chessvariants.com/historic.dir/indiangr1.html
[indiangreat]
pieceToCharTable = PNBRQ..VW.........G..Kpnbrq..vw.........g..k
pawn = p
knight = n
bishop = b
rook = r
queen = q
king = k
archbishop = v
chancellor = w
amazon = g
maxRank = 10
maxFile = 10
startFen = rnbqkgvbnr/ppppwwpppp/4pp4/10/10/10/10/4PP4/PPPPWWPPPP/RNBVGKQBNR w - - 0 1
promotionRank = 10
promotionPieceTypes = q
doubleStep = false
castling = false

```

Here is a custom variant where pawns cannot advance two squares:

```
[singlestep:chess]
doubleStep = false

```

```
[Title "A sample game: depth 30"]
[FEN "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"]
[Event "Single step pawns: Fairy Stockfish 14 Depth 30"]
[Site "https://lichess.org/study/bFDVIuGM/LcTmHREr"]
[White "Fairy Stockfish 14"]
[Black "Fairy Stockfish 14"]
[Result "1/2-1/2"]
[UTCDate "2023.01.08"]
[UTCTime "03:38:53"]
[Variant "Standard"]
[ECO "A00"]
[Opening "Mieses Opening"]

1. d3 Nf6 2. Nf3 d6 3. Bf4 Nbd7 4. h3 g6 5. e3 Bg7 6. c3 O-O 7. Be2 b6 8. O-O Bb7 9. Bg3 Re8 10. Nbd2 e6 11. d4 e5 12. Bh4 h6 13. a3 a6 14. Nh2 h5 15. Re1 d5 16. Qc2 Qe7 17. dxe5 Nxe5 18. Nhf3 Rac8 19. Rad1 Nxf3+ 20. Nxf3 Qc5 21. Nd4 c6 22. Nb3 Qf8 23. Nd2 Re6 24. Bg5 b5 25. a4 Qc5 26. axb5 axb5 27. Qb3 Qb6 28. c4 Nd7 29. cxd5 cxd5 30. Qxb5 Qxb5 31. Bxb5 Nc5 32. Rb1 Rb6 33. Bf1 Ne6 34. Bh4 Rc2 35. Nf3 Rcxb2 36. Rxb2 Rxb2 37. Bg3 d4 38. Nxd4 Nxd4 39. exd4 Bxd4 40. Kh2 Kf8 41. Kg1 Rc2 42. Bd6+ Kg8 43. Bg3 Rb2 44. Kh2 h4 45. Bxh4 Bxf2 46. Bxf2 Rxf2 47. Kg3 Rd2 48. h4 Bd5 49. Be2 Rb2 50. Bf3 Bxf3 51. Kxf3 Kg7 52. g3 Kf6 53. g4 g5 54. h5 Rb4 55. Re4 Rb3+ 56. Re3 Rb1 57. Kg3 Ra1 58. Rc3 Kg7 59. Rc4 Ra3+ 60. Kf2 Rb3 61. Rc5 Rb4 62. Rxg5+ Kh6 63. Ra5 Rxg4 64. Kf3 Rb4 65. Kg2 f6 1/2-1/2

```
> 5 votes

---
Tags: engines, chess-variants
---


title: How to merge multiple pgn files?

text:
# Question
Title: How to merge multiple pgn files?
Merging two pgn files is an operation, that makes just one game variation, and the one of the game gets added as a variation to the other game. If both the games have similar opening, then the similar opening moves are eliminated and a variation is created at the point when both the games starts to differ.

In Chessbase software (or any other chess tools), it is easy to merge normal chess games, we just copy the game and paste it into another, and it gets added as a variation. If if we have to do this for multiple games, it get laborious and manual process of merging. It will be good if some automated script exists for this purpose.

# Answer
A piece of code that works perfectly for merging pgns is.

https://github.com/permutationlock/merge-pgn

The code is not regex heavy, thanks to python-chess library. It can merge several pgn games into a single pgn with one game including all moves as variations.

All headers and comments are ignored as this is designed only to manipulate the move lines.
> 3 votes

# Answer
I looked at the merge-pgn tool and made some modifications to it to have support for also merging text comments and also software comments/annotation (arrows and circles etc). There are some technical caveats but it works. The modified version is available here.

For those who can't be bothered to install Python, and who doesn't have Chessbase, chesstempo is another free tool that also does real PGN game merging, but there are some issues with that.

In order to get a clean merge, you have to remove all existing repertoires and reload the page before uploading the PGN files to merge, and then export them. If you are already using the opening trainer at chesstempo.com you would have to first export/backup your repertoires and then re-upload them afterwards which could be a nuisance. Also, while it does merge the text comments, it doesn't really merge the annotations (arrows and circles), and it will also include annotations from repertoires of the opposite color (hence the reason why you need to remove all repertoires before you begin). There is a discussion regarding these subtleties at the site's forum.
> 3 votes

---
Tags: pgn
---


# Question
Title: Achieving e4 pawn push after 1.d4 opening
Is there a reasonable way for me to start with 1.d4 and be able to push (without gambitting) the e-pawn to e4. I am happy to do this without playing c4 first, and also it is ok if I get this pawn exchanged with Black's d-pawn (or f-pawn) as long as I get a piece (say the knight from c3) to recapture on e4.

Basically, I want my pawn on d4 and my knight on e4.

**Is there any logical move order to (almost) force this?**

Why is it somehow easier to do this with e and d switched: push 1.e4, 2.Nf3, then push d4.

1. the reason I don’t want 1.e4 version is that I want to end up with a pawn on d4 rather than on e4.
2. 1.d4 d5 2.Nc3 Nf6 and now I have neither c4 nor e4 pushes. I like the look of this opening but with White I get nothing or even am often worse.

# Answer
I haven't played or studied it myself, but White's aim in the Colle System is to play e4 after due preparation starting with 1. d4. Quoting Wikipedia:

> The **Colle System**, also known as the **Colle-Koltanowski System**, is a chess opening system for White, popularized in the 1920s by the Belgian master Edgard Colle and further developed by George Koltanowski. Quoting Wikipedia:
>
> The Colle is characterized by several moves. White's center pawns are developed to d4 and e3, the king's knight is developed to f3, the king's bishop is developed to d3, and the queen bishop's pawn (c-pawn) is developed to c3. Common continuations include development of the queen's knight to d2 (Nbd2) and kingside castling (0-0). **A major theme of the Colle System is the ambition to play a well-timed e4,** where the square is defended by the bishop at d3, the knight at d2 (following Nbd2), and possibly the rook at e1 (following 0-0 and Re1). Although sometimes described as a specific sequence of moves, the Colle System is not a fixed line of play, but rather a system for White where the moves may be permuted at the player's discretion. When a game opens with most or all of the above moves, to the exclusion of moves which typify other openings, the game may be described as "a Colle System".
> 3 votes

# Answer
There is a standard opening which has your idea as one of the ideas of the opening. That is the Veresov opening. Basically white starts with the moves d4, Nc3, Bg5 and then at some stage the move Qd3 or the pawn move f3 prepares the e4 push.

Here is the 2014 game Nakamura - Karjakin where Nakamura achieved e4 followed by Nxe4 on move 10. Annotations are by YouTuber Kingscrusher. You can see his video covering this game here.

```
[Title "Nakamura - Karjakin, Baku 2014"]
[fen ""]
[Startply "19"]

1. d4 Nf6 2. Nc3 d5 3. Bg5 Nbd7 4. Qd3 (4. Nf3 g6 5. e3 Bg7 6. Bd3 O-O 7. O-O c5 8. Re1 b6 9. e4) 4... c5 (4... c6) 5. O-O-O (5. dxc5 e6 6. O-O-O Qc7 7. Nh3 a6 8. Kb1 Bxc5) (5. Bxf6 Nxf6 6. dxc5 e6 7. e4 Nxe4 8. Nxe4 dxe4 9. Qxe4 Bxc5 10. Bb5+ Bd7 (10... Kf8) 11. O-O-O) 5... c4 6. Qg3 (6. Qf3 e6 (6... Qa5 7. e4 Nxe4) 7. e4) 6... Qa5 (6... a6 7. e4 b5 8. Nxd5 Nxd5 9. exd5) (6... e6 7. Nb5 h6 8. Nc7+ Ke7 9. Qa3+) 7. e4 (7. Nf3 b5 8. e3 b4 9. Ne2 Ne4 10. Qh3 Qxa2) 7... b5 (7... dxe4 8. Bxc4) (7... e6 8. exd5 exd5 (8... Nxd5 9. Nxd5 Qxd5 10. Kb1) 9. Re1+ Be7 10. Bxf6 Nxf6 11. Qxg7) 8. Kb1 (8. exd5 b4 9. Nb1 (9. Nce2 Qxa2) 9... Qxa2 10. Nf3 c3 11. bxc3 Ne4 12. Qf4 bxc3) (8. Nxd5 Nxd5 9. exd5 Qxa2) 8... dxe4 (8... Nxe4 9. Nxe4 dxe4 10. Ne2 b4) (8... e6 9. exd5 b4 10. dxe6 fxe6 11. Re1 bxc3 12. Rxe6+ Kd8 13. Bxc4) 9. Bxf6 gxf6 (9...exf6 10. Nd5 (10. Nxe4 Be7 (10... Bb7 11. Nc3)) 10... Rb8 11. f3 exf3 12. Nxf3 Bb7 13. Nf4) (9... Nxf6 10. Qe5 Ng4 11. Qxe4 Rb8) 10. Nxe4 (10. Nd5 Rb8 11. Nc7+ Kd8 12. Nd5 Bb7) 10... Bb7 11. Nc5 (11. Nc3 b4) (11. d5 Bxd5 12. Rxd5 (12. Qe3 Bxe4 13. Qxe4 Rc8 14. Ne2 Qb6 15. g3 e6 16. Bg2 b4 17. Nd4 Nc5 18. Qe2 Na4 19. Qg4 Nc3+ 20. bxc3 bxc3+ 21. Nb3 Bh6) 12... Qe1+) (11. f3 Rc8) 11... Nxc5 (11... Bc6) 12. dxc5 Rc8 (12... e6 13. Nh3 Bxc5 14. Qg7 Rf8 15. Nf4) 13. Be2 (13. Nf3 Rxc5 14. Be2 Qc7) 13... Qc7 14. Qh3 (14. f4 Qxc5 15. Nf3) 14... Bg7 (14... Qxc5 15. Qd7#) 15. Bf3 Bxf3 16. Nxf3 e6 (16... O-O 17. Rd7 (17. Nd4) 17... Qxc5) 17. Rhe1 O-O 18. Rd4 Qxc5 19. Rg4 Rfd8 (19... c3 20. Qh6) (19...Kh8) (19... f5 20. Rg3 Kh8) 20. Qh6 Qf8 21. Qxf6 Kh8 22. Qf4 Rd5 (22... Qb4 23. Rxg7 Qxe1+ 24. Nxe1 Rd1+ 25. Qc1 Rxc1+ 26. Kxc1 Kxg7) 23. Ng5 Rf5 24. Qe3 Rd8 25. Rh4 (25. Re4 c3 26. bxc3 Qa3 27. c4 Qb2#) 25... Kg8 26. Rg4 (26. Rxh7 Rxg5 (26... Re5 27. Qc1 Rxg5 28. Qxg5 Kxh7)) (26. Nxh7 Qb4 27. c3 Qa4 (27... Bxc3 28. Qxc3) 28. Rc1 b4 29. Rxc4 (29. cxb4 Qxb4 30. Qe2 Rd2) 29... Kxh7) 26... h5 27. Re4 (27. Rg3 Re5 28. Qc1 Rxe1 29. Qxe1 Qb4 30. c3 (30. Qxb4 Rd1#) (30. Qc1 Rd1 31. c3 Qd6) 30... Qa4 31. Kc1 Qxa2 32. Nf3 Qa1+ 33. Kc2 Qa4+ 34. Kc1 b4) 27... Qb4 (27... Rfd5 28. Rc1 c3 29. bxc3 Rc8) 28. c3 (28. Qc1 Rxg5 29. c3 Qc5) (28. b3 Rfd5 29. c3 Bxc3) 28... Bxc3 29. Qxc3 Qxc3 30. bxc3 Rxg5 31. g3 Kg7 32. Kc2 Rd3 33. f4 (33. h4 Rf5 34. f4 Rxg3) 33... Rgd5 34. R1e2 Kf6 35. a4 (35. a3 h4 36. gxh4 Rf3 37. Rd4 Rxd4 38. cxd4 Rxf4 (38... Rxa3)) 35... a6 36. Rf2 Kf5 37. Re5+ Rxe5 38. fxe5+ Kg6 (38... Kxe5 39. Rxf7 h4) 39. a5 (39. Rf6+ Kg7 40. Rf2 Re3) 39... Rd5 40. Re2 Kf5 41. Rf2+ Kg6 (41... Kxe5 42. Rxf7 Ke4 43. Ra7) 42. Re2 Rd3 43. Re4 Rf3 44. Rd4 Rf2+ 45. Kb1 Rxh2 46. Rd6 Rg2 47. Rxa6 Rxg3 48. Kb2 b4 49. cxb4 (49. Rb6 Rg2+ 50. Kb1 h4 51. Rxb4 h3 52. Rb2) 49... Rb3+ 50. Ka2 Rxb4 51. Ka3 Rb5 52. Ka4 Rc5 53. Rb6 (53. Kb4 c3 54. Kxc5 c2) 53... c3 54. Rb1 c2 55. Rc1 h4 56. a6 h3 57. a7 Rc8 58. Kb5 h2 59. Kb6 Rh8 (59... Kf5 60. Rxc2 Rxc2 (60... h1=Q 61. Rxc8) 61. a8=Q) 60. Rh1 Kf5 0-1

```
> 0 votes

---
Tags: opening, pawn-structure, 1.d4, center
---


# Question
Title: Legal positions with one color to move only?
Most positions in chess can be reached with both black or white to move.

Some positions are only legal with one color to move. One such position is the *starting position*, which famously can't be reached with black to move. This is because knight moves preserve parity.

**How many such positions are there?** (excluding *checks*, which can only be reached with the threatened side to move).

A large and trivial family of such positions are all the knight permutations. These all have a unique side to move due to parity

```
[Title "White to move"]
[fen "r1bqkb1r/pppppppp/8/3NN3/3nn3/8/PPPPPPPP/R1BQKB1R w KQkq - 0 1"]

```

All four knights must be present, as captures do not preserve parity:

```
[Event "White to move"]
[FEN ""]
[StartPly "14"]
1.Nf3 Nf6 2.Ne5 Ng4 3.Nc3 Nc6 4.Nd5 (4... Ne3 5.Nxe3) Nb8 5.Nxg4 Nc6 6.Ne5 Nb8 7.Ne3 Nc6

```

The rooks, if kept in a properly confined area, also preserve parity. I see two versions of this, both with or without the a3/a6/h3/h6 pawns moved.

Are there more ways to raise the number of permutations? Letting bishops, queens and kings loose usually allows triangulation, but sufficiently small cages could potentially prevent that, just like with the rooks.

# Answer
You found most of the possibilities where an argument about parity can determine which side has the move (*however, this is not all the 32-pieces positions, see the edit at the bottom*), which all have in common:

* pawns from b2 to g2
* bishops on their initial squares
* pawns on a2 or a3 and on h2 or h3
* rooks on a1-a2-b1 and h1-h2-g1
* either Ke1+Qd1, or Ke1 and no queen, or Kd1 and no queen
* same things for Black
* knights on any non-checking free square.

For a gross estimate of 3^2 x 25^2 x 32 x 31 /2 x 30 x 29/2 = 1 213 650 000 positions (this is a lower bound because there's one more spot for Black knights when a white knight occupies a square from which it attacks the white king, and because we have more choice for knights when there's no queen - a more precise count is at the bottom of this answer)

However, you are incorrect in your postulate that parity cases disappear once a capture occured.

In this position, for instance, it is necessarily White's move because there is no ante move for White:

```
[fen "4b2N/B5pp/1p6/4kPK1/4p1p1/8/2P3n1/4N2r w - - 0 1"]

```

It can sometimes become very subtle to understand if a position can be reached with either side on move. Actually, because of Dead Reckoning, even something as simple as Ka8 vs Kc6 can be reached only with one color! (the last move was necessarily made by the king on c6)

Anyway, that will add billions of positions that are not easily categorized.

---

**Precise count for positions where only one side can be on move because of an argument about parity:**

First, each pair rook + rook-pawn can be arranged in 5 differents ways, independantly of everything else, giving us a 5^4 factor.

Then we must distinguish cases according to the presence of queens, and then whether wNs are on any of the 2 squares from where they could target their own king (d3 and f3 if the wK is on e1)

A) *With both queens on the board* (one position for Ks and Qs):

* There are 30x29/2 ways to place the wNs without targetting the wK, and then 30x29/2 ways to place the bNs. A1=189 225
* There are 2 ways to place a wN on d3 or f3, then 30 spots for the second wN, then 31x30/2 ways to place the bNs. A2=27 900
* There is 1 way to place the wNs on d3 and f3, and then 32x31/2 ways to place the bNs. A3=496

subtotal: A = A1+A2+A3 = 189225+27900+496 = 217 621

B) *With one queen on the board* (4 possibilities for Ks and Q):

* There are 31x30/2 ways to place the wNs without targetting the wK, and then 31x30/2 ways to place the bNs. B1=216 225
* There are 2 ways to place a wN on d3 or f3, then 31 spots for the second wN, then 32x31/2 ways to place the bNs. B2=30 752
* There is 1 way to place the wNs on d3 and f3, and then 33x32/2 ways to place the bNs. B3=528

subtotal: B = 4x(B1+B2+B3) = 4x(216225+30752+528)= 990 020

C) *With no queen on the board* (4 possibilities for Ks):

* There are 32x31/2 ways to place the wNs without targetting the wK, and then 32x31/2 ways to place the bNs. C1=246 016
* There are 2 ways to place a wN on d3 or f3, then 32 spots for the second wN, then 33x32/2 ways to place the bNs. C2=33 792
* There is 1 way to place the wNs on d3 and f3, and then 34x33/2 ways to place the bNs. C3=561

subtotal: C = 4x(C1+C2+C3) = 4x(246016+33792+561)= 1 121 476

*Finally*

T = 5^4 x (A+B+C) = 1 455 698 125

So my best guess is that overall there are **1 455 698 125** such positions with no captures but the queens, and many more with less material.

If we require 32 pieces, the result becomes T2 = 5^4 x A = 136 013 125

---

The argument about parity is not the only one that can ensure which side is on move when there are 32 pieces, because positions like this one also meet the requirement.

```
[fen "r1bqkbN1/pppppp1N/7p/6p1/P7/r7/1PPPPPPP/nRBQKBnR w Kkq - 0 1"]

```

It is necessarily Black who played last here, and it's now White's move. Since most Black pieces can be shuffled almost anywhere, such a matrix leads to zillions of possibilities !
> 9 votes

# Answer
because any path where any piece(other than pawns and knights) can access 2 or more connected squares relative to the way that it moves rules out all following positions in the tree of moves, the trivial cases of knight moves and the rooks contained by the pawns(including knight captures) account for all such positions, any involving castling are ruled out because it is impossible to release the bishop without presenting the possibility of breaking parity. also any attempt to use a piece other than a pawn (pawns work because their moves are irreversible) to block another pieces access to squares which would allow for violations of parity doesn't work precisely because those moves are reversible. for example you cannot block in the rook with the knight and then say that parity is preserved because the rook may have come out first and then the knight proceeded to block it in later. Even not all knight moves are possible as any that captures a pawn would break parity as well as any where you capture a bishop and the opposing knight is moved (because now the rooks and/or the queen will have 2+ connected). So ultimately the conclusion is that there are only the mentioned rook moves and the knight moves which don't create to much freedom for pieces
> 1 votes

---
Tags: problems, retrograde-analysis
---


# Question
Title: What is the Depth reached by chess-AI agents on a regular computer?
I'm looking for some **reference** for the number of lookahead steps typically used by chess agents (Stockfish / Leela Chess Zero / others?)

From a quick search I found that: the answer depends on:

1. complexity of position,
2. computer hardware/processor speed,
3. efficiency of software/graphics interface,
4. time given to the chess engine.

with somewhat mediocre hardware a **depth around 15 ply's in one second** is typical.

the NPS value for the Stockfish engine: 49,473 kN/s (calculating 49,473,000 positions (nodes) per second).

source:

1. https://www.quora.com/What-is-Stockfishs-depth-when-analysing-a-chess-position
2. https://chessify.me/blog/nps-what-are-the-nodes-per-second-in-chess-engine-analysis

# Answer
Up to date reference is practically impossible to give, since engines and hardware change on yearly basis.

You identified most important conditions, but I would like to add two more:

1. Presence of tablebases (vastly improves evaluation depth in late endgames);
2. NNUE (slower) or hand-tuned evaluation function (faster).

Introduction of NNUE techniques vastly improved accuracy of evaluation function, but also made it slower. If you compare stockfish versions before NNUE and after you will see in same time frame difference of as many as 10-20 ply. Newest stockfish is still stronger than older, because it gains more in evaluation accuracy than loses in depth (in most positions! in some endgames this tradeoff is not so good).

From my experience (running time 1-2 minutes):

* SF before NNUE in middlegame on reasonably strong computer: 30-40 ply
* SF with NNUE in middlegame on reasonably strong computer: 20 ply
* SF with NNUE in middlegame with 64 cores and 128gb ram: 30-40 ply
* SF with 6 piece tablebases in endgame with ~8 pieces: 60+ ply or (more often) forced win/draw found.

Note that in early openings engines are very unreliable, no matter the (contemporarily achievable) depth.

---

As @Polytropos pointed out in comment, meaning of depth depends on choice of tree search algorithm. Possible moves and possible replies to them (and replies to them ...) can be arrayed into tree structure, so question of finding the best move is question of finding route to victory. Since this tree is too big to cover entirely we need to cheat - stop searching before we find the goal, evaluate positions and calculate approximate scores.

Additionaly chess is a zero sum game - this means, that your position can only be as good for you as it is bad for your opponent (and vice versa). This means that minimax search can be used.

Detailed explanation of tree search algorithms is out of scope for this answer. If interested, consult pages for minimax, Alpha-Beta pruning and Monte-Carlo tree search (MCTS). I will focus on practical consequences of choice of algorithm. Theoretically given infinite time they all lead to optimal solution.

Minimax in pure form cannot be used practically, since it's too time intensive. So in practice it's optimized by Alpha-Beta pruning. This way of searching is used by Stockfish, currently strongest publically available engine. **Depth here means number of plys before reaching evaluation, with some moves ignored at each ply based on preliminary evaluations.** Practically it optimizes for greater depth by sacrificing some breadth.

Consequence is that it may miss some good moves, which look bad to preliminary evaluation. Consequently human skill still matters in engine-assisted correspondence chess, since humans can force engine to consider moves that it would disregard to early (most commonly sacrifices with long-term positional compensation). It also leads to engines being weaker in (at least quiet) openings compared to (at least forcing) middlegames, since breadth is larger in openings, so more of it has to be pruned.

MCTS is used most notably by AlphaZero and Lc0. It's based on probabilistic methods. Practically it leads to lower search depths but better breadth than minimax with Alpha-Beta pruning.

Consequently play of these engines is slightly better in openings, but slightly worse in endgames (but this may also be attributed to evaluation function).

**Depth for Lc0 is average depth reached for move,** based on considered sample.

**In short, don't compare depths reached by one engine to depths reached by different engine. Depth is inaccurate heuristic for accuracy, as such it can only tell you, that if same engine reaches depth 20 and depth 40, evaluation at depth 40 is most probably more accurate.**

---

More pedantically Lc0 uses PUCT not MCTS, since pure MCTS uses random playouts for evaluation, while Lc0 uses neural network based evaluation function. For pure MCTS depth has not a lot of meaning, since better heuristic for accuracy is number of random playouts.

Another thing that makes comparision between Lc0 and Stockfish harder is difference in hardware. Lc0 runs on GPU, Stockfish on CPU.
> 5 votes

---
Tags: engines, software, stockfish, leela
---


# Question
Title: Extract evaluation data from Stockfish in Cpp
I am working on a chess player-rating system based on engine evaluations. As part of this I would like to extract evaluation data from Stockfish for the top 10 moves in a given set of positions.

Ideally I would like to be able to loop this from my program, so something like:

```
while i < 1000:
#'evaluate' returns a list of top moves with their centipawn evaluations.
choices = evaluate(positions[i]);
...do stuff...
i++;
end while

```

In the above 'positions' would be a vector of chess positions in FEN format. I have looked around and there are some solutions for this using the chess library in Python, but I would really like to do this from within cpp. Is there any relatively trouble-free way to do this?

# Answer
The Python solutions are nothing but wrapper for sending UCI commands to the Stockfish engine. I'm not aware there is a C++ equivalent but you can code it yourself.

I don't have a copy-and-paste ready code for you. To do what you want you will need:
> 2 votes

---
Tags: engines, software, stockfish, evaluation
---


title: Who is better in this endgame?

text:
# Question
Title: Who is better in this endgame?
This endgame can come out of the scotch gamibt, albeit there are better lines for a black player that desires a draw. However, I was wondering out of curiosity if this is good for white or black.

# Answer
Komodo 9.3 evaluates the position after 1.Kd5 (after searching to 31 ply) as +2.32 for White. Playing out a few lines, White usually ended up with Q+2P vs Q+P. It's not necessarily winning (Q+P endings have lots of resources for the defender due to all the checks) but I am comfortable asserting that the position is more pleasant for White.

For what it's worth, the position has occurred 6 times in my database, with 4 White wins and 2 draws.
> 8 votes

# Answer
There are many variations here which all lead to a win for white. The pawn on c4 is the only piece making a difference. After 1. Kd5 Kf5, you just push on the queenside and eventually Black has to make a concession. White also wins the pawn race after 1. Kd5 Ke3 because of the advanced pawn.
> 2 votes

# Answer
Stockfish 9 at d= 44(in a demo) give more than 9 points as White, maybe the setting was for a corrispondence game.It appears that starting from 2012 six piece ending are considered wins if they lead to mate, even if the 50 move rule has to be broken in the process. Starting from January 1, 2020 it is also true for 7 piece ending. Corrispondence chess.
> -1 votes

# Answer
Now I just did a deep analysis with Stockfish 14.1 NNUE depth =73 three quarters of an hour, and it is winning right away , with or without the 50 move rule. The position is evaluated at +5.02 for White , and , most importantly , the line reaches a winning seven pieces ending according to Syzygy tablebases online. The riddle is now solved : the Scotch Gambit ending is a win for White.
> -1 votes

# Answer
I got very deep and reaches the conclusion that the ending is a draw in over the board chess ( but it is nearly impossibile to defend) but a win in correspondence chess. The key position with WHITE King in c6 Queen in c1 pawn in b7 BLACK King in h2 Queen in b3 pawn in g5 Black to move, that is indeed a mate for White, but 58 moves are needed before a pawn move or a capture. Syzygy tablebases online. Only six pieces are present at the board at this point.
> -2 votes

---
Tags: endgame, pawn-endgame
---


# Question
Title: Lets suppose I develop a chess engine, can I enter it into tournaments? If so, where do I begin?
My question is simple. I recently discovered that chess.com hosts a computer chess championship, and that got me really interested in chess programming. I know its a very difficult field, but let's suppose I do create a chess engine someday. How could I enter it into a tournament? Is there a ranking system for "chess computers"? Are there lower level tournaments which I have to win to be able to participate in a bigger tournament like CCC on chess.com? I tried running a quick google search but found nothing. I tried searching for the big "Participate" button on the computer chess championship section of chess.com, but I couldn't find one.

# Answer
You will need to create a chess engine, and then announce it out on talkchess. There will be independent testers who will run your engine in their own tournaments. You will see your engine appear in various computer rating lists.

If your engine is open source, there will be engine programmers checking if your code is a modified Stockfish. If YES, you won't go anywhere but very low ranked computer tournaments. If closed source and you have a very strong engine, the community will compare your engine with Stockfish.

TCEC won't enter you unless they are sure your code is "original" - not a copy-and-paste from Stockfish. You need to demonstrate not just that you have an engine but your works are original. Your engine will also need to play strong chess (at least GM level).

Once your engine has been "accepted" by the community, you don't need to do anything because TCEC will most likely contact you and enter your engine. They will work out how to find you.
> 6 votes

# Answer
If you just want too see how your engine fares against players, easiest to implement are probably Lichess bots. They however cannot participate in Lichess tournaments, nor enter its leaderboard. Thibault wrote some advice for implementators here.

One of most recognized computer engine tournaments is TCEC. However it's invite only. For rules consult TCEC wiki.
> 2 votes

---
Tags: engines
---


# Question
Title: What does Depth mean in Stockfish Game Analysis?
When I'm observing a game, the evaluation bar works and above the moves list, there is a numerical value for depth. But what is Stockfish depth and what does it measure or tell?

# Answer
> 1 votes
See the Chess Programmming wiki on depth. It is *nominally* a measure of how far ahead an engine is searching, so e.g. an engine that is looking at depth = 10 is looking five moves ahead (10 ply = 5 moves). "Nominally" because these days there are all sorts of pruning techniques and quiescent searches and similar that makes the number itself relatively meaningless; however, in terms of playing strength, a higher number is still always better than a lower one. As you let Stockfish run, you should see that its depth continuously increases, as well.

# Answer
> 1 votes
Depth means roughly nothing. It used to mean the depth in the search tree that an engine searched but with modern search algorithms, there is enough pruning that the depth becomes fairly non-informative.

---
Tags: stockfish
---


# Question
Title: What are the main changes in the latest (January 2023) version of the FIDE Laws of Chess?
FIDE has released its latest version of the Laws of Chess - *FIDE Laws of Chess taking effect from 1 January 2023*.

What are the main differences from the previous version(*Laws of Chess: For competitions starting from 1 January 2018 till 31 December 2022*)?

# Answer
There are three main differences:

1. FIDE has finally adopted inclusive pronouns. "He" is replaced by "He/She". "Him" is replaced by "Him/Her", etc.
2. The normal time penalty for illegal moves has been changed for rapid to bring it into line with blitz. It is now 1 minute instead of 2 minutes. The penalty for standard remains at 2 minutes.
3. Recording the moves on a 'FIDE certified electronic scoresheet' has been introduced as an alternative to writing the moves on a paper scoresheet. The word 'record' is now also used instead of 'write'. e.g.

> **Article 8: The recording of the moves**
>
> 8.1 How the moves shall be recorded:
>
> 8.1.1 In the course of play each player is required to record his/her own moves and those of his/her opponent in the correct manner, move after move, as clearly and legibly as possible, in one of the following ways:
>
> 8.1.1.1 by writing in the algebraic notation (Appendix C), on the paper ‘scoresheet’ prescribed for the competition.
>
> 8.1.1.2 *by entering moves on the FIDE certified ‘electronic scoresheet’ prescribed for the competition*.

There are additional minor typographical and grammatical corrections that don't affect the rules in any meaningful way.
> 20 votes

# Answer
The answer by @Brian Towers is correct, in their news statement FIDE highlighted the same points. Moroever, they released a “comprehensive table showing all changes and corrections“.
> 9 votes

# Answer
In addition to the answer given by Brian Towers, I found a few smaller points and clarifications that may affect gameplay or tournament organisation (some of these aren't even mentioned in the changes document!):

* Usage of "stop the chessclock" is largely replaced with "pause the chessclock" (perhaps to prevent confused players from resetting the clock to zero?).
* Articles 9.2.1 (formerly 9.2.1.1) and 9.3.1 (claiming draws under threefold repetition or 50-moves by announcing the move you're about to make) have had their wording updated to clarify that it is the announced move that cannot be changed, not the electronic scoresheet that cannot be changed.
* Brian correctly mentions that penalties for illegal moves and incorrect draw claims during Rapid Chess games are now one minute instead of two minutes. However, these penalties under Blitz Chess are now two minutes instead of one minute, if the Competitive Rules of Play are used. (I thought this might have been a mistake, but they explicitly acknowledge this as "repealed" in the changes table.)
* The allowance of a player to ask the arbiter for a copy of the scoresheet up to five times per game is now a *requirement* for a Blitz game to run under the Competitive Rules of Play rather than the Rapid Chess Laws.
* An Introduction has been added to the Guidelines that clarifies that the Guidelines are not considered part of the FIDE Laws. (I assume this means that FIDE-sanctioned events are free, though strongly not recommended, to ignore these rules or implement different rules in the cases of game adjournment, Chess960, or quickplay finishes.)

Other than that, many of the changes are small spelling/grammar/numbering/wording fixes. Some sub-articles have been given titles. The "Competition Rules" are now called the "Competitive Rules of Play".

There are also a few minor errors I found:

* Articles 6.10.2 and Guidelines I.1.1 still use the wording "stop the chessclock", which may cause confused players to reset the chessclock to zero when notifying the arbiter of incorrect clock settings or when adjourning a game. (Not fully sure if it is intended that the chessclock be reset to zero in these cases, but I doubt it is.)
* Article A.2, still uses the wording "write the moves", which might suggest that players can only ask the arbiter for a paper scoresheet to write the moves on, and not an electronic scoresheet to record the rules on. (Again, not fully sure if this is intended, but I doubt it is.)
* Article C.10.1.3 was erroneously renumbered to C.10.1.2, so there are now two Articles numbered C.10.1.2.
> 2 votes

---
Tags: rules, fide, history
---


# Question
Title: Would Quadruple forking be considered a brilliant move according to Stockfish?
Is a quadruple fork (the image above) considered a brilliant move according to Stockfish?

I was just curious to know if Stockfish considers this a brilliant move, but at the same time, I'm not sure how to check this, so it would be great if someone could tell me.

# Answer
Stockfish has no concept of what a "brilliant move" actually is. It just gets a position as an input and returns an evaluation number for each of the possible continuations.

All the labels on specific moves are provided by chess.com based on the engine's evaluation and a few other factors. According to chess.com themselves, "brilliant" moves are best moves in a given position that involve some sort of sacrifice. Since this move doesn't, I don't think the move would be classified as brilliant. But stronger players will have more restrictive criteria to be assigned "brilliant moves", so your rating will have an impact on whether your move will be considered brilliant or not.

I wouldn't bother either way. "Brilliant moves" as computers use the term are not a real concept in chess analysis, but rather a marketing strategy used by chess sites to make you want to buy their analysis services. There's also the human definition of "brilliant" (!!) moves used by chess authors that goes something like "a great move that is hard to spot". This of course has the downside of being subjective and not too useful when working with an engine.
> 13 votes

---
Tags: stockfish, fork
---


# Question
Title: Macintosh: Seeking client with better listing format than Stockfish
I currently use the Stockfish client on my Macintosh, but don't like the way it displays the moves (left to right, no line breaks between moves, annotation in-line, branches hard to follow).

Are there any clients which allow customization of these features / do them better? A bonus would be one that lets me add annotations.

# Answer
If you’re talking about a GUI that, among other things, hooks up to UCI engines, such as Stockfish, almost any chess GUI will be better than the Stockfish client you’re using.

Particularly for the Mac—though not limited to the Mac—I think the new-and-improved “Pro” version of HIARCS Chess Explorer, namely “HIARCS Chess Explorer Pro” (HCEP), is excellent in many dimensions, including what you’re focusing on. HCEP has an optional column-based view of the main line and a really nice way of not only indenting variations but also labeling them to make it clearer where each one starts. (So it satisfies your “One line per move pair. Indented branches, one line per move pair” desire.)

It integrates very nicely with Stockfish (or any UCI engine). For example, if you hover over a line of Stockfish analysis, a picture of the resulting chessboard follows your mouse cursor as you move along the line.)

And, to address another desire in your post: It allows you to add annotations.

But, more generally, it’s arguably a ChessBase killer. It now (i.e., as of the Pro version) reads ChessBase databases. And it searches large databases (e.g, the CB MegaBase) blindingly fast. (People say it’s much faster than ChessBase itself, but I can’t compare since I don’t have ChessBase on my Mac.)

I’m not associated with HIARCS, so this isn’t a promotional post. (I did beta test the Pro version when it was first being released.)

HIARCS Chess Explorer Pro is a paid app. If you want free, SCID vs. PC is open source and has a Mac version (look for “ScidvsMac” in the download list). It’s a very capable GUI, too, though a little quirky as open-source projects can be. It has a proprietary database format and doesn’t interoperate with ChessBase databases. (Last I checked, it was not and likely never would be compatible with Chess960 games.)
> 1 votes

---
Tags: stockfish, macos
---


# Question
Title: How to play as adult attacking Chess player against young chess prodigies
I'm an expert-level chess player, who enjoys playing dynamic chess, but I am struggling against young chess players (ages between 8-16), who have lower ratings. How can I improve my score against this type of player? Playing positional chess? Non-traditional chess openings? or solid ones, which I don't play normally?

# Answer
If you play what you call "dynamic" chess and are being consistently beaten by young, lower rated players then it is very likely that you are losing to superior tacticians. If you enjoy dynamic chess then you are probably already working on tactics so just suggesting that you do more work on tactics probably isn't very helpful.

Instead I would suggest an alternative approach which as well as countering these young players will improve your chess generally:

1. Start working hard on your endgames to make sure they are bulletproof.
2. Change your repertoire to favour openings which give rise to queenless middlegames and an early endgame. For example, the Berlin, the exchange Ruy Lopez, the Philidor with d6, Nf6, e5 which gives the possibility of an early queen exchange.

These openings give rise to positions where maneuvering becomes more important, where positional factors feature more than tactics. Give your young opponents positions where there is not much to calculate and there is more to plan.

You should try and be happy to reach even middlegames and endgames which are quiet, where not much is going on. Then try and outplay them.

This type of approach has been successfully adopted by a number of strong, older players to counter younger players. The English GM Keith Arkell is probably the most dedicated player of these kind of principles. He has almost made it his life's work to be an expert on the Carlsbad structure and the resulting endgames and has won an enormous number of games from such quiet, even middlegame positions.
> 26 votes

# Answer
Here's a fun article published by Chessbase several years ago, titled "How to lose to a 9-year old at chess". After complaining about the ignominy of losing to an opponent barely tall enough to see over the board (not to mention explaining it to one's friends afterwards), the author suggests heading to an endgame where experience matters more. The author gives several games as examples, and describes how once the youngsters are in an endgame, their physical play noticeably changes - they are no longer as quick or as confident, which is a psychological victory.

So yeah: choose lines that head to quiet middlegames/endgames, and make sure your own handling of those positions is up to snuff.
> 9 votes

# Answer
Attack more, and exchange their pieces for your attack. I assume they're attacking most of the time. If you're on the defense, look how their attacks are weakening their position and go straight for the king, because they are attacking without paying attention to their king.
> 5 votes

# Answer
Examine their play: Consider their previous contests and make an effort to pinpoint their advantages and disadvantages. Note their favourite openings and strategies, then try to come up with a plan to oppose them.

Be patient: Due to their inexperience, young prodigies sometimes make blunders. Use this to your advantage by waiting patiently for them to make a mistake.

Utilize your expertise: You have more experience than your younger opponent as an adult gamer. Take use of this by remaining composed under stress and making wise choices.

Utilize your advantages: Try to lead the game in the direction of the regions of the game where you shine. Find their weak points and try to take advantage of them by exploiting them.

Do not undervalue them: Young prodigies are frequently extremely skilled and unpredictable in their movements. Never let your guard down and always be ready for anything.

Keep it simple by avoiding overly intricate or sophisticated maneuvers and sticking to tried-and-true strategies.

Don't let the pressure of competing against a young prodigy get to you; instead, keep a positive outlook.

Be modest: Avoid becoming overconfident or arrogant, and always treat your adversary with respect.

Love the game: Keep in mind that playing chess is a game, and try to enjoy yourself when you play a young player.
> 1 votes

---
Tags: opening, strategy, recommendations
---


# Question
Title: What happens when FIDE can't find a host for the World Championship match?
With less than 90 days to go to the 2023 World Championship match between Ian Nepomniachtchi and Ding Liren, FIDE can't seem to find a host for the game.

So what will happen when no one hosts the game? Will FIDE host the match themselves? What about the prizes?

# Answer
For most FIDE events there is a formal bidding process where what must be included in the bid, how much the proposers have to pay FIDE as a non-refundable bid fee, etc. is laid out formally. Here, for instance is the Call for Bids – FIDE World Championships 2023 which came out on 1st December 2022:

> CALL FOR BIDS
>
> FIDE EVE WORLD CHAMPIONSHIPS 2023
>
> Deadline 10th of January 2023
>
> 1. World Junior Chess Championships 2023
> 2. World Senior Team Chess Championships 2023
> 3. World Amateur Chess Championships 2023
> 4. World Youth U-16 Chess Olympiad 2023

but no mention of *THE* world championships.

Then on January 12 2023 we had CALL FOR BIDS FIDE EVE WORLD CHAMPIONSHIPS 2023 ENDED in which it was announced that

1. Italy, Malta, Thailand and North Macedonia had bid for the World Seniors
2. Montenegro and *Mexico* had bid for the World Juniors
3. Oman and Italy had bid for the World Amateurs
4. Holland and Kazakhstan had bid for the U16 Olympiad

So, these low key (compared to the World Championships) events can be sorted out very quickly. Meanwhile the bidding process for the real World Championships seems to be much more opaque. I couldn't find any formal bid requirements.

According to the Chess24.com article Dvorkovitch said in November that:

> Mexico is the main contender, but there are a couple more interested parties who can compete. We will make a decision within a month. We will make a decision by the end of this year

The latest from FIDE's Communications Manager David Llada:

> There had been an opportunity to host the World Championship match in Mexico. The project presented to us was not limited to just holding the match, but also organizing a massive festival with multiple events. Altogether, this could have been the single largest funded chess event in history. This possibility was so appealing that we decided to postpone our decision and give the Mexican promoters some extra time. However, **this ambitious plan hasn't materialized yet, and we are now considering alternative proposals**

The impression FIDE give is that they are very relaxed about this. Whether that is really true is hard to tell. However the experience of Covid has changed a lot in the world. The last world championships was originally scheduled for 2020 but ended up being delayed until 2021.

FIDE, having had that experience 3 years ago of delaying the match may very well be more prepared to do so again if what they consider a suitable bid doesn't emerge in time.

Three years ago the force majeur driving them was Covid. This time round it is the Ukraine war which seriously disrupted the cycle. Without that war and with a Russian contestant Moscow would have been more than eager to host the match on generous terms and with a Russian FIDE president that would have been the strong favourite. Now that is not possible.

The 2020 world championships was not the only major FIDE event to be delayed. Revisions to the FIDE Laws of Chess normally happen on a 4-yearly schedule. The last major revision was in 2017 with a minor update in 2018. The latest revision was due in 2021 (maybe 2022 at the latest) but didn't appear until this year.

If no suitable, acceptable (to FIDE and the players) bid emerges in time the match will be delayed. There are plenty of precedents and reasonable excuses for doing so.

***Update***: With just 78 days to go FIDE announce that Astana, Kazakhstan have won the bid to hold the championships with a bid of €2 million. More information on the Chess24 website. They point out that Kazakhstan is a neutral country which borders both China (Liren's country) and Russia (Nepomniatchi's country) making it sound the obvious choice.
> 5 votes

---
Tags: fide, world-championship
---


# Question
Title: USCF and FIDE: Is it legal to organize a tournament with the Monrad System? Monrad: rank 1 versus 2, in the first round. Swiss: 1 versus 5
We started to use the Monrad system:

https://rankedin.ladesk.com/043159-2152--Monrad

https://en.wikipedia.org/wiki/Swiss-system\_tournament

We are organizing a monthly tournament valid for ELO rating of the United States Chess Federation (USCF). The rating of our players is in the range 2000-400. We play a maximum of 3 rounds. Usually, we have between 8 and 16 players. This is an amateur tournament, in other words, no cash prizes. Players who achieve 3 points get a gold medal, 2 points a silver medal, and 1 point a bronze medal. We found that the classic Swiss system produces that a big percentage of the lower players retired from chess.

In my experience, in a game with a rating difference of 400 points, the lower rating player has a minimum of 90% chance to lose. In general, that will occur.

***For that reason, we started to use the Monrad system.***

If the highest rating is number 1, and the lowest rating is number 16. Without considering colors, the Swiss system produces 1-5, 2-6, 3-7, 4-8. But the Monrad system 1-2, 3-4, 5-6, 7-8.

The Monrad system is great because our main goal is to have a pairing with the smallest ELO rating difference possible. However, is it legal to use it for an USCF open tournament? It will be announced in advance. So, the players will know about it before to register. Our tournaments do not offer cash prices.

My main interest is in USCF. However, I would also like to know if it is legal for the International Chess Federation (FIDE).

As far as I know, the tournament organizer can use any system, if it is announced in advance and if it is NOT a national or international championship with established rules that the tournament organizer needs to follow.

Thank you for everything!

# Answer
> 2 votes
According to the FIDE handbook C.04.2 General handling rules for Swiss Tournaments:

> 1 The pairing system used for a FIDE rated Swiss tournament should be one of the published FIDE Swiss Systems. Accelerated methods are acceptable if they were announced in advance by the organizer and are published in section C.04.5.

> 2 In derogation of the previous rule, unpublished pairing systems or accelerated methods may be permitted, provided that a detailed written description of their rules:
> be submitted in advance to the Qualification Commission (QC) and temporarily authorized by them; and
> be explicitly presented to the participants before the start of the tournament.

So, it appears that in FIDE you need prior approval to use a non-standard system.

In the USCF, rule 26B states:

> A variation sufficiently major that it might reasonably be expected to deter some players from entering should be mentioned in any Chess Life announcement and all other detailed pre-tournament publicity and posted and/or announced at the tournament.

So you don't need prior approval, but you do need to let the players know in advance.

---
Tags: rules, fide, uscf, swiss-pairing
---


# Question
Title: Why was this castling move so "brilliant"?
```
[FEN ""]

1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. Ng5 Nh6 5. O-O

```

Why did chess.com mark this move as a brilliant move? It was quite surprising to see a simple king-side castle getting a `(!!) brilliant` which — at my level — is usually only seen for some insane sacrifice that gives you a winning advantage. For some context, my elo is in the ballpark of around 900 and I won this match with an 86% accuracy.

# Answer
I don't know what chess.com's algorithm for deciding on "brilliant" moves is exactly, but your "simple king-side castle" is in fact close to "some insane sacrifice" that gives a small advantage.

You see, your 4.Ng5 was a blunder that gives a piece away for nothing, black should just take it with 4...Qxg5.

However, after 4...Nh6 5.0-0, the piece is still en prise, but now 5...Qxg5 doesn't work because of 6.d4! and now white wins the piece back, and has a small advantage because of the bishop pair and the slightly odd positions of the black queen and knight on h6.

After 4...Qxg5, 5.d4 didn't work because black had 5...Qxg2, attacking the rook, so he can move the bishop to safety after white plays 6.Rf1.

So your simple king side castle makes your previous blunder actually work, because it covers pawn g2.

```
[FEN ""]

1.e4 e5 2.Nf3 Nc6 3.Bc4 Bc5 4.Ng5?? Nh6?? (4...Qxg5 5.d4? Qxg2 6.Rf1 Nxd4) 5.O-O! Qxg5 6.d4! Qh4 7.dxc5

```
> 6 votes

---
Tags: analysis
---


# Question
Title: Is the following position really a White win?
In a 2001 book by Karsten Muller and Frank Lampart FUNDAMENTAL chess ending the following position WHITE King on a4 Bishop on d5 pawns on a5 c6 e2 BLACK King on c7 Bishop on d4 pawn on f4 WHITE to move is given as a draw. Stockfish 14.1 NNUE disagree and found a very complicated way to win for White. The position appeared in the game Alexandrov vs Gleizerov in 1993 . What do you think?

```
[Title "Alexandrov-Gleizerov 1993, White to move: is it really a draw?"]
[FEN "8/2k5/2P5/P2B4/K2b1p2/8/4P3/8 w - - 0 0"]

```

Here's a continuation Stockfish gave :

```
[FEN "8/2k5/2P5/P2B4/K2b1p2/8/4P3/8 w - - 0 1"]

1. Kb4 Kd6 2. Kc4 Bf2 3. Kb5 Bg1 4. Bb3 Be3 5. Ba4 Bd4 6. Kc4 Bg1 7. Bb5 Ba7 8. a6 Bb8 9. Kd4 Kc7 10. Ke5 Kb6+ 11. Kf5 Bd6 12. Ke6 Bb8 13. Kd7 Kxb5 14. a7 Bxa7 15. c7 f3 16. exf3 Kc5 17. Ke6 Kd4 18. f4 Bb6 19. c8=Q Bc5 20. f5 Ba3 *

```

# Answer
There are quite a number of lines here, and it's not obvious how White can force concessions. In sum, White must either win f4, win a bishop for a pawn, or trade their c- for Black's f-pawn. I'll elaborate on the non-obvious latter.

**Tablebase observation**: First, note that your *position without e+f* is a tablebase draw:

```
[fen "8/2k5/2P5/P2B4/K2b4/8/8/8 w - - 0 1"]

```

Your *position without a+f* is also a tablebase draw:

```
[fen "8/2k5/2P5/3B4/K2b4/8/4P3/8 w - - 0 1"]

```

But your *position without c+f* is a tablebase win:

```
[fen "8/2k5/8/P2B4/K2b4/8/4P3/8 w - - 0 1"]

```

**Summary**: Black can defend against a+c as well as against c+e, but is lost against a+e.

**Conclusion**: White's general plan is thus to trade their c- for Black's f-pawn. They seek to send Black's bishop to b8, from where it eyes both f4 and the critical a7, but remains moveless. Then the manoevre c7+-Kxc7-Kxf4 can be prepared and exerted as shown, leading into a known tablebase win.

```
[fen "1bk5/8/2P5/P2B1K2/5p2/8/4P3/8 w - - 0 1"]

1. Be4 Bc7 2. a6 Bb8 3. Bd3 Kd8 4. c7+ Kxc7 5. Kxf4

```

**TLDR**: Keep your outside pawns and seek to trade c- and f-pawn.
> 6 votes

---
Tags: endgame
---


# Question
Title: Chess game/gui in C++/SDL. Integrating Stockfish. Mostly all is working, but is it possible to find all legal moves for a specified square/piece?
I've never worked with Stockfish or anything command line based like this before, so it took me a lot of getting used to in send/receiving the messages etc.

I do now have a C++ game project set up and it opens a stockfish process etc and interacts with it (sends commands and listens to commands).

I made two chess games. The first one didn't have stockfish and I done the move logic by myself. It ended up ok to have 1v1 against a friend locally, but really was just for fun. Anyway, when I came to try add Stockfish as CPU opponent, I started to learn about FEN string and all that other good stuff.

So... I decided to make a new version, and I use the FEN string as the basis of the rendering logic (ie. I convert that string into bunch of Piece sprites and lay them out where the string dictates they should go.)

It all works brilliantly. I can start a CPU vs CPU game and watch it moving all the pieces. However, when I come to include a Human player this is where I ran into problems.

The problem I am writing here about at this time is, I want the user to be able to click a piece (let's say he clicks Pawn e2 at the start of match), I want to highlight all the legal squares that can go to. But using Stockfish, I cannot seem to find enough data in the "info" string or any other that I found to piece together a list of valid destination squares for the selected piece.

If there is a command to return something like this it would be grand (eg. "Legal e2") but I am pretty sure there is NOT :( Any way at all would be great , otherwise I have to implement a lot of the logic for the whole game myself just to get this list of legal moves.

That was the question out of the way and I really hope it is possible. Meanwhile, I will post the bulk of the code here (NOTE: The code is work in progress, some stuff returns wrong values etc but I myself having written the code can navigate through that. If you tried to just copy this into your own project, it would probably be a bad example.

```
#include "Game.h"

#include "MegaEngine.h"
#include <cstdio>

#include "Sprite.h"
#include "Assets.h"
#include "ChessPiece.h"

#include <sstream>

void Game::run()
{
    MegaEngine::initGame(1920,1080);

    init();

    MegaEngine::runGameLoop(this);

    MegaEngine::closeWindow();
}

void Game::init()
{
    Chessboard_Sprite=new Sprite();
    Chessboard_Sprite->init(TEXTURE_CHESSBOARD);

    saAttr.nLength=sizeof(SECURITY_ATTRIBUTES);
    saAttr.bInheritHandle=TRUE;
    saAttr.lpSecurityDescriptor=NULL;

    StartStockfish();
    StartNewGame();

}

void Game::update()
{
    if(isCheckmate)
    {
        printf("\n*******\n*******\n*******\nCHECKMATE!\n*******\n*******\n*******\n");
        return;
    }

    if(isDraw)
    {
        printf("\n*******\n*******\n*******             DRAW!            *******\n*******\n*******\n");
        return;
    }

    if(player_to_act == 'w') // white turn
    {
        if(white_player == CPU_PLAYER)
        {
            //auto-play a turn
            if((autoplayTimer+=MegaEngine::getDeltaTime()) > autoplayInterval)
            {
                autoplayTimer=0.f;
                PlayMove(GetBestMove());
            }
        }
        else // human player...
        {
            if(MegaEngine::mouseButtonClicked1)
            {
                ChessPiece* clickedPiece=getMouseOverPiece();
                if(clickedPiece)
                {
                    printf("piece clicked Rank,File: %d,%d\n",clickedPiece->GetRank(),clickedPiece->GetFileInt());
                    printf("piece pos str=%s\n",clickedPiece->GetPiecePositionString().c_str());
                    GetLegalMoves(clickedPiece->GetPiecePositionString().c_str());
                }
            }
        }
    }
    else if(player_to_act == 'b') // black turn
    {
        if(white_player == CPU_PLAYER)
        {
            //auto-play a turn
            if((autoplayTimer+=MegaEngine::getDeltaTime()) > autoplayInterval)
            {
                autoplayTimer=0.f;
                PlayMove(GetBestMove());
            }
        }
    }
}

void Game::render()
{

    Chessboard_Sprite->render();

    for(int i=0; i < pieceSprites.size(); i++)
        pieceSprites[i]->render();

}

void Game::StartStockfish()
{
    // Start the Stockfish process

    ZeroMemory(&si,sizeof(si));
    si.cb=sizeof(si);
    ZeroMemory(&pi,sizeof(pi));

    // Create pipe for the child process's standard input
    if(!CreatePipe(&hStdinRead,&hStdinWrite,&saAttr,0))
    {
        printf("CreatePipe failed (%d).\n",GetLastError());
        return;
    }

    // Create pipe for the child process's standard output
    if(!CreatePipe(&hStdoutRead,&hStdoutWrite,&saAttr,0))
    {
        printf("CreatePipe failed (%d).\n",GetLastError());
        return;
    }

    // Create pipe for the child process's standard error
    if(!CreatePipe(&hStderrRead,&hStderrWrite,&saAttr,0))
    {
        printf("CreatePipe failed (%d).\n",GetLastError());
        return;
    }

    si.hStdError=GetStdHandle(STD_ERROR_HANDLE);
    si.hStdOutput=hStdoutWrite;
    si.hStdInput=hStdinRead;
    si.dwFlags|=STARTF_USESTDHANDLES;

    if(!CreateProcess(
        (LPCTSTR)L"D:/_Dev/stockfish_15.1_win_x64_avx2/stockfish-windows-2022-x86-64-avx2.exe",   // No module name (use command line)
        (LPTSTR)L"",                // Command line
        NULL,                   // Process handle not inheritable
        NULL,                   // Thread handle not inheritable
        TRUE,                  // Set handle inheritance to TRUE
        0,                      // No creation flags
        NULL,                   // Use parent's environment block
        NULL,                   // Use parent's starting directory
        &si,                    // Pointer to STARTUPINFO structure
        &pi)                    // Pointer to PROCESS_INFORMATION structure
        )
    {
        printf("CreateProcess failed (%d).\n",GetLastError());
    }
}

void Game::CloseStockfish()
{
}

void Game::SendStockfishCommand(std::string str)
{
    DWORD bytesWritten=0;
    str+='\n';
    if(WriteFile(hStdinWrite,str.c_str(),str.length(),&bytesWritten,NULL))
    {
        printf("Sent command:%s  . BytesWritten=%ld\n",str.c_str(),bytesWritten);
    }
}

std::vector<std::string> Game::ReadStockfishOutput(DWORD delayMillis)
{
    // need some form of PeekPipe check before ReadFile to stop it hanging when there was no response but we try to check one anyway.
    Sleep(delayMillis);
    printf("*************************Read called*********************\n");
    std::vector<std::string> lines;
    DWORD bytesRead=0;
    char buffer[1024 * 8];
    while(true)
    {
        // Check if the read operation was successful
        if(!ReadFile(hStdoutRead,buffer,sizeof(buffer),&bytesRead,NULL))
        {
            printf("FAIL bytes READ=%ld\n",bytesRead);
            DWORD errorCode=GetLastError();
            if(errorCode == ERROR_BROKEN_PIPE)
            {
                printf("Pipe was closed\n");
            }
            else
            {
                printf("Error occurred while reading from the pipe: %d\n",errorCode);
                // Additional error handling code
            }
            break;
        }

        std::stringstream bufferStream(std::string(buffer,bytesRead));
        std::string line;
        while(std::getline(bufferStream,line))
        {
            lines.push_back(line);
        }

        fflush(stdout);
        break;

    }
    return lines;
}

void Game::GeneratePiecesFromFenString(std::string fenString)
{
    printf("GeneratePiecesFromFenString() called. 'fenString'=%s\n",fenString.c_str());
    pieceSprites.clear(); //check this clear is sufficient. I probably need to delete pointers and null the references.
    int rank=0;
    int file=0;
    SDL_Rect sRect={0,0,0,0};
    SDL_FRect dRect={0.f,0.f,0.f,0.f};
    std::vector<char> fenChars(fenString.begin(), fenString.end());
    for(int i=0; i < fenChars.size(); i++)
    {
        char c=fenChars[i];

        if(c == ' ')
        {
            player_to_act=fenChars[i + 1]; // the char after the first space is always there so this won't cause problems.
            break;
        }
        if(c == '/')
        {
            rank++;
            file=0;
            continue;
        }
        if(c < 'A')
        {
            file+=(int)c - '0';
            continue;
        }

        ChessPiece* spr=new ChessPiece();
        spr->init(
            TEXTURE_PIECES,
            7-rank,
            file++,
            c);
        pieceSprites.push_back(spr);
    }
}

void Game::StartNewGame()
{
    // Send a command to Stockfish
    SendStockfishCommand("uci");
    std::vector<std::string> uci_response=ReadStockfishOutput(20);
    for(int i=0; i < uci_response.size(); i++)
    {
        printf("uci_response %d=%s\n",i,uci_response[i].c_str());
    }

    SendStockfishCommand("isready");
    std::vector<std::string> isready_response=ReadStockfishOutput(20);
    for(int i=0; i < isready_response.size(); i++)
    {
        printf("isready_response %d=%s\n",i,isready_response[i].c_str());
    }

    currentFen=START_FEN;
    GeneratePiecesFromFenString(START_FEN); // TODO: Could turn this into a parameter of this function, so we can start game from any position.
}

std::string Game::GetBestMove()
{
    std::string best;

    std::string cmd="position fen ";
    cmd+=currentFen;
    SendStockfishCommand(cmd);
    SendStockfishCommand("go depth 10");
    std::vector<std::string> position_startpos_response=ReadStockfishOutput((DWORD)cpuThinkTime);
    for(int i=0; i < position_startpos_response.size(); i++)
    {
        printf("go-depth output: %d=%s\n",i,position_startpos_response[i].c_str());
        if(position_startpos_response[i].compare(0,9,"bestmove ") == 0)
        {
            best=position_startpos_response[i].substr(9);
            std::size_t found=best.find(" ");
            best=best.substr(0,found);
        }
    }
    return best;
}

void Game::PlayMove(std::string move)
{
    std::string cmd="position fen ";
    cmd+=currentFen;
    cmd+=" moves ";
    cmd+=move;
    SendStockfishCommand(cmd);

    GetFenFromStockfish();

    GeneratePiecesFromFenString(currentFen);
}

void Game::GetFenFromStockfish()
{
    SendStockfishCommand("d");
    std::vector<std::string> response=ReadStockfishOutput(100);
    for(int i=0; i < response.size(); i++)
    {
        printf("response %d=%s\n",i,response[i].c_str());
        //cache fen string, for use in rendering pieces
        if(response[i].compare(0,5,"Fen: ") == 0)
        {
            std::string fenStr=currentFen;
            size_t spaceIndex=fenStr.find(" ");
            if(spaceIndex != std::string::npos)
            {
                fenStr=fenStr.substr(0,spaceIndex);
            }
            MoveLog.push_back(fenStr);
            currentFen=response[i].substr(5);
        }
        //check if king is in check.
        if(response[i].find("Checkers:") == 0 && response[i].length() > 11)
        {
            //printf("KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK\nCHECKERS LENGTH=% d\n",(int)response[i].length());
            //TODO: Can get exact square eg "a1" for the piece that put the king into check (for example to highlight it) using substr
        }
    }

    CheckMovesUntilMate();
    CheckDrawConditions();

}

int Game::CheckMovesUntilMate()
{
    SendStockfishCommand("isready");
    std::vector<std::string> isready_response=ReadStockfishOutput(100);
    for(int i=0; i < isready_response.size(); i++)
    {
        printf("isready_response %d=%s\n",i,isready_response[i].c_str());
    }

    SendStockfishCommand("go mate movetime=100");
    StopStockfishAfterTime(105);
    std::vector<std::string> response=ReadStockfishOutput(200);
    for(int i=0; i < response.size(); i++)
    {
        printf("movesuntilmatecheck_response %d=%s\n",i,response[i].c_str());
        if(response[i].find("mate 0") != std::string::npos)
        {
            isCheckmate=true;
        }

    }

    return 6969;
}

void Game::StopStockfishAfterTime(DWORD millis)
{
    Sleep(millis);
    SendStockfishCommand("stop");
}

void Game::CheckDrawConditions()
{
    // check repetition...
    for(int i=0; i < MoveLog.size(); i++)  //TODO: come up with a better way.
    {
        for(int j=i + 1; j < MoveLog.size(); j++)
        {
            for(int k=j + 1; k < MoveLog.size(); k++)
            {
                if(MoveLog[i] == MoveLog[j] && MoveLog[j] == MoveLog[k])
                {
                    printf("DRAW BY REPETITION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! %d, %d, and %d\n",i,j,k);
                }
            }
        }
    }

    // check 50 rule... (50 rule is checked in the GetFenFromStockfish function

    // check stalemate...
}

void Game::GetLegalMoves(std::string squareCode)
{
    std::string cmd="moves ";
    cmd+=squareCode;
    cmd="eval";//TEST
    SendStockfishCommand(cmd);
    StopStockfishAfterTime(2000);
    std::vector<std::string> response=ReadStockfishOutput(20);
    for(int i=0; i < response.size(); i++)
    {
        printf("legal_response %d=%s\n",i,response[i].c_str());

    }
}

ChessPiece* Game::getMouseOverPiece()
{
    for(ChessPiece* piece : pieceSprites)
    {
        SDL_FRect pieceRect=piece->getDstRect();
        if(MegaEngine::mouseX >= pieceRect.x && MegaEngine::mouseX <= pieceRect.x + pieceRect.w &&
            MegaEngine::mouseY >= pieceRect.y && MegaEngine::mouseY <= pieceRect.y + pieceRect.h)
        {
            return piece;
        }
    }
    return nullptr;
}

```

Well I ended up figuring out one way, but it is very slow. It causes a long delay in the program. Here is the code I used to fix it, but I would love to hear of a better way.

```
std::vector<std::string> Game::GetLegalMoves(std::string squareCode)
{
    std::string cmd="go searchmoves ";
    cmd+=squareCode;
    std::vector<std::string> legals;

    for(int f=0; f < 8; f++)
    {
        for(int r=0; r < 8; r++)
        {
            std::string destinationStr="";
            destinationStr+=(char)(f + 'a');
            destinationStr+=(char)(r + '0' + 1);
            SendStockfishCommand(cmd + destinationStr);
            SendStockfishCommand("stop");

            std::vector<std::string> response=ReadStockfishOutput(20);
            for(int i=0; i < response.size(); i++)
            {
                printf("legal_response %d=%s\n",i,response[i].c_str());
                if((response[i].find("bestmove")) != std::string::npos)
                {
                    if((response[i].find("(n")) == std::string::npos)
                    {
                        std::string str=response[i].substr(11,2); //hardcoded location of destination square
                        legals.push_back(str);
                        printf("LEGAL MOVE ADDED TO LIST\n\n");
                    }
                }
            }
        }
    }

    //DEBUG INFO...
    printf("legals size=%d\n",(int)legals.size());
    for(int i=0; i < legals.size(); i++)
    {
        printf("LEGALLINE:%s\n",legals[i].c_str());
    }
    // DEBUG END

    return legals;
}

```

The reason it is so slow is the call to "ReadStockfishOutput(20)" that allows a 20 millisecond halt in the program, but I am running this check brute force on every square in the board. I am trying to find a way that avoids coding all the piece movement logic for each piece and position individually. If I change the "halt" time to zero, it improves quite a lot, but it's still a bit slow.

# Answer
> 1 votes
I solved the problem pretty well. But really I am not totally happy with brute forcing through every square on the board. (But at the same time, I love that my code doesn't need to care which pieces are which etc.)

What was a bit too hefty to post all here. So here is link to Github: https://github.com/RetroCoderTV/MegaChess

If you tried to just copy my entire project to your own Visual Studio, you would need to modify the code a tiny bit. You will find the odd hardcoded string filepaths. You will also need SDL2. I also used my own "Game Template" I had been working on and so the code has Box2d physics integrated even though its obviously not needed. (Might be cool for some kind of "WIN" effect though). You'll need to linker the SDL and Box2d libs and you need to copy some .dll files into the outputted .exe location (eg. "\MegaChess\x64\Debug" ..depends on the configuration you have at your end).

Still this took me a lot of figuring out. Perhaps this will save someone some time one day (IMPORTANT: The way I coded it is NOT best practice. I'm a hobby coder and just done it all with whatever knowledge I had)

# Answer
> 1 votes
Stockfish is a chess engine, it's not designed for generating legal moves. There is a legal move generator in the code but the engine is not made to expose legal moves for you.

* Add a legal move generator outside of Stockfish. It's your responsibility for legal move generation not Stockfish. There are a few on Github.
* Run multi-PV analysis where the number of PV is something like 100 so you can capture all legal moves from Stockfish. It's a hack.

The first option is the best.

---
Tags: engines, stockfish, development
---


# Question
Title: Some adjustable chess engines below 3000 elo?
Stockfish, Alphazero, Leela chess zero, Komodo have elo above 3300. I need the names of some adjustable chess engines below 3000 level, from beginner level to Grand Master level (2800 to 3000 elo), like Shredder?

# Answer
I did some test on engines that support UCI\_Elo option.

Sample engines that supports said option. There are others. The list below are tested on UCI\_Elo 2300.

```
   # PLAYER                              :  RATING  ERROR  POINTS  PLAYED   (%)
   1 Cheng 4.39 ucielo 2300              :  3187.9  173.9    95.0     102    93
   2 Fruit reloaded v3.21 ucielo 2300    :  2945.0  141.5    78.5     102    77
   3 Amyan 1.72 ucielo 2300              :  2832.9  134.8    68.0     103    66
   4 Cheese 2.0 ucielo 2300              :  2823.7  135.1    66.5     102    65
   5 Lc0 0.21.2 w48x5 blas               :  2789.5  119.1   154.0     243    63
   6 Rhetoric 1.4.3 ucielo 2300          :  2726.9  129.6    56.0     102    55
   7 Discocheck 5.2 ucielo 2300          :  2652.3  129.2    48.0     102    47
   8 Arasan 21.3 ucielo 2300             :  2628.2  126.3    45.5     102    45
   9 Wasp 3.60 ucielo 2300               :  2535.3  125.1    36.5     102    36
  10 CT800 V1.34 ucielo 2300             :  2300.0   ----    19.0     102    19
  11 D2019.2.37.53 ucielo 2300           :  2159.2  143.1    11.5     102    11
  12 Hiarcs 14 ucielo 2300               :  1983.5  188.0     4.5     102     4

```

The engine `D2019.2.37.53` is my engine Deuterium.
> 2 votes

# Answer
A lot ... Pick your engine from the CCRL rating list: https://ccrl.chessdom.com/ccrl/4040.
> 1 votes

# Answer
Lichess has a software system with 8 levels. Level 1 has a ELO rating close to 0 because it loses on purpose. Level 8 is the strongest version of Stockfish. The other 6 levels are in between. It is available on your computer, tablet or cell phone. You can download the Lichess app. Good luck in your chess journey!

Steps to play:

1. Go to https://lichess.org/
2. Select ***Play.***
3. Select ***Play with the Computer.***
4. Select the **level** that you want to use (1, 2, 3, 4, 5, 6, 7 or 8).
5. Select the color that you want to play
6. Start!
> 0 votes

---
Tags: engines
---


title: Muzio Gambit with 11...Qd4+

text:
# Question
Title: Muzio Gambit with 11...Qd4+
The Muzio Gambit is great fun in blitz games. I realize it's slightly silly to study too much "theory" when it comes to blitz chess, but I figured it couldn't hurt to read up a bit and also see what the engines have to say. In the course of doing so, I discovered that in the variation below, both Stockfish and Leela Chess Zero rather strongly favor 11...Qd4+ whereas the written analyses that I've found discuss only 11...Qc5+ and 11...Qf5. It seems that the rationale is that after White plays 12.Kh1 or 12.Rf2, Black will castle, and his queen can return to the defense with ...Qf6 or ...Qg7, which it can't do after 11...Qc5+.

My question is, is 11...Qd4+ really an improvement over 11...Qc5+ and 11...Qf5? Has anyone analyzed this line carefully before? In something as complicated as the Muzio Gambit, I'm not whether running the engines for a couple of hours on my laptop will give me a reliable assessment.

---

```
[StartPly "22"]
[FEN ""]

1. e4 e5 2. f4 exf4 3. Nf3 g5 4. Bc4 g4 5. O-O gxf3 6. Qxf3 Qf6 7. e5 Qxe5
8. d3 Bh6 9. Nc3 Ne7 10. Bd2 Nbc6 11. Rae1

```

# Answer
> 1 votes
You're right that in this type of position, finding improvements over mainline theory is not as simple as trying to bring the engine evaluation to your side. If the engine is evaluating the position at something like -2.5, it won't matter much if you can make it -2.8 or -2.1.

Instead, we should be looking for moves that make our opponent's play more difficult. I'm not entirely sure if the queen on f6/g7 would be helping the defense or getting in the way. Think of a line like 11...Qd4+ 12.Kh1 0-0 13.Nb5 Qf6 14.Nxc7 Rb8 15.g3

---
Tags: opening, kings-gambit, novelties
---


# Question
Title: Is the concept “getting out of the book” outdated?
I see the phrase “getting out of the book” used in a way that no longer makes sense because if I’ve seen the position before then surely anyone good has seen it thousands of times, and it’s still in the book in terms of not throwing anyone off.

Is there some authority that holds what the opening book is and updates it with classic games every year?

Or is it updated by the top positions and their win %?

A side question but related, when a pro player preps their out of book moves, they aren’t so much prepping out of book but things their opponent’s game history has never played before, correct?

# Answer
> Is there some authority that holds what the opening book is and updates it with classic games every year?

No

> Or is it updated by the top positions and their win %?

No

> when a pro player preps their out of book moves, they aren’t so much prepping out of book but things their opponent’s game history has never played before, correct?

An "out of book" move is an opening novelty, a move which isn't known to theory. The current game between Caruana and van Foreest in the Tata Steel competition is a good example.

```
[Title "Caruana - van Foreest, Tata Steel 2023"]
[Fen ""]
[Startply "14"]

1. e4 e5 2. Nf3 Nf6 3. Nxe5 d6 4. Nf3 Nxe4 5. d4 d5 6. Bd3 Be6 7. O-O f5 8. Qe2 Be7 9. Ne5 Nd7 10. Nxd7 Qxd7 11. f3 O-O 12. Bf4 Bf6

```

Here is Chess24.com's tweet on 7...f5 with a video clip of Peter Svidler's reaction:

> Jorden blitzes out 6...Be6 which is already an incredibly rare move ... I'm sure people have played it over the years ... but Be6 specifically in connection with the idea of playing f5 here is just very 2023.

For me the shocking move is 11...O-O offering the knight on e4 as a piece sacrifice but not so much for the super GMs.

Take a look at the timings from Chess24 for this part of the game:

6. Bd3 6s Be6 3s
7. O-O **1m04s** f5 9s
8. Qe2 **17m50s** Be7 48s
9. Ne5 **7m17s** Nd7 33s
10. Nxd7 2m01s Qxd7 56s
11. f3 2m33s O-O **4m08s**
12. Bf4 **5m39s** Bf6 **27m21s**
13. c3 45s g5 18s

So, for Caruana 6...Be6 is no big deal. He takes just over a minute for his reply. But 7...f5 is a real shock, just as it was for Svidler watching and commentating. It takes almost 18 minutes for him to work out a response. Then van Foreest takes just 48 seconds for 8...Be7 Looks like he had this position on his PC pre-game.

Van Foreest thought for just over 4 minutes over the piece sacrifice 11...O-O but Caruana needed only 5 or 6 minutes to reject it with 12. Bf4. Now van Foreest is clearly out of his prep as he takes over 27 minutes to reply.
> 7 votes

# Answer
Getting someone "out of the book" just means to play an opening move they're not used to or that will require them to think by themselves rather than rely on theory.

Just as today people will have analyzed different positions with different engines. In the past different people would have studied games from different sources. It's not an expression meant to be taken literally or with a "strict" sense, but rather as a way to say that a player is trying to avoid turning the game into a theoretical debate and just wants to "play some chess".
> 4 votes

---
Tags: opening
---


# Question
Title: Exchange Caro-Kann Qc7 line: why does the black king's knight not go to f6?
In this position in the Exchange Caro-Kann:

```
[FEN "r1bqkbnr/pp2pppp/2n5/3p4/3P4/2PB4/PP3PPP/RNBQK1NR b KQkq - 0 5"]

```

the computer suggests one of the continuations as:

```
[FEN ""]
1. e4 c6 2. d4 d5 3. exd5 cxd5 4. Bd3 Nc6 5. c3 Qc7 6. h3 e6 7. Nf3 Bd6 8. O-O Nge7 9. Re1 O-O 10. Nbd2

```

However, the computer's top choice was to go 5... Nf6 instead of 5...Qc7, indicating that the knight on f6 isn't that bad on its own. This means that our position has something which needs the knight on e7.

**Why does the black king's knight not go to f6 HERE?**

# Answer
IM Sielecki explains this in detail in his new course Keep it Simple 1. e4 2.0. He checks all Black ideas and also covers a line like this. He explains that White gets an easy game when the knight is developed to f6, because Black deprives himself of the play he has to compensate for his bad bishop. Usually, Black would not voluntarily lock the bishop in that way with e6, here is what Sielecki writes about that:

> Black locks in the c8-bishop, which is not in the spirit of the Caro-Kann, you might think. However, in recent years this move has received some attention, as the setup involving ...Bd6 and ...Nge7 looks reasonable for Black. They have some control of the e5-square and might even play ...f6 at some point, stopping any ideas we may have about playing our knight to the attractive square e5.

Nf6 allows a strong knight outpost on e5, whereas when Black develops the knight to e7, f6 is always an option to smoke the knight out. The other idea of f6 is to prepare to get a big pawn center with e5 later. Sielecki recommends White striking at the center with c4 against that.
> 1 votes

---
Tags: opening, beginner, caro-kann
---