# Question
Title: Correct swiss pairings for a group of 4 players
Say we have a situation that's not super uncommon in swiss tournaments. There are four people currently tied with the most points, where #1 and #3 have just played White (for example), while #2 and #4 have just played Black. Everything else being equal, do FIDE rules say anything about what the pairings should be here? Information about any rules from individual federations is also welcome.

# Answer
> There are four people currently tied with the most points, where #1 and #3 have just played White (for example), while #2 and #4 have just played Black.

All else being equal, the pairings would likely be 1 vs 4 and 2 vs 3. This is, however, not guaranteed.

The pairing rules for the commonly used Dutch system are here. Let's walk through rule B (Pairing Process for a bracket) to see what happens.

Rule B.2 says:

> To make the pairing, each bracket will be usually divided into two subgroups, called S1 and S2.
> S1 initially contains the highest N1 players (sorted according to A.2), where N1 is either M1 (in a heterogeneous bracket) or MaxPairs (otherwise).
> S2 initially contains all the remaining resident players.

This is a fancy way of saying that the group is split into an upper and lower half. In your scenario, #1 and #2 would be in the first half while #3 and and #4 would be in the second half.

Then, rule B.3 says:

> S1 players are tentatively paired with S2 players, the first one from S1 with the first one from S2, the second one from S1 with the second one from S2 and so on.

So the tentative parings would be 1 vs 3 and 2 vs 4.

Rule B.4 says we should then evaluate how this tentative pairing complies with the various criteria in rule C. When we do so, we find that this pairing violates the quality criteria C.10 "minimize the number of players who do not get their colour preference." Since the candidate is not perfect, rule B.4 says we should apply rule B.5. Rule B.5 in turn says to apply rule B.6. (This is a homogeneous bracket, since everyone has the same score.)

Rule B.6 says we should first try a transposition. A transposition means the order of the players in the second half are changed. Since there are only two players in the second half, only one transposition is possible and we can pretty much skip the rules saying which transpositions should be considered first. So the new tentative pairing is 1 vs 4 and 2 vs 3.

As it turns out, this transposition results in a perfect candidate. So we stop there. The pairings would be 1 vs 4 and 2 vs 3.

But there are several reasons why the pairings might not go this way:

* The players might have played each other in an earlier round. It is prohibited for players to play the same opponent twice in the same Swiss, so some other pairing would have to be generated.
* A player who played Black last round might actually be due Black again due to playing White twice in a row earlier (or vice versa.) Having a different color preference could result in different pairings.
* A problem with pairing the lower score groups could mean that the top group must be collapsed into the lower groups to be able to generate legal pairings. The group would then be entirely re-paired, which would almost certainly result in different pairings.
* Some other system besides the Dutch system is being used. In this case you'd obviously have to read the rules for that system instead.
> 4 votes

# Answer
The FIDE algorithm (I assume the standard is used) can be read online. It is deterministic. I can think only of one worst case: No initial ranking can be done as the players have same name and same rating :-) Considering the second part of your question, note that other Swiss variants exist.
> 1 votes

# Answer
In this situation, assuming the pairings are possible, #1 would play Black against #4 while #2 would play White against #3.
> 1 votes

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


# Question
Title: White to play and win - only moving the rook once
```
[Title "White to play and win - only moving the rook once"]
[fen "k7/8/8/8/8/8/8/K1R5 w - - 0 1"]

```

This is an exercise in using the opposition and outflanking from John Hawkins' Amateur to IM. Obviously your engine isn't going to help.

# Answer
This is a simple one. You can't make progress once the K's are opposed and thus the only solution is outflanking.

```
[FEN "k7/8/8/8/8/8/8/K1R5 w - - 0 1"]

1. Ka2 Ka7 {is the human approach} (1... Kb8 {forces thinking about opposition} 2.Kb2 {maintaining opposition} Ka8 {since moving up sustains the white opposition, but makes it shorter} (2... Ka7 3.Ka3 {opposition but shorter}) (2... Kb7 3.Kb3 {opposition but shorter}) 3.Kc3 {outflanking = not losing opposition} Kb8 (3...Ka7 4.Kc4 {more of the same, doesn't shorten Blacks imminent death}) (3...Kb7 4.Kb3 {opposition again}) 4.Kb4 {and the opposition story goes on...}) 2. Ka3 Ka6 3. Ka4 Kb6 4. Kb4 Ka6 5. Kc5 {Ka5 won't lead to a solution.} Kb7 6. Kb5 Ka7 7. Kc6 Ka8 8. Kc7 (8. Kb6 {is a bit slower and as GM Ben Finegold would thus say: "wrong!"} Kb8 9. Ka6 Ka8 10. Rc8#) 8... Ka7 9. Ra1#

```

EDIT: added some more sidelines on request. IMO 4 deep for a sideline is more than sufficient to keep it readable.
> 13 votes

# Answer
Since it can't be analyzed with an engine, I made it so :-) I hope you agree that this setting keeps the relevant restriction (the wR only moves once):

```
[FEN "8/p7/rp6/rp6/pP6/R7/8/K6k w - - 0 1"]

```

Note that Kb3 is impossible here, so you must be a bit careful with outflanking. But Kb1 is a clear #11. (A problem solving engine could give all shortest variants, but that takes tiiiime...)
> 8 votes

# Answer
**Answer is edited.** Initial conclusion was that it's impossible.

First of all, the only rook's move must be the last move (you cannot check by a king), so it's all about kings dancing. White are willing to checkmate here either when the black king is on `a` column opposed by the white king on `c` column or when the black king is cornered at `a8` with the white king on `a6/b6/c7`. First option is typically avoidable by black so white's strategy is to gradually force the black king into the corner by using opposition.

Position that forces a king to step back is when it's opposed by the other king and the distance is exactly one row. For the king whose turn is next it's *bad opposition*, for the king just moved it's *good opposition*. In this play whenever black happen to obtain good opposition they can maintain it by mirroring the white king's moves (rook will not interfere here as it will always be blocked by the king). This way black keep *odd* number of rows between the kings. It works vice versa - whenever black ends a turn opposing the white king with *odd* number of rows between them - they are safe. So, *good* and *bad* oppositions should be extended from single row to any *odd* number of rows. Initially white can immediately obtain good opposition by `1. Ka2` but the catch here is that **white need to approach the black king and black do not have to**.

So the detailed strategy for white should be this:

1. Always avoid black's *good opposition*
2. Do not let black king to the rook
3. Approach the black king
4. Use threat of opposing the black king on `a` column from `c`

Strategy for black should be this:

1. Obtain *good opposition* whenever possible
2. Threaten to get to the rook (when white king is to the right of `c` column)
3. Preferrably maintain odd number of rows to the black king
4. Keep distance from the white king

```
[FEN "k7/8/8/8/8/8/8/K1R5 w - - 0 1"]

1. Ka2 {b1 or b2 allow good opposition for black} Kb8
    (1. Kb1 Kb7!)
    (1. Kb2 Kb8!)
    (1... Ka7 {allows good opposition for white} 2. Ka3)
    (1... Kb7 {allows good opposition for white} 2. Kb3)
2. Kb2 Ka8
    (2. Ka1 {same for 2. Ka3, allows good opposition for black} Ka7! {black are safe})
    (2. Kb1 {same for 2. Kb3, allows good opposition for black} Kb7! {black are safe})
    (2... Ka7 3. Ka3)
    (2... Kb7 3. Kb3)
3. Kc3 Kb7
    (3. Ka2 Kb8 {Repeats the first turn})
    (3. Kc2 Kb8. 4. Kc3 Kc7! {black are safe}
        (4. Kb2 Ka8 {Repeats the second turn})
        (4. Kd2 {Or any other to d column} Kb7 {black king gets space and approaches the rook})
        (4. Kb1 {same for 4. Kb3} Kb7!)
    )
    (3... Ka7 Kc4 {white is just getting closer})
    (3... Kb8 4. Kb4)
4. Kb3 {The white king is opposing similar to 1 ...Kb8 2. Kb2 but it's two rows closer. Now white can repeat this 2-move pattern to approach the black king} Ka7 (same reason as for 2... Ka8)
5. Kc4 Kb6
6. Kb4 Ka6
7. Kc5 {Now he threat Ra1# is active} Kb7
    (7... Ka5 8. Ra1#)
    (7... Ka7 8. Kc6 {repeating 7. Kc5 but one row closer to the edge})
8. Kb5 {same as 6. Kb4 but closer to the edge} Ka7
9. Kc6 Kb8
10. Kb6 Ka8
11. Rc8#

```

And remarkably, it matches the 11 turns produced by engine for edited position. For me, it's not "simple one" ©.
> 3 votes

---
Tags: endgame, puzzles, rook-endgame
---


title: What goes wrong with white?

text:
# Question
Title: What goes wrong with white?
Can you find the mistake(s) that caused white to lose this game?

```
[fen ""]

1. e4 g6 2. d4 Bg7 3. Nf3 c6 4. Be3 f6 5. Bd3 d5 6. c4 dxe4 7. Bxe4 e5 8. Bc2 Ne7 9. O-O O-O 10. Nc3 exd4 11. Qxd4 Nf5 12. Qxd8 Rxd8 13. Bxf5 Bxf5 14. Rad1 Na6 15. a3 Bd3 16. Rfe1 Bxc4 17. Nd2 Bf7 18. Nde4 Bb3 19. Rxd8+ Rxd8 20. Bxa7 f5 21. Nc5 Nxc5 22. Bxc5 Bf6 23. h3 Kf7 24. g3 Rd2 25. Rb1 Rc2 26. Bb4 Bd4 27. Kh1 Bxf2 28. Nd1 Bxg3 0-1

```

# Answer
> 3 votes
This is clearly a game produced by two beginners, so a oneliner as answer is difficult.

A simple explanation:

> White failed to address the threats posed by black and gave away the initiative without a real reason. Its pieces didn't take part in a game that seemed equal on a material POV.

A more substantial try:

> The game seems equalish (not counting the numerous misplays by both sides) until move 15. `15.a3` is incorrect because it gives away the initiative to black. After the rook and pawn trades (the latter were actually two blunders) Black prepared the decisive 2nd rank infiltration of the rook by preventing Whites rook from entering on e7. White should have prevented `24.-Rd2` at all costs but played unnecessary f and g pawn moves and seems to have counted on the material equality (which is surprising). After the infiltration Black lured the white pieces to the queenside whilest attacking both the K- and Q-side. Without sufficient defense on the K-side, Whites position is lost. `27.Kh1` is the final error since it direcly forfeits the Kings defensive structure. `27.Nd1` could have defended a bit longer, but pushing the b and c pawns and/or playing `Re2` probably seems sufficient to win for Black (and where not far fetched and thus natural moves to play).

Conclusion:

> Black actually played a rather passive and faulty opening (e.g. the `4. f6` move), but White didn't do anything about it. As far as I can conclude from this game, White constantly played his own game without watching the Black threats (or perhaps misjudging/underestimating them). Black on the other hand prevented the (minor) threats of White.

*PS. Probably Stockfish won't like my conclusions, but I did it without computer analysis.*

# Answer
> 0 votes
To add to the other answer I'll add a specific way to punish your opponent's opening. After 7...e5, White should absolutely take the pawn. After 8.dxe5 fxe5 9.Qxd8+ Kxd8, Black is left with a permanent weakness in the e5 pawn and a horrible bishop on g7

---
Tags: online-chess
---


# Question
Title: What's the positional threat in this opening of the London?
In a London system course, when explaining the following line, the author mentions that with 4.Ne5 "White is creating a big positional threat of Nxg4."

```
[FEN ""]
1.d4 d5 2.Nf3 Nf6 3.Bf4 Bg4 4.Ne5

```

I don't understand what's the threat. Even if White plays aggressively, let's say with

```
[FEN ""]
1.d4 d5 2.Nf3 Nf6 3.Bf4 Bg4 4.Ne5 e6 5.Nxg4 Nxg4 6.e4 Nf6 7.e5 Nfd7

```

Sure, White has more space, but I don't see it being dramatic. In fact, in the only masters game in which Black left the bishop in g4, White didn't take it https://lichess.org/8fgM6xR1.

What's the positional thread?

# Answer
**Bishop pair**

When White plays Nxg4 he gets the bishop pair. While it doesn't translate into an immediate breakthrough, this is a valuable positionnal plus that will be felt later on, when the game opens up. Having it as early as move 5, without making concession, is a small but clear achievement for White.

You might argue that this gain costed White 2 tempi (Ne5-Nxg4), but actually Black will lose time with their stranded knight on g4 too (most probably Nxg4-f6).

Concretely, after 4...e6 5.Nxg4 Nxg4, White can either :

* try to exploit the floating Ng4 as you mentionned: 6.e4 Nf6! 7.e5 Nfd7 8.Bd3, intending c3, Nd2-f3, h4...
* try to exploit the slight weaening of the light squares: 6.c4 intending Nc3, either e3 or e4, possibly Db3 hitting b7 and d5. This is riskier but may succeed in opening the center faster.
* continue slowly as if nothing happened : e3, Bd3, Nd2, 0-0... expecting the stength of the light-squared bishop to reveal itself later in the game, possibly after c2-c3 and e3-e4.

In any case, Black's position doesn't collapse immediately but any grandmaster would gladly take White. That's the kind of position we used to evaluate as +/=, althought nowadays it's probably just +0.15...
> 3 votes

---
Tags: opening, positional-play, london-system
---


title: London system move order

text:
# Question
Title: London system move order
The standard London System consists of the setup moves: d4, Bf4, e3, Nf3, Nbd2, c3, Bd3. I'm wondering about the nuances of what the most accurate move order is to play it in. Here are some of my thoughts:

Some people like reaching the London via 1.d4 Nf6 2.Nf3, but I like playing 2.Bf4; that way, you can go for the more aggressive setup with 3.Nc3 against King's Indian players, potentially tricking them into a Pirc.

Against people who play symmetrically, ie. 1.d4 d5 2.Bf4 Bf5, I like playing an early c4 instead of c3 to break symmetry.

If White plays Nf3 early, Black can play a combination of Nc6-Nh5 to harass / potentially trap the London bishop (since the queen has lost vision of h5) and force it to move off its natural diagonal, which can be annoying.

```
    [FEN ""]

    1.d4 d5 2.Bf4 Nf6 3.e3 c5 4.Nf3 Nc6 5.Nbd2 Nh5

```

If Black follows the main line setup with d5/Nf6/c5/Nc6/Qb6, it seems more accurate to play Nbd2 before c3, in case Black decides to enter the sharp gambit lines with dxc5 / Qxb2.

```
    [FEN ""]

    1. d4 d5 2.Bf4 Nf6 3.e3 c5 4.Nf3 Nc6 5. Nbd2 Qb6 6.dxc5 Qxb2 7.Rb1

```

In the main line, most masters seem to prefer the move order with d4-Bf4-e3-c3-Nd2; I'm not sure why this is.

```
    [FEN ""]

    1. d4 d5 2. Bf4 Nf6 3. e3 c5 4. c3 Nc6 5. Nd2

```

Why do masters prefer the above move order, and what other nuances am I missing from my points here?

# Answer
> 3 votes
The early Nd2 gives some breathing room for your a1 rook

```
       [FEN ""]
       1. d4 d5 2. Bf4 Nf6 3. e3 c5 4. c3 Nc6 5. Nf3 Qb6 6. Qb3 c4 7. Qc2 Bf5 8. Qc1 (5. Nd2 Qb6 6. Qb3 c4 7. Qc2 g6 8. e4)

```

Notice how black cannot easily harass your queen and get a lead in development with Bf5 in the early Nd2 case

# Answer
> 0 votes
Delaying the development of the Ng1 sometimes allow f2-f4, hoping to reach a perfect construction that Black usually avoids why the "normal" move order:

```
       [FEN ""]
       1. d4 d5 2. Bf4 Nf6 3. e3 c5 4. c3 Nc6 5. Bd3 (5. Nf3 e6 (5...Qb6) 6. Bd3 Bd6 7. Bg3 O-O 8. Nbd2 cxd4 9. exd4 Dc7 {prevents Ne5}) (5. Nd2 Bf5!?) e6 6. Nd2 Bd6 7.Bg3 O-O 8. f4!? Qc7 9. Ngf3 {followed by Ne5}

```

This shape with a Ne5 supported by the pawns on d4 and f4 is often attributed to Pillsbury and is very appreciated by London System players.

---
Tags: opening, london-system
---


# Question
Title: How to prevent evaluation function thinking better position after defended piece is taken?
So I’m making a chess engine and have an evaluation function that has material as (a large) part of the eval weighting. But the eval function (as if depth is 1) will think that one side is up a piece if a defended piece is taken and hasn’t been taken back yet.

You might think that’s not a problem as this is why we have search depth, but I have the issue that if the search ends with ‘half’ a trade then the program thinks this is a bad move when maybe it isn’t.

How do I implement something in the eval function to let it know the position is still equal.

# Answer
What you are looking for is a quiescence search. Chess programming wiki has a helpful guide to it here: https://www.chessprogramming.org/Quiescence\_Search. A quiescence search is a search that searches only captures. When depth reaches 0 in your search, instead of returning the static evaluation of a position, return the output from a quiescence search. Here is the pseudocode (assuming a minimax-esque search function)

```
func quiescence(alpha, beta) // no depth!
    eval = static_eval()
    if eval >= beta : return beta
    else if eval < alpha : alpha = eval
    capture_moves = generate_capture_moves()
    for move in capture_moves:
        push(move)
        eval = -quiescence(-beta, -alpha)
        unpush(move)
        if eval >= beta : return beta
        else if eval < alpha : alpha = eval
    return alpha

```

If you search until a position with no captures, this problem does not arise.
> 2 votes

---
Tags: engines, programming
---


# Question
Title: Good chess puzzle that involves queen running around the board?
Basically title. Ideally not too difficult or too many steps, but if you have any good puzzles where the queen traverses across the board.

Thanks in advance!

# Answer
Unfortunately, "running around" is a bit unspecific, but nevertheless, here are some offhand suggestions.

* "The ladder" Brian suggested you can see in problem chess, but also in the Philidor position in the Q vs R endgame: Kc6 Qa5 - Kb8 Rb7, black to move, e.g. 1...Rb1 2.Qd8+ Ka7 3.Qe7+ Kb8 4.Qf8+ Ka7 5.Qf7+ (a bit precision, please) Kb8 6.Qg8+ Ka7 7.Qa2+ 1-0
* "Merry Go Round" #4 by Jan Dobrusky, None Schachmatnoe Obozrenie 1901. 8/3B4/1K1p4/2pNk3/2bn1b2/3p4/5N2/Q7
* "Eine Schwalbe": A four-mover which gave the name to the German problem chess journal AND to the formal theme "A single white piece does all the work" (so googling "Schwalbeform" will find more). See here: https://www.dieschwalbe.de/ueberuns.htm

Is there something in my post which fulfils your request? Elsewise, be more specific.
> 3 votes

---
Tags: problems, puzzles
---


# Question
Title: What are FIDE really hoping to achieve by the proposed rating changes from January 2024?
FIDE have published a new article: FIDE seeks public discussion about proposed rating changes. They say:

> In the past decade, certain innovations have caused rating deflation, a concern that has been raised by professional players and mathematicians and did not go unnoticed by FIDE. Players' ratings are spread out too widely, and the situation is deteriorating with each passing year. The problem arises due to various factors, including the minimal rating being set too low at 1000 points, changes to the famous 400-point rule and the way the initial ratings are calculated.
>
> FIDE Qualification Commission and mathematician Jeff Sonas put significant effort into analysing the situation. As a result of this work, they propose two corrective measures.
>
> The first measure, which they called compression, aims to adjust for deflation. All players rated below 2000, which constitutes the bottom 85% of all rated players, shall be given a one-time rating increase on the January 2024 rating list. The additional points awarded will gradually decrease from 400 (for those rated 1000) to 0 for those rated 2000. For instance, a player with a rating of 1600 will receive an additional 160 points.
>
> The second measure, calculation improvements, focuses on improving the rating regulations to prevent future deflation. This includes raising the minimum rating from 1000 to 1400, restoring the 400-point rule to its earlier state so that it can apply multiple times in an event, and adjusting the formula for calculating initial ratings to incorporate two additional draws against hypothetical 1800-rated opponents.
>
> Understanding the significance of resolving the issue of rating deflation, we are sharing these proposals and inviting the chess community to engage in a public discussion. You can read the full text of Jeff Sonas' suggestions here.

I kind of get the reasons for the rating calculation changes:

1. Reintroduce the 400 point rule - the strong players (e.g. Magnus) have complained that they don't get enough rating points when they beat much lower rated players.
2. Change the calculation of initial rating by introducing 2 hypothetical draws against 1800 players. It is correct that a player's first rating can be widely different from their real playing strength / performance.

For instance, if a player about 2000 strength gets their first rating in a tournament where they beat 5 players all rated 1000 then their first rating will wildly underestimate their true rating. Other federations also have separate calculations for first ratings. For instance, the English Chess Federation iterates. That is to say they perform the calculation and get a first estimate of the players rating. They then repeat the calculations as if the player already has this estimate as their rating. This gives a new rating which they again use in a new iteration. Eventually the iteration process reaches a limit and this is used as the players first official rating. For me that makes more sense than adding 2 hypothetical draws.

The proposed rating compression from January 2024 applies to ratings under 2000. Ratings below 2000 will be adjusted according to the following formula:

New rating = old rating + (2000 - old rating ) * 0.4

So anybody with a rating of 1000 will get a new rating of 1400 which will become the new minimum. Anybody with a rating of 1500 will get a new rating of 1700, etc.

I don't get this. To me this just looks like a vanity thing to make lower rated players feel better, particularly older players (like me) who are not necessarily worth the extra rating points. Can anybody explain to me how this change is supposed to help?

# Answer
The justification is that lower rated player are outperforming their rating when playing higher-rated players. When a 1000-ish player played an 1800-ish player, the rating system expects the lower-rated player to score about 0%. In reality, in the years 2021-2023 the lower-rated player in that scenario scored about 8% - which is just about what you'd expect from a 1400-ish player playing a 1800-ish player.

I think the choice to increase lower ratings is also partially due to not wanting to remove many players from the rating list (there are over 120K players below 1400), while also wanting to raise the minimum rating for various reasons. The only way to do both is to raise the lower players' ratings to at least the new minimum, but a pileup at 1400 wouldn't make much sense either.
> 9 votes

---
Tags: rules, fide, rating, elo
---


# Question
Title: Position where promotion to bishop is the unique best move?
Let me define the problem clearly so as to avoid confusion. I am trying to find a position where:

* The unique best move is a promotion move.
* Said move needs to be promotion to a bishop. Not a queen, not a knight, and not a rook.
* Where "unique best move" means either: a move that draws while all other moves lose, or, a move that wins while all other moves draw or lose.

---

I have been trying to come up with such a position for more than a week now without success. The following is my thought process.

AFAIK there are two main reasons for underpromoting:

1. Underpromote to deliver a check/attack that a queen cannot fulfill
2. Underpromote to avoid stalemate

The first scenario should be irrelevant because a queen has all the moves of a bishop.

For the second scenario, I thought about the fundamental cause of stalemate. Promoting to queen can draw, either due to its rook-move ability, or its bishop-move ability, or both abilities simultaneously.

| Reason for stalemate | Rook move | Bishop move | Both |
| --- | --- | --- | --- |
| **Example FEN** | `8/k1P5/2P5/K7/8/8/8/8` | `8/6P1/8/8/8/8/8/k1K5` | `8/k1P5/8/2K5/8/8/8/8` |
| **Solution** | Promote to Bishop/Knight | Promote to Rook/Knight | Promote to Rook/Bishop/Knight |

As you can see, there is no scenario where you ***have to*** get a bishop. Therefore I concluded that any singular reason alone cannot produce a position where promotion to bishop is the only move. In other words, there has to be other conditions in the position that prevent the choice of another piece, in particular that of the knight.

One idea that came to my mind is that you might need a bishop-move to prevent something, but this idea got shot down pretty quickly because if you need to prevent something, that means the opponent is threatening a move, which means there's no stalemate.

---

Currently, the only semi-plausible idea I have left is that promotion to knight leads to insufficient material, whereas promotion to bishop doesn't. However coming up with such a position is quite difficult as you can imagine (especially given the condition that it has to be the only move), so I have yet to think of one.

---

I have asked this question to a few IMs and GMs on their streams to no avail (understandably so, since they still have to stream), so I am turning to StackExchange community for ideas and answers.

# Answer
> 11 votes
There are numerous chess problems, whether a checkmating one or an endgame study, that feature certain promotions as a necessity to win. Stalemate is the long-known reason behind doing so.

This problem is the first known one to use Bishop promotion, although it is a later correction. Even better, it comes with double the fun!

```
[Title "Ignazio Calvi  Le Palaméde 4/1836, White Wins (Correction)"]
[FEN "8/6PP/3Pn3/6b1/8/k3P3/p7/K2B4 w - - 0 1"]

1. g8=N! Bxe3 2. h8=B! (2. h8=Q? Nd4 3. Ne7 Nc2+ Bxc2 Bd4+ 5. Qxd4)    Nd4 3. Ne7 Bd2 4. Nd5 {And white wins!}

```

However, in theory, it can also be motivated by the "Dead Position" rule. Here is a flawed, hypothetical example.

Suppose White is down to seconds on the clock. They have no queens or rooks nearby-just knights. Stopping the clock to call in the arbiter might not help really. Thus, White must promote to a bishop, luckily just before the clock runs out. Now, the game is drawn and a half point is saved!

```
[FEN "8/3P4/8/8/8/7k/7b/7K w - - 0 1"]

1. d8=B

```

# Answer
> 12 votes
It's easy to come up with positions where promoting to knight leads to insufficient material but promoting to bishop doesn't. This one, for instance:

```
[FEN "N5q1/7P/8/8/8/7K/8/7k w - - 0 1"]

```

# Answer
> 6 votes
Various problems requiring bishop promotions. White is to play in all cases.

```
1) Economy record for a study (also correct as #5!)
2) Earlier really good study from 1856 for comparison
3) Economy record using 50 Move rule
4) Black in time-trouble (using special FIDE "half-dead rule", 6.9)
5) White in time-trouble (ditto)

```

First then, a new economy record:

```
[Title "1) Win - end of study by Klinkov, 1966"]
[FEN "3n3k/1P5P/7K/8/8/8/8/8 w - - 0 1"]

1. b8=B! Nf7+! 2.Kg6! Nd6! 3. Bc7! Nf5 4.Be5+! Ng7! 5. Bxg7#!

```

Shifting all units one column to the left gives 2n3k1/P5P1/6K1/8/8/8/8/8: a sound study, with mate in 14, but alas no dual-free line.

By way of comparison, here is the only comparable prior art with less than 6 pieces in either of the mega-databases PDB or WinChloe. It has mate in 9, but again no dual-free line.

```
[Title "2) Win - Luigi Centurini, La Regence 1856"]
[FEN "2k5/8/2K1P3/b7/8/6B1/8/8 w - - 0 1"]

1. e7! Bd8 2. e8=B! Bc7! 3. Bd7+! Kb8 4. Bxc7+ etc.

```

Let me show some other off-the-wall examples...

Here's one based on the 50-move rule (which must be specified in the stip, since by default it does not apply for orthodox studies).

```
[Title "3) Win (with 50 Move Rule) - Original, 2021"]
[FEN "7N/pP6/k7/8/K7/8/8/8 w - - 0 1"]

```
1. b8=B! White mates in 35.

On the other hand:

1. b8=N? This is a "cursed win": White could in principle mate in 104, but a draw intervenes under the 50-move rule as Black can delay the first pawn move or capture until White's 54th move.

Another example uses the FIDE “half-dead rule" Article 6.9 concerning the clock. Basically if a player times out (normally a loss) the game is drawn if the position is such that the opponent cannot checkmate the player’s king by any possible series of legal moves.

```
[Title "4) Best play under FIDE rules (Black in extreme time trouble) - Version 2023"]
[FEN "6rk/7P/6pK/p5Pb/6p1/p5P1/P7/8 w - - 0 1"]

```

**Explanation**

1.hxg8=Q/R+? (dp) Kxg8= 1.hxg8=N? a4 (dp) 2.Ne7,Nf6 So in all these cases no checkmate is possible, and the game immediately ends in a draw before Black has to reply.

On the other hand, after 1. hxg8=B! then game does *not* end *immediately*, because at least in principle there is the alternative lifeline 1... a4 2.Bb3 axb3 3.axb3 & e.g. a2 4.a4 a1=Q 5.a6 Qg7# and although Black wins, it takes 5 moves, there are checkmates around for either side. To seize the draw though, Black should play 1... Kxg8=, *but* has to execute this before the quivering flag falls.

And here's the final example, with *White* in time trouble:

```
[Title "5) Draw under FIDE rules (White in extreme time trouble) - Original, 2023"]
[FEN "7Q/4q1P1/5k1K/5r2/8/8/8/8 w - - 0 1"]

```

**Explanation**

White can win after 1.Qf8+ or 1.g8=X+, but in only one case is the checkmate certain: 1.g8=B+ Qg7+ 2.Qxg7#, so by playing this key, White locks in at least a half point if he times out before the next move.

# Answer
> 2 votes
Another addendum. *Very* strictly speaking, *none* of the positions (except the "dead" utilization by Laska) fulfil the specifications of the OP, since promotion should be the *only* move. But this is still easy, not even a capture involved:

```
[FEN "k2b4/P5P1/Kp6/1P6/8/8/8/8 w - - 0 0"]

```

`1.g8B!` and mate in the next move; `1.g8R? =`, `1.g8N? Bg5! 2.Kxb6 Be3+ 3.Ka6 Bxa7 =`

Addendum to the addendum. As promised above, a study where both sides underpromote. (But Black's is only a joke, the piece is captured immediately.) Not by Troitzki (I conflated that with his study where *five* same-field-color bishops win) but by a world champion:

V. Smyslov, Pravda 1976

```
[FEN "8/8/5P2/8/2k2p1p/2B1p2P/6P1/2b2K2 w - - 0 1"]

1. f7 Ba3 2. Bg7 f3 3. gxf3 Kd3 4. f8=B e2+ 5. Kf2 e1=B+ 6. Kxe1 Ke3 7. f4 Kxf4 8. Kf2 Bc1 9. Bh6+ 1-0

```

`4. f8Q? e2+ 5. Kf2 Bc5+ 6. Qxc5 e1Q+ 7. Kxe1 =` is the reason.

# Answer
> 2 votes
I didn't look at existing answers yet; so maybe this was already posted. I tried and fairly quickly came up with:

```
[FEN "1r5K/2P5/8/k1N5/8/8/8/8 w - - 0 1"]

```

My line of thought was: if promoting to a bishop is better than promoting to a queen, then having more "power" must lead to stale mate. Therefore promoting to a bishop must win. Then, if you allow that promoting happens while taking a piece it is rather easy to make it the only move that wins.

I'll be interested to see if there are answers that strongly divert from this idea, especially promoting without capturing a piece. But I'll first think about that myself.

EDIT:

After just 2 minutes or so, I came up with:

```
[FEN "7K/P7/8/1N6/1N6/1p1P4/1k5p/8 w - - 0 1"]

```

Here promotion is necessary because otherwise black promotes to queen with check, and promoting to rook or knight is not going to stop black from doing that, after which you just lose your promoted piece (black promotes with fork). Promoting a queen still results in a stalemate: then black also promotes to a queen and the best thing white then has is to take it, which is stalemate.

Promoting to a bishop stops black from promoting and white will go on to win.

# Answer
> 1 votes
Here are two light problems involving bishop-promotion (and rook-promotion, too, to boot).

A. Kudryavtsev; Smena (Moscow), Mar 1999; PDB P1165938. #4. FEN 6B1/7P/5Pk1/8/6K1/8/8/8

```
[Title "A. Kudryavtsev #4"]
[fen "6B1/7P/5Pk1/8/6K1/8/8/8 w - - 0 1"]

1.h8=B! (1.h8=R Kxf6 {and White wins at move 8}; 1.h8=N+ Kxf6 {and White wins at move 31}; 1.h8=Q? =) Kh6 2.f7 Kg6 3.f8=R (3.f8=Q/f8=B? =) Kh6 4.Rf6#

```

Viktor Pilipenko; Sa ogneupory, 26 Mar 1987, 190; PDB P1165936. #5. FEN 6B1/7P/6k1/4P3/6K1/8/8/8

```
[Title "Viktor Pilipenko #5"]
[fen "6B1/7P/6k1/4P3/6K1/8/8/8 w - - 0 1"]

1.h8=B! (1. h8=R Kg7 {and White wins at move 7}; 1. h8=N+ Kg7 {and White wins at move 10}; 1. h8=Q? =) Kh6 2.e6 Kg6 3.e7 Kh6 4.e8=R (4. e8=Q/B? =) Kg6 5.Re6#

```

# Answer
> 1 votes
```
[fen "3n3k/1P2N3/6K1/8/8/8/8/8 w - - 0 1"]

1. b8=B Nc6 2. Nxc6 Kg8 3. Bd6 Kh8 4. Bf4 Kg8 5. Bh6 Kh8 6. Bg7+ Kg8 7. Ne7#

```

---
Tags: pawn-promotion, composing
---


# Question
Title: Stockfish misses mate in 11 with 10 pieces
I fed @HaukeReddmann's "hack" to this scenario

```
[FEN "8/p7/rp6/rp6/pP6/R7/8/K6k w - - 0 1"]

```

to Lichess Stockfish 14, white to move. Up to Depth 77 (after which I gave up waiting), it declares draw, and suggests `Ka2` as best move. Yet, the moment I play `Kb1`, it immediately realizes mate in 11 for white.

Shouldn't 10 pieces be easy? Surely, eventually, it realizes M11 - but why not already with 38 (77/2) moves? And why doesn't Stockfish consider `Kb1` for itself (since it instantly realizes M11 when I play it)?

**Clarifying**, this explains my second question, but not quite the first and last. I get that ultimately it's heuristics, but is there something to specifically explain how it fails to find mate with just 10 pieces, *and* that me making the right move makes it see mate? Yes, longer wait (or better hardware, it runs on cloud) would help, so it's a question on efficiency (which moves it chooses to discard).

# Answer
My instance of Stockfish 16 saw M11 after about 7 seconds, so I think you just didn't wait long enough, although Stockfish 16 is stronger than 14 so that could also be why.
> 0 votes

# Answer
What version of Stockfish are you using? I am using Stockfish 15.1, with Chessis Pro GUI on Android 13, Snapdragon 8 Gen 1, and it found the mate in few seconds with depth around 70.

Edit: sorry, I missed the part where you say the version of the engine.
> 0 votes

---
Tags: endgame, stockfish, rook-endgame
---


# Question
Title: Storing generated moves for a chess engine in Java
I am in the process of building a chess engine in Java using bitboards. I know C/C++ is more optimal for this but I have no knowledge of either so I'd rather attempt to do it with Java for now. I have two questions about storing generated moves.

1. With regard to the format in which the moves themselves are stored, I've read about Stockfish's 16 bit format (from square, to square, promotion piece, special move) and I've also looked through the source code of CuckooChess (written in Java, ~2600 on CCRL) that have a Move class designated to hold all characteristics of a move in an object. What are the tradeoffs between either method, or any other method not mentioned?
2. I'd like to store legal moves in an array, but I wouldn't be able to just append a move to the end of the array. The logical alternative would be using an ArrayList; however I'm also worried that the larger memory requirement of ArrayList would cause some issues. Would I store legal moves in an array, arrayList, or another structure, or are these considerations insignificant?

# Answer
> 2 votes
My answer is not about chess, just as your question only superficially is about chess. The questions you ask are really about other things, and you may be better advised to try to address that part of the question in forums dedicated to Java.

If you haven't read Bloch's book Effective Java, do so, as you are sure to learn a lot about basic Java efficiency that will be important as well, perhaps even more so than the things you ask about here.

Question 1. The considerations are internal to your chess code, and you 'should' select a representation that makes it inexpensive to perform the operations you need: create moves, access the constituent parts of a move, etc. Unless you are fairly experienced you can't select the 'right' representation without knowing what your code needs. Choose something, and wrap in in your own class to make it easy to change implementation later without changing the class interface.

(Added: When you have working code, you can relatively easily replace your initial implementation with a different one, and see how that affects processing time, nodes per second, or other significant measures.)

Question 2. Create a suitable container class with the accessors etc that you require in your program. Then implement it by using an ArrayList, say. If you find that it isn't efficient enough replace the implementation with something better. But that's part of the improve/optimize phase of the development cycle, not the design phase. (From my own experience, I rarely find important inefficiencies in Java standard classes, I usually find the important problems in the code I have written myself.)

Programming (not only coding) is a large part eating pain: coding, discovering mistakes, retracing, and repeating; the more so the less experience you have. Accept that half of your initial design decisions will be sub-optimal, and don't press for optimal implementation too early.

---
Tags: engines, computer-chess, bitboard
---


title: Modern Benoni strategy question

text:
# Question
Title: Modern Benoni strategy question
Imagine that I have this position with White when playing against the Benoni defense

```
[FEN ""]
1. d4 Nf6 2. c4 c5 3. d5 e6 4. Nc3 exd5 5. cxd5 d6 6. e4 g6 7. Bd3 Bg7 8. h3 O-O 9.
Nf3 a6 10. a4 Re8 11. O-O Nbd7 12. Bf4 Qc7 13. Re1 Nh5 (13...Rb8 14. Qd2 Nh5 15. Bh2 Ne5) 14. Bh2 Ne5

```

Once the Black knight lands on e5 in both variation, when it's a good idea to play Nxe5 and when it's better to play a move like Be2 protecting the Nf3 knight so that if Black takes, white captures with the Bishop? And if the right answer is to play Nxe5, then what White is playing for? I can see that White has a passed pawn on the d-file. But how to prevent counterplay on the queenside with c4 or b5 for Black for good? I have tried to analyze the position with stockfish but couldn't understand or make a good plan for White and to stop Black's counterplay well.

# Answer
`15.Nxe5` seems the correct (winning) human approach for White. The reason is that it forces the Black fianchettoed bishop to be traded off or remain passive.
`15.Be2` seems correct as well, but IMO it's the GM/computer line.

After the below continuation White should keep his Q side as closed as possible and aim for a K side attack, combined with the threat of promoting the d pawn. After logical trades, that d pawn becomes active and Blacks pieces are so passive that it is exploitable for White.
E.g. white will nearly always benefit from a queen trade.
**White should play for a pawn breaktrough on the Q side while maintaining K side pressure** to keep the position as wide as possible. In this way the cramped pieces of black will fail to defend both sides.

```
[FEN "r1b1r1k1/1pq2pbp/p2p2p1/2pPn2n/P3P3/2NB1N1P/1P3PPB/R2QR1K1 w - - 9 15"]

1.Nxe5
    (1.Be2 Nxf3+ {is the computer style approach}
    2.Bxf3 Nf6
    3.e5 dxe5
    4.d6 Qb6
    5.Bxe5 Bd7
        (5...Qxb2 {is an error, because the Q gets trapped}
        6.Rb1 Qa3
        7.Rb3)
    )
    (1.Bf1 {is not as good, since it allows the powerful move 2... Bd4 after the Knight trades} Nxf3+
    2.Qxf3 Bd4)
Bxe5
    (1...dxe5 {creates a semi-bad bishop}
    2.Bf1 {indirectly defends the h pawn and prepares g3})
2.Bxe5 dxe5
    (2...Rxe5 {seems active, but isn't}
    3.Qd2 {preps f4} Qd8
        (3...Qb6 {creates a threat but abandons the K side}
        4.Bf1 {consolidates the white defense and Black has no threats. g4 and f4 are still coming.} Bd7 {could be a continuation if black chooses to not retreat his Q}
        5.g4 Ng7 {Nf6 is possible as well but doesn't defend as well}
        6.f4 Ree8
        7.e5 {creating a passed pawn.})
   4.f4 Re8
   5.g4 Qh4 {is a bizarre looking defense for black but it works}
   6.gxh5 Qg3+
   7.Qg2 {preventing the eternal checks} Qxd3
   8.Kh2 {defends the pawn} Qd4
   9.h6 {cramps black even further. This line eventually leads to a Q trade and passive pieces for black. +2 score for white according to the engine. Doubling the rooks on the e file and pushing the pawns creates a winning end game where a pawn can be promoted. Analysis of that would lead us even further.}
    )
3.Bf1 {Bf1 consolidates whites defense and does not make any commitments yet} null {The game might continue like the below variant.}
(3...Bd7 {other moves like Qa5 result in the same position}
4.Qf3 {threatens a Q infiltration on f6 after hitting the knight with g4} Qa5 {Kg7 is also possible is only a move permutation}
5.b3 {Kh2 might be required at some point, but Blacks minor threats are gone. The only remaining task to do for black is defending from now on. White is ready to start chasing pieces, potentially trading pieces and then start pushing the pawns.})

```

It's important to assess the position after `17.Bf1` (move #3 in the diagram).

Since the opening phase has just passed, it's very hard to show the 'winning moves". Here is an enumeration (attempt) of strengths and weaknesses of both sides.
Clearly black has more weaknesses than strengths whilest white is balanced.

1. **What has black achieved?**
    * BAD:
        + Playing g6 lefted the black fields around the king weak.
        + The fianchettoed bishop is gone.
        + The white colored bishop is very passive with only two accesible fields.
        + Most pieces are limited to the own half of the board.
        + There is a half open file in the center of the board that is not under control.
        + The knight is at the rim.
        + Apart from the queen there are no developed pieces controlling the center.
        + A K side attack requires at least two Q moves to be threatening.
        + A Q side attack is possible with at least two moves. Currently the Q side is only supported by the queen and requires black to play Bd7 and Rab8 (or perhaps Rfb8).
        + White has the initiative.
    * GOOD:
        + Whites white colored bishop is forced into the defense.
        + Nf4 is an actual threat that requires two moves to chase it away.
        + From a material POV the position is equal.
        + Bd7 creates connected rooks and prepares the possibility of playing b5.
        + d4 is a very strong field if it ever becomes accessible.
2. **What has white achieved?**
    * BAD:
        + Nf4 can't be easily stopped.
        + There is only one piece defending the K side position.
        + The black fields are weak.
        + The Q side is open for infiltration by the Q.
    * GOOD:
        + The d pawn is a connected free pawn.
        + Pieces are active.
        + There are no real pawn structure weaknesses.
        + The b2 pawn can't be captured by the Q because of tactics that trap it. (see the 5...Qxb2 side line).
        + The b5 pawn push is well defended.
        + the K side is adequately defended.
> 1 votes

---
Tags: strategy, modern-benoni
---


# Question
Title: What is the idea behind 1. nh3 h6 in atomic chess?
On the Lichess analysis board for atomic chess, it suggests for white to play 1. nh3, an unorthodox move that seems to leave the knight in a terrible spot on the side. But even more bizarrely, the best move for black after 1. nh3 is h6, which seems to only prevent ng5 and not much else. Then, after these strange moves, the engine finally suggests a more sensible move, 2. d4, taking control of the center. This is a bit of a shock to see as intuition would suggest that centralizing your pieces as quickly as possible in the opening would be the best plan of action.

Based on my experience with atomic chess, the lines I see the most following 1. nh3 h6 are usually 2. e3 e6 3. nc6 bb4 or 2. e4 e6 3. d4 d5 or 2. nc3 c6 3. e3 e6, and I have also seen people unfamiliar with the computer line or don't want to play the computer line to respond 1. nh3 with 1... f6, which can sometimes lead to a very common losing line (at least for me, I have seen many beginners and even advanced players fall for the "trap") 1. nh3 f6 2. nc3 c6 3. e3 e6 4. nb5 cxb5 5. qh5+ g6 6. qb5 nc6 7. qb6 axb6 8. bb5 kf7 9. nf4 and usually black resigns in this position due to the unavoidable mate in 1.

---

My main question is: What are the main ideas/rationale behind the unorthodox moves 1. nh3 h6? How should both white and black play in these lines, and what are their goals as the game approaches the middlegame?

# Answer
My answer is that 1. Nh3 is in fact inferior and that the computer doesn’t know what it’s doing. Playing 1. Nf3 forces black to play the worst possible move on move one which is f6, weakening the kingside. If you ask stockfish it will say 2. e3 is a mistake compared to 2. Nc3 which is ridiculous, e3 opens up the queen and bishop on the light square diagonals immediately after the f7 square is opened.

But that is not your question, you want to know what the ideas of the opening are. After all, 1. Nh3 is the second best opening in the game.

The idea behind 1. Nh3 is it allows white to play e4 and d4 moves without blowing up the knight. 1. Nf3 makes this pretty much impossible so tossing the Knight onto the edge of the board allows you to do this.

The reason for 1… h6 is it’s a better move than f6 and simply put there’s no stopping Nf4 on black’s first move.

White should be looking for Knight sacrifices to open up holes for stronger pieces, controlling the center, and in general forcing black to remain behind the line.

Black should be concerned with responding accurately to avoid traps, making proper pawn blocks, and pretty much just surviving the first 10 moves to achieve counterplay later in the game. Many players choose to play this because it’s a diverse opening that’s difficult to defend as black.

Just look at the number of possible moves white has after h6. White can reasonably play d4, e4, c3, Nc3, Na3, e3, and even g3. If you’re a novice you will not know how to defend most of these moves.

That’s another reason 1. Nh3 sets itself apart from 1. Nf3. Nf3 is about forcing black to play your game and grinding your opponent into losing several pieces while they’re powerless to stop it. Nh3 allows your creativity and genius to flow, if you know what you’re doing your opponent won’t know up from down and you can dance all over them. Most atomic games are fast anyway so it makes this move that much more confusing for the opponent.

In general the computer plays a confusing game because it is smarter than you and as long as you’re removed from the theory you’ve learned you will lose to stockfish. The only way to beat it is to use its own moves against it.

Look at the first 7 moves offered by the cloud opening. 1. Nh3 h6 2. d4 c6 3. Na3 d5 4. Nb5 cxb5 5. e4 a6 6. c3 Bd7 7. Bg5 f6

White has sacked a knight and is completely winning but it’s incredibly difficult to see why or how. No human outside the top 10 could ever reasonably expect to play like this.

To answer one final part of your question: why not 1.d4? Why Nh3 first? It’s because it forces black to make a non move, so it’s sort of like a move 1 between move, but also bringing out the knight first is standard because the knight is only dangerous in the opening when it’s jumpy explosiveness can cause massive holes and disrupt black’s game pretty severely. The more pieces are removed and the further into the middlegame you get, the less powerful the knights are so making use of them early is important to avoid having an impotent piece later on.
> 4 votes

# Answer
The point of 1.Nh3 is to force black to play the more damaging move ...h6 instead of ...f6. This is a strong point in favour of white, especially with the positional 2.d4 followup, instead of the older 2.e3.

1.Nh3 h6 is a perfectly normal opening in atomic; tactics play a larger role in dictating opening moves in atomic than in orthodox chess. 1.d4 looks "normal" but is not as forcing as 1.Nh3.

**General opening ideas**

In atomic there are two main kinds of openings: those with piece centres, characterised by minor pieces in the centre and generally lots of tactics (e.g. 1.Nf3 f6 2.Nd4 Nh6 3.e3 Ng4); and those with pawn centres, with fewer tactics but greater tension and positional play (e.g. anything with white e4/d4 vs black d5/e6). 1.Nh3 h6 2.d4 falls into the latter category.

Typically in this kind of game, pawns occupy the centre rather than pieces. There will usually be pawns on e4/d4 vs e6/d5 (sometimes e5/d5). In these positions, the knights are naturally developed on the edges, further from the tension in the centre. (Tactics may sometimes allow them to be developed centrally.)

If white plays skillfully, black will always be on the back foot in this kind of opening, cramped and under severe pressure. In the absolute worst case, white has Na3/Nh3 while black has a6/h6, and three of black's minors are still on b8/c8/g8 with no prospects. (Side note: black's c8-bishop can be a thematic problem piece with the d4/e4 vs e6/d5 centres.)

**Why is ...h6 bad?**

There are two reasons why ...h6 is more often worse than ...f6.

First, in light of the general ideas above, **the goal of 1.Nh3 h6 is to prevent black's knight from going to h6.** 1...h6 is a necessary evil since 1...f6 2.Nc3 is too good for white. (Side note: I have played 1.Nh3 f6 2.Nc3 Nh6 with some success against 2000 rated players, but it's objectively bad, and more of a mixup to see if my opponents know how to exploit it.)

With h6 blocked, it becomes difficult for black to develop the g8 knight. Ne7 is generally bad and needs another move, while Nf6 is hard to make work. Black will therefore suffer more in the middlegame trying to solve piece activity issues.

The other reason why **...f6 is better is that it creates luft around the king.** With f7 empty, moves like Ng5, Ne5, Bc4 and Qb3 do not come with tempo against a king on e8 or f8. This seems like a small point, but can affect many tactical sequences in the middlegame.

In fact, white will often play f3 unprovoked in this kind of Nh3-d4-e4 game, because it's simply a useful move. This kind of move is commonly part of a buildup to a decisive white break in pawn-centre openings.

Blocking the d1-h4 diagonal (white; d8-h5 for black) is not an issue; the queen may go out via a4, b3, or even stay happily on d1.

Likewise, one idea black can try in 1.Nh3 h6 games is to play ...f5 and ...Nf6. Black may have to accept a N for P trade, or even material loss (N+P for P), but can generate some dynamic play in return. (N or B for P is not really material loss in atomic.)
> 0 votes

---
Tags: chess-variants, atomic-chess
---


title: UCI go with depth and movetime

text:
# Question
Title: UCI go with depth and movetime
Is it possible to perform analysis with stockfish for a given depth, but stop in case it is taking longer than a specified time?

Something like this:

`go depth 17 max movetime 10000`

or

`setoption name MaxMovetime value 10000`
...
`go depth 17`

# Answer
I don't think it's possible to do it in the UCI protocol. Fortunately, it's really easy to do it yourself. For example, in my SmallFish app (http://www.smallchess.com), to save the phone's battery the app would send the "stop" signal to the engine after a minute of analysis. The command is very simple:

```
stop

```

You will just need to create a timer yourself and send the stop signal to terminate the search immediately.
> 3 votes

# Answer
Yes, it is (now?) possible. If stockfish reaches the specified `movetime` before it reaches the specified `depth`, it will stop searching

```
PS C:\Users\Marvin\Desktop> .\stockfish-windows-x86-64.exe
Stockfish 16 by the Stockfish developers (see AUTHORS file)
go depth 100 movetime 10
             ^^^^^^^^^^^
info string NNUE evaluation using nn-5af11540bbfe.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 2 nodes 20 nps 10000 hashfull 0 tbhits 0 time 2 pv g1f3
info depth 2 seldepth 2 multipv 1 score cp 2 nodes 40 nps 20000 hashfull 0 tbhits 0 time 2 pv g1f3
info depth 3 seldepth 2 multipv 1 score cp 16 nodes 70 nps 35000 hashfull 0 tbhits 0 time 2 pv c2c3
info depth 4 seldepth 2 multipv 1 score cp 29 nodes 101 nps 50500 hashfull 0 tbhits 0 time 2 pv e2e4
info depth 5 seldepth 3 multipv 1 score cp 42 nodes 131 nps 65500 hashfull 0 tbhits 0 time 2 pv e2e4 g8f6
info depth 6 seldepth 4 multipv 1 score cp 59 nodes 489 nps 163000 hashfull 0 tbhits 0 time 3 pv g1f3 d7d5 d2d4
info depth 7 seldepth 6 multipv 1 score cp 31 nodes 1560 nps 312000 hashfull 1 tbhits 0 time 5 pv e2e4 d7d5 e4d5 d8d5 g1f3
info depth 8 seldepth 6 multipv 1 score cp 40 nodes 2105 nps 350833 hashfull 1 tbhits 0 time 6 pv e2e4 d7d5 e4d5 d8d5
info depth 9 seldepth 8 multipv 1 score cp 48 nodes 4500 nps 409090 hashfull 1 tbhits 0 time 11 pv e2e4 e7e5 g1f3 g8f6 f3e5 f6e4 d2d4 b8c6
info depth 10 seldepth 8 multipv 1 score cp 48 nodes 5254 nps 437833 hashfull 1 tbhits 0 time 12 pv e2e4 e7e5 g1f3 g8f6 f3e5 f6e4 d2d4 b8c6
                                                                                ^^^^^^^
bestmove e2e4 ponder e7e5

```

The opposite also works, of course. If stockfish reaches the specified `depth` before it reaches the specified `movetime`, it will stop searching:

```
PS C:\Users\Marvin\Desktop> .\stockfish-windows-x86-64.exe
Stockfish 16 by the Stockfish developers (see AUTHORS file)
go depth 1 movetime 1000000
   ^^^^^^^
info string NNUE evaluation using nn-5af11540bbfe.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 2 nodes 20 nps 20000 hashfull 0 tbhits 0 time 1 pv g1f3
     ^^^^^^^
bestmove g1f3

```
> 2 votes

---
Tags: engines, stockfish, uci
---


# Question
Title: Where can I find mobile software for Fischer random chess?
Fischer had a chess variation (chess960) but I cannot find any mobile app to play it.

Does anyone knows where I can get the best software (if possible free or cheap) to play it?

# Answer
> 4 votes
There are a number of websites and tools listed on the Chess960 wikipedia page. Scroll to the bottom for the complete list. These should all be playable on your mobile device.

# Answer
> 0 votes
2012 there was chesscube i think...oh wait i think i remember in 2014 they didn't have 9LX in their app. RIP chessube

2021 this is very moot of course. lichess, chessdotcom, chessvision (using lichess), etc

# Answer
> 0 votes
If you use iOS there’s Chess Studio from AppStore which it’s great and have the 960 board positions to play against machine! Which is Stockfish!

---
Tags: software, chess-variants, chess960
---


title: Why is this the best move?

text:
# Question
Title: Why is this the best move?
I was just reviewing my game and was wondering why the AI would think this is the best move. All I see is giving white a free knight.

# Answer
> 3 votes
10 . . . Nxe4 is best because it wins a pawn, while other moves only keep material equality (or worse, give away material).

The move is a typical "desperado" sacrifice, introducing a line where wB and bN try to take as much material as possible before being captured themselves:

11 Bxe7 (or 11 Nxe4 Bxg5 and if then 12 Nxg5 Qxg5)
11 . . . Nxc3! (not Qxe7? 12 dxe4 1-0)
12 Bxd8 (or 12 dxe4 Qxe7)
12 . . . Nxd1 (certainly not Rxd8?? and Black is down a Queen)
13 Rxd1 Rxd8 and Black remains a pawn up.

At the end White can instead play 13 Bxb6 Nxb2, but Black is still up a pawn and the desperado Knight escapes while the Bishop is in danger, e.g. 14 Bc7 (trying to restore material equality) Na4 15 Bxd6 Rd8 16 Bc7 Rd7 and the Bishop is trapped and lost.

Note that the engine already has Black up 1.1 pawns after 10 . . . h5?!, and 1.67 pawns after Nxe4!. That's probably because White is behind on development and needs several moves to castle; that's less of an issue after the Queens come off the board, though meanwhile Black also gains B for N.

---
Tags: engines, analysis, online-chess, computer-chess, online
---


# Question
Title: Help with Negamax using transposition table
I've recently been improving my Negamax algorithm for chess, adding a transposition table. The algorithm was working well before this addition. After this addition I can't see no big improvements in speed, and sometimes I even see some regressions. I tested it with a depth of 5 and 6.

Is there any error in my code?

Here's the code, the new pieces are the commented lines at the top and at the bottom:

```
private int negaMax(Board board, Move[] legalMoves, int depth, int turnMultiplier, int alpha, int beta) {

    //Search in transposition table
    /*int initialAlpha = alpha;
    int transpositionDepth = 0;
    String transpositionFlag = "";
    int transpositionEvaluation = 0;
    String fenString = board.GetFenString().Split(" ")[0];
    if (transpositionTable.ContainsKey(fenString)) {
        transpositionDepth = Int32.Parse(transpositionTable[fenString].Split(" ")[0]);
        transpositionFlag = transpositionTable[fenString].Split(" ")[1];
        transpositionEvaluation = Int32.Parse(transpositionTable[fenString].Split(" ")[2]);

        if(transpositionDepth >= depth) {
            if(transpositionFlag.Equals("Exact")) { return transpositionEvaluation; }
            else if (transpositionFlag.Equals("Lowerbound")) { alpha = Math.Max(alpha, transpositionEvaluation); }
            else if (transpositionFlag.Equals("Upperbound")) { beta = Math.Min(beta, transpositionEvaluation); }

            if(alpha >= beta) { return transpositionEvaluation; }

        }
    }*/

    //Base case
    if (depth == 0) { return evaluatePosition(board) * turnMultiplier; }

    //Recursion
    int bestEvaluation = -infinity;

    foreach(Move move in board.GetLegalMoves()) {

        board.MakeMove(move);
        legalMoves = board.GetLegalMoves();
        orderMoves(legalMoves);
        int evaluation = -negaMax(board, legalMoves, depth - 1, -turnMultiplier, -beta, -alpha);

        if(evaluation > bestEvaluation) {
            bestEvaluation = evaluation;
            if (depth == searchDepth) { bestMove = move; }
        }

        board.UndoMove(move);

        //Pruning
        alpha = Math.Max(alpha, bestEvaluation);
        if(alpha >= beta) {
            break;
        }
    }

    //Transposition table update
    /*transpositionEvaluation = bestEvaluation;
    if (bestEvaluation <= initialAlpha) { transpositionFlag = "Upperbound"; }
    else if (bestEvaluation >= beta) { transpositionFlag = "Lowerbound"; }
    else { transpositionFlag = "Exact"; }
    transpositionDepth = depth;
    if (!transpositionTable.ContainsKey(fenString)) {
        transpositionTable.Add(fenString, transpositionDepth + " " + transpositionFlag + " " + transpositionEvaluation);
    }*/

    return bestEvaluation;
}

```

# Answer
I did not check the entire code in detail, however, two things that I noticed are: You seem to be using a generic hash map with a string as key and value. That seems very slow in my eyes, usually one uses a long as key instead which takes less space and is in general better to handle for the hash map. For the value, you can also stuff everything into a long, or, to stay more true to Java I suppose, you can create a class that has as members an integer for evaluation, a short for depth and an Enum (probably? Not a Java expert) for the bound type. On a more advanced level you would also write your own hash map since the generic one is not very good for this purpose, but that's something for another day I think.

Another thing I notice is you only add an entry if it is not already contained. However, even if the entry already exists you would still want to modify it if you improved the bounds with your search. And if you did a search then often you will have improved the bound because otherwise you would have already gotten a transposition table cutoff further up.
> 2 votes

---
Tags: chess-algorithms, transpositions, chess-ai
---


# Question
Title: What is the exact difference between <1500 and >1500?
I just finished a video series on imbalances, and I was wondering, why doesn't anyone talk about this? I'm 1440 blitz on lichess and 1373 on chess.com(peak 1391). Based on the video I just watched Imbalances are literally the key to knowing what to do all the time even in boring middlegame positions.

So, what exactly is the difference between amateurs and advanced+, apart from "experience" and "they're just better". What separates us? Is it Imbalances? Is it another hidden aspect of chess?

# Answer
> 5 votes
It is impossible to name a specific aspect of the game, knowledge or skill that exactly differentiates players up to 1500 from those above. Chess played by 1500s is far from great and they still have a lot of room for chess improvement in all areas of the game. Saying that understanding imbalances would do the trick falls short in many ways.

You can be an 1800 and still be relatively weak in some areas of the game (e.g. strategic understanding ("imbalances")) if you can compensate it e.g. with good calculation skills. There are other players above 1500, that might have a solid strategic understanding, but still have some deficiencies when it comes to calculation compared to their peers. Your playing strength is a reflection of the combination of all your chess-related strengths and weaknesses which differ from player to player.

Of course, for every chess playing strength, there are "minimum requirements" in each aspect of the game to be in that rating range. You will not find a 2000 rated player who cannot calculate deeper than three moves and hangs pieces every other move or who is puzzled what to do in minor-piece-imbalance situations.

What you can say is, that *on average*, a player rated higher than another player is expected to be more proficient in each chess-related skill or knowledge, i.e. having a better chess understanding and calculating better.

They visualize better, calculate deeper, calculate more correctly, consider more appropriate candidate moves, have a better pattern recognition or intuition, evaluate better, know more typical plans, know more opening and endgame theory, have a better positional understanding and use better "thinking methods" and habits (e.g. asking themselves what the opponent's threat is before thinking about their own move, blunder-check their intended moves, briefly checking all promising checks, captures and threats, thinking while it's the opponents' move, adapting to time pressure, making practical decisions, etc.).
This enables them to play better moves, apply more pressure and blunder less.

Improving in any of these areas will likely improve your playing strength, however it may be benefecial to improve in areas first that are "holding you back", because improving in something where you already outclass your rating peers yields diminishing returns. For example, ceteris paribus, being able to calculate deeper will increase your playing strenght - as indicated by research on engines whose playing strenght increased by approx. 66 Elo per additional half-move calculated in advance.

I understand that you wished to hear "this is the one thing you have to do to finally break through 1500" or something similar after being excited learning about imbalances. But what it really is that you need to improve depends on how **you** play chess and **your** specific strengths and weaknesses, therefore noone can give you a "hidden" golden formula for how to reach a certain rating.
Chess players have been searching for an easy universal chess improvement formula for ages. For you, it might be understanding imbalances. Or understanding how to better evaluate trades ("to take is a mistake"). Adopting a good thinking method improving your visualization or pattern recognition, or something else. This is the reason playing longer time-control games and analysing them afterwards is so crucial to become a better player.

In contrast, there is a lot of evidence of what you should avoid if you want to improve your chess..

P.S.: It's not true that noone talks about imbalances. There are whole books dedicated only to this, e.g. "How to reassess your chess", and about every strategy book/course has a chapter on "good knight vs bad bishop" or asymmetric pawn structures and corresponding plans.

---
Tags: rating, middlegame
---


title: Cloud computing for ICCF?

text:
# Question
Title: Cloud computing for ICCF?
I’ve been looking for a cloud computing service that can run the latest stockfish dev build. Chessify only goes to stockfish 16 and I can’t for the life of me figure out chessbase. If the answer is a generic cloud service, like google or amazon, can you provide a link to instructions on how to set up stockfish dev build? And if stockfish dev build is on chessbase, how do I use it? I am aware of next chess move but I want to calculate for longer than 30 seconds.

# Answer
Stockfish dev releases are packaged as standard Ubuntu and Windows binaries that should run out-of-the-box. There are many tutorials out there on setting up an AWS EC2 (or another cloud provider) Ubuntu instance with lots of cores and RAM.

It'll cost you though. For example, chess.com CCC uses 2x AMD EPYC 7H12 with 256 cores and 512 GB RAM. Looking at https://aws.amazon.com/ec2/pricing/on-demand/ for 128 vCPUs, depending on your region it'll cost several dollars per hour. Which AWS instance to use would be an interesting follow-up question.
> 1 votes

---
Tags: stockfish
---


# Question
Title: Blunders that they didn't realise for some time
Any high-level GM games where somebody makes a big blunder but was in blissful ignorance about how bad the move was until several moves after the blunder?

EDIT thanks to comment: classical time format, not blitz (where blunders are common)

# Answer
Of course this has happened, but it depends on your definitions. With the definition that "a blunder is a move that changes the game-theoretic state of the game" (e.g. "draw" to "loss" or "win" to "draw"), then here's an example where both Ding Liren and Alexander Grischuk were blissfully unaware of the blunder until after the end of the game.

```
[FEN ""]
[White "Grischuk, Alexander"]
[WhiteElo "2759"]
[Black "Ding, Liren"]
[BlackElo "2811"]
[Result "1/2-1/2"]
[startply "26"]

1. d4 Nf6
2. c4 e6
3. Nf3 d5
4. g3 dxc4
5. Bg2 a6
6. O-O Nc6
7. e3 Rb8
8. Nfd2 e5
9. Bxc6+ bxc6
10. dxe5 Ng4
11. Nxc4 Be6
12. Qe2 h5
13. Rd1 Qc8
14. Qf3? Bd5
15. Rxd5 cxd5
16. Qxd5 Qf5! {Black threatens ...Qxf2+ and mate.}
17. f3! {Both Grischuk and Ding Liren saw this far and could not see a refutation of this move.} Qc2! {Black threatens ...Qxc1+, and ...Qf2+ followed by mate.}
18. Qc6+! {18.Nbd2? Qd1+ 19. Kg2 Qe2+ wins. White has to move the Queen so that the d2-knight is no longer pinned, and Nf1 becomes possible.} Kd8
19. Nbd2 Qd1+
20. Nf1 {If White gets a single free move here, 21. Bd2 intending 22. Ba5 wins.} Nxh2! {20...Rh6? 21. Qe4 Nxh2? 22. Qh4+ and Qxh2 wins for White.}
21. Kxh2 {Just to illustrate how difficult the position is, see if you can calculate how Black wins after 21. Bd2.} Rh6!! {And Black wins because of the dual threats of ...Rxc6 and ...Qxf1. Comparatively 21...Qxf1? 22. e6 gives White enough counterplay to force a draw.}

```

Grischuk (White) went 14. Qf3? allowing Ding a game-winning continuation beginning with 14...Bd5, that was however not easy to spot by an unassisted human. After seven minutes Ding played ("blundered") 14...Rb6 and the game was eventually drawn.

However: given the complexity of the variation and how hard it is for a human to spot, can you fairly call 14. Qf3 or 14...Rb6 blunders?
> 2 votes

---
Tags: grandmaster, master-games, blunder
---


title: How is this a draw?

text:
# Question
Title: How is this a draw?
I was playing a game on chess.com. It is this game: https://www.chess.com/live/game/84265198943 It ended in a draw right as I was about to flag my opponent. I can not figure out why.

# Answer
> 4 votes
Three-fold repetition. The position facing Black for their 61st, 63rd, and 65th moves was exactly the same.

---
Tags: rules, draw
---


# Question
Title: Is it possible for a white piece to deliver check to the black king, but for black's counter move to result in white getting checkmated?
Is it possible for a white piece to deliver check to the black king, but for black's counter move to result in white getting checkmated?

Has this happened in games between top players?

# Answer
> 23 votes
You can find some examples in the following game collection: Games where check is answered with checkmate.

Among those games, Nigel Short vs Alexander Morozevich, Russia - The Rest of the World (2002) is the only one that meets the qualification *top players*. This was a rapid game.

The most entertaining example is the following:

```
[FEN ""]
[Event "Philadelphia (m/7)"]
[Site "Philadelphia (m/7)"]
[Date "1945.??.??"]
[Result "0-1"]
[White "NN"]
[Black "Winkelman"]
[ECO "C29"]

1.e4 e5 2.Nc3 Nf6 3.f4 d5 4.fxe5 Nxe4 5.Qf3 Nc6 6.Bb5 Bc5
7.Nxe4 dxe4 8.Qxe4 O-O 9.Ne2 Re8 10.Bxc6 bxc6 11.Qxc6 Rxe5
12.Qxa8 Rxe2+ 13.Kd1 Bg4 14.Qxd8+ Re8# 0-1

```

There are also some additional examples in Edward Winter's Chess Notes: 4130, 4135.

# Answer
> 8 votes
Yes, it can happen.

```
[FEN "rk2K3/1q5r/8/8/4Q3/8/8/8 w - - 1 1"]

1.Qxb7+ Kxb7#

```

It probably won't happen in games between strong players because they'll resign when checkmate is inevitable.

# Answer
> 6 votes
Could there be another example here? http://www.futilitycloset.com/2010/06/09/intercepted/ or is it checkmate followed by checkmate?

# Answer
> 2 votes
```
[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
[FEN "8/8/8/8/8/2k5/2q5/K1B5 w - - 0 1"]

1.Bb2+ Qxb2# *

```

# Answer
> 0 votes
Here is an example of a check that forces a checkmate reply:

```
[fen "R3q3/r7/8/Rp5n/2P3Q1/1p3Kb1/N4RBP/2rkr3 w - - 0 119"]

1. Nc3+ Rxc3#

```

(from a generated game with worst moves possible).

---
Tags: checkmate, check
---


# Question
Title: How do you win with a queen against a rook?
What's the *technique* behind the moves of the stronger side in order to win?

Are there situations where the side with K+R can force a draw against K+Q?

I've read plenty of examples of K+Q vs K+R, but they were only mere sequences of moves without explanation, and sometimes I didn't get the logic. The only thing I managed to understand is that the stronger side has to force the Rook away from his King, and then double-attack them with the Queen. But how can I make it happen?

# Answer
> 13 votes
In "Chess Fundamentals," former world champion J. R. Capablanca noted that this was the hardest of the basic piece-only endgames to win.

His analysis was that the stronger side can win if it can force the rook away from the king, with double threats of checkmating the king, and forking rook and king. If the defending side can keep the rook near the king without getting checkmated, it can draw. Often, the win or draw is just a matter of a square or two; e.g., the rook's staying on the same or opposite square color as the king (it is easier to fork them in the former case).

# Answer
> 23 votes
---

## *INTRODUCTORY NOTE:*

Examples and instructions are taken from the book:

Y.Averbakh - Comprehensive Chess Endings Volume 3.

In many cases I felt no need to "reinvent the wheel" so I quoted the above authors. Those parts will be marked with apostrophes `""`, like this: "This is a quoted text".

---

Without further delay let us tackle this endgame:

"In endings of this group the stronger side normally wins thanks to its big material advantage. At the same time, in a number of positions the rook's fighting quality enables it to put up a successful defense. **Drawing dangers arise each time that the weaker side's king, on being pushed to the edge of the board, becomes restricted in its mobility**"-emphasis are mine.

So let us first start with the position in which rook can successfully defend.

```
[Title "Weaker side holds balance: Ponziani, 1782"]
[StartFlipped "0"]
[fen "5k2/6r1/4Q3/8/8/8/8/7K b - - 0 1"]

1...Rh7+ 2.Kg2 Rg7+ 3.Kf3 Rf7+ 4.Kg4 Rg7+ 5.Kf5 Rf7+ 6.Kg6 Rg7+ 7.Kh6 Rh7+! 8.Kxh7 1/2-1/2

```

Here is another relevant position:

```
[Title "Weaker side holds balance: Berger, 1889"]
[StartFlipped "0"]
[fen "6k1/6r1/5Q2/8/8/8/8/7K b - - 0 1"]

1...Rh7+ 2.Kg2 Rg7+ 3.Kh3 Rh7+ 4.Kg4 Rg7+ 5.Kh5 Rh7+ 6. Kg5 ( 6.Kg6 Rh6+! 7.Kxh6= ) 6...Rg7+ 7.Kh6 Rh7+ 8.Kg6 Rh6+! 9.Kxh6 1/2-1/2

```

Another important note from the authors:

"If, for example, the queen is moved to `f1`,`f2`,`f3` or `f4`, the game ends in a perpetual check, since the king can not cross the `f-file`. But **with his queen at `f5` White wins: when his king occupies the `h6` the rook does not have a saving check on `h7`.**"

Let us move on to another important position, and again I will quote the authors:

"If the queen is stalemating the king in the corner of the board, the rook may become a *desperado*."

The following example shows a badly posted rook trying to save the game in this manner.

```
[Title "Failed 'desperado' attempt"]
[StartFlipped "0"]
[fen "r6k/5Q2/2K5/8/8/8/8/8 b - - 0 1"]

1...Ra6+ 2.Kc5 Ra5+ ( 2...Rc6+ 3.Kd4 Rd6+ 4.Ke5+- ) 3.Kd4 Ra4+ 4.Kc3 Ra3+ 5.Kb2+-

```

Stronger side should maneuver with its king so that one of the checking squares is covered with the queen-this way queen can take the rook which frees opposing king from stalemate. King should approach the rook **along a diagonal adjacent to the queen's.**

Now let us see how weaker side defends when rook is properly posted:

```
[Title "Drawn for any position of the White king!"]
[StartFlipped "0"]
[fen "7k/5Q2/2K5/8/8/8/8/r7 b - - 0 1"]

1...Rc1+ 2.Kd5 ( 2.Kd6 Rd1+ 3.Ke6 Re1+ 4.Kd7 Rd1+ 5.Ke8 Rd8+! ( 5...Re1+?? 6.Kf8+- ) 6.Ke7 Rd7+ 7.Kxd7=) 2...Rd1+! ( 2...Rc5+?? 3.Kd4+- ) 3.Kc5 Rc1+ 4.Kb4 Rb1+ 5.Ka3 Ra1+ 6.Kb2 Rb1+ 7.Kc2 Rc1+=

```

Perpetual check! Do not forget that in this position **rook must never leave the first rank!** See the sub variation for the second Black's move ( `2...Rc5+?? 3.Kd4+-` ).

Now let us move the rook on the `g-file`:

**Do not forget that here rook must not leave the `g-file`!!**

```
[Title "Drawn for any position of the White king!"]
[StartFlipped "0"]
[fen "6rk/5Q2/8/8/8/2K/8/8 b - - 0 1"]

1...Rg3+ 2.Kd4 Rg4+ 3.Ke5 Rg5+ 4.Ke6 ( 4.Kf6 Rf5+!= ) ( 4.Kd6 Rg6+= ) 4...Rg6+! 1/2-1/2

```

Let us sum up: *In these types of positions the defender draws if his rook operates along the `g-file` or the `1st rank`. Of course, this also applies for all 8 mirror positions.*

For further details of playing these positions refer to the above book. In normal situations the queen always wins against a rook, although not without overcoming certain technical difficulties.

"The winning plan consists of pushing the opponent's king into the corner or onto the edge of the board and creating mating threats. In defending, the weaker side is forced to separate his forces, which leads to the loss of the rook by coming under double attack by the queen. The basic method of achieving the goal is zugzwang."

```
[Title "Stronger side wins: Philidor position"]
[StartFlipped "0"]
[fen "1k6/1r6/2K5/Q7/8/8/8/8 b - - 0 1"]

1...Rh7 ( 1...Rb1 2.Qd8+ Ka7 3.Qd4+ Ka8 4.Qh8+ Rb8 ( 4...Ka7 5.Qh7+ Ka8 6.Qxb1+- ) 5.Qa1# )  ) 2.Qe5+ Ka8 3.Qa1+! Kb8 4.Qb1+ Ka8 5.Qxh7+-

```

If stronger side is to move, **it gives back the move to the weaker side with the following maneuver:**

```
[Title "Stronger side wins: Philidor position"]
[StartFlipped "0"]
[fen "1k6/1r6/2K5/Q7/8/8/8/8 w - - 0 1"]

1.Qe5+ Ka8 2.Qa1+! Kb8 ( 2...Ra7 3.Qh8# ) 3.Qa5+-

```

**This maneuver is characteristic for this endgame.**

The authors continue with practical examples of driving the weaker side's king to the edge/corner of the board **but give no written instructions** on how to achieve this.

This is not satisfactory for my standards thus I have tried to find a better resource for this. I believe this is decent coverage for the plan of pushing weaker side's king to the edge/corner of the board. Just look articles for second and third rank defense. If I find anything better I will edit my post, but for now this is the best I can find.

Best regards.

# Answer
> 22 votes
There are several key positions from which it is easy to memorize the win. The basic idea is to drive the opposing king to the edge of the board, and then to the corner, where you can force the rook to separate from the king.

```

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "King and Queen"]
[Black "King and Rook"]
[Result "*"]
[SetUp "1"]
[FEN "8/6rk/5K2/3Q4/8/8/8/8 w - - 0 0"]
[PlyCount "11"]

1. Qh1+ (1. Qh5+? Kg8 {this is the diagram we want, but the wrong side has the
move.}) 1... Kg8 2. Qh5 {This is the key position to have with black to move.
The rook must leave the king} Rg1 (2... Kf8? 3.Qh6) 3. Qd5+ Kh7 4. Qe4+ Kg8 5. Qa8+ Kh7 6. Qa7+ {
forks the king and rook} *

```

The first move in the diagram is Qh1+. Qh5+? is a mistake, though the position is the one we want the wrong side is to move.

After 2.Qh5 we have the position we want. The rook must leave the protection of the king, and a series of checks will allow a fork of king and rook by the queen.

If the rook is already separated, then there is usually a sequence of checks that produce the win.

```

[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "?"]
[White "King and Queen"]
[Black "King and Rook"]
[Result "*"]
[SetUp "1"]
[FEN "8/8/8/4K3/r6k/8/3Q4/8 w - - 0 3"]
[PlyCount "9"]

3. Kf5 Kg3 4. Qd3+ Kh4 5. Qc2 Ra5+ 6. Kf4 Kh3 7. Qc3+ *

```

# Answer
> 16 votes
There are a few technical ways to approach this endgame, the most notable one being a Philidor's Position (the KQ vs. KR one, not the KRP vs. KR one or the KRB vs. KR one).

If you do a web search for 3rd or 4th rank defense, you should be able to find more complicated situations outlining ideas for how the defensive position can try to put up a fight while minimizing the effects of a K-R fork occurring.

# Answer
> 9 votes
As long as we're mentioning ways the player with the rook can draw, the following is a very common setup in endgame puzzle books:

```
[fen "8/8/8/8/8/2QK4/8/3kr3 b - - 0 1"]

```

*Black to move and draw*

Solution:

> White is threatening to mate at c2, d2, and a1. Black's *only* move is 1.. Re3+! 2. Kxe3 1/2-1/2

# Answer
> 6 votes
Goals in KR KQ:

Get your king to where you are attacking his rook.

Force his king to defend the rook while you attack it.

Remove the king as a defender from the rook with your queen.

Do not allow your queen in a position where a rook could attack it with support of the king unless you initiated a check.

# Answer
> 5 votes
One possibility is to force a draw by repetition. E.g. if you have black Ka8, Qc8 and white Kb1, Rb2, then white needs just to check the black king forever. If he goes on the c file, the queen is lost.

```
[fen "k1q5/8/8/8/8/8/1R6/1K6 w - - 0 1"]

```

# Answer
> 3 votes
I've done a lot of research on this ending, as I was a little downcast to see so few good resources showing the technique. I've summarised my findings in two articles on my page:

The ending is broken down into two elements - 1. Winning from the Philidor position http://www.thequietmove.com/queen-v-rook-ending-philidor/ and 2. How to get to the Philidor position from an open board http://www.thequietmove.com/queen-v-rook-getting-to-philidor/

Note you really have to know the Philidor win or rely on tactics and this ending is super-tough! Happy chessing

# Answer
> 1 votes
Found this resource on the topic, which explains the three concrete steps involved in playing this endgame. Sharing here as it may help someone: http://www.chess-insights.com/queen-vs-rook.html

The linked article gives detailed explanation with good diagrams for each step. But to summarize in 3 sentences, the steps mentioned are as follows:

* First: force the rook into a third-rank defence and break that down. The defender then has to opt for a second-rank defence.
* Second: play against the second-rank defence until you reach the Philidor position.
* Third: win the rook from the Philidor Position.

# Answer
> 1 votes
I find *Secrets of Pawnless Endings* (Gambit, 2002) by John Nunn (pages 49 to 69) to be the ultimate reference about the KQvKR ending. All steps needed to force Philidor's 1777 position are described precisely, each position showing how to reduce to a previously seen position.

The book of course covers stalemate cases (which are all obvious) and what I call "perpetual check attractors", that is, positions that allow the KR side to force a position where the R will be able to give perpetual check.

# Answer
> 0 votes
I don't have a specific method, but I have some general tips.

1. Herd the king to the corner while being aware of skewers and stalemate traps.
2. Learn some of the K+QvK+R studies to have a strategy in key positions.
3. Attempt to separate the rook from the king.

# Answer
> 0 votes
I have this question myself, so I can't give a complete answer. But we can make a start with investigating certain positions.

First of all, it doesn't seem very hard to get the black king (BK, the weaker side) to the edge. So, lets investigate positions where this is the case.

Further more, I will first look at positions where the WK is at a knights jump away from the BK. With the BK on e8 and the WK on d7 there is something special about the square h5, to give check on. For example:

```
[Variant "From Position"]
[FEN "4k3/r7/3K4/5Q2/8/8/8/8 w - - 0 1"]

 1. Qh5+ Kf8 (1... Kd8?? 2. Qh8#) (1... Rf7? 2. Ke6!) 2. Qh8+ Kf7 3. Qh7+

```

If the BR is not that far away we still can make use of h5. Note that only two other squares that the BR can stand on while on the 7th row that are worth investigating are e7 and g7. All others (b7, c7, d7, f7 and h7) are trivially won for white because of immediate loss of the rook or mate in one.

```
[Variant "From Position"]
[FEN "4k3/4r3/3K4/5Q2/8/8/8/8 w - - 0 1"]

1. Qh5+ Kf8 (1... Rf7? 2.Ke6) (1... Kd8? 2. Qh4) 2. Qh8+ Kf7 3.Qh7+

```

which is the exact same pattern as before. Note that there *is* a faster way in this case:

```
[Variant "From Position"]
[FEN "4k3/4r3/3K4/5Q2/8/8/8/8 w - - 0 1"]

1. Qg6+ Kf8 2. Qf6+!

```

winning the rook the next move, or mate the next move after Rf7.

The pattern here is that the BK is far away from the corner and even though it (can) move to f8 after the check, we still can check on the 8th row, forcing the BK to the 7th row, after which we can pick up the rook with a check on h7. This is not possible when the rook is on the other side of the board however: on h7. In that case the win is long and hard:

```
[Variant "From Position"]
[FEN "4k3/6r1/3K4/5Q2/8/8/8/8 w - - 0 1"]

 1. Qe6+ Kf8 (1... Kd8?? 2. Qf6+) 2. Qf6+ Kg8 (2... Rf7?? Qh8#) 3. Ke6

```

and we reached a typical position with black to move that is rather non-trivial to win. Here black has seven moves with significant resistance: In order of decreasing resistance:

```
 a) Kh7!  The best move.
 b) Rb7 or Rg2  Both equally good.
 c) Rg1
 d) Kh8
 e) Ra7
 f) Rh7

```

Note that after Rc7 Qd8+ and the rook is lost. While

```
[Variant "From Position"]
[FEN "6k1/6r1/4KQ2/8/8/8/8/8 b - - 0 1"]

1... Rg3? (1... Rg4? 2.Qf7+! Kh8 3. Qh5+) 2.Qd8! Kh7 (2... Kg7 3.Qc7+) 3.Qh4+

```

Please click "Flip" to get the board in the same position as before.

You could say that the rook was too close in these two cases.

Therefore lets look at **c) Rh7** first; also close, but close enough to be harder.

```
[Variant "From Position"]
[FEN "6k1/7r/4KQ2/8/8/8/8/8 w - - 0 1"]

1.Qd8+ Kg7 2.Qe7+ Kg8 (2... Kg6? 3.Qf6+ Kh5 4.Kf5!) (2... Kh6? 3.Qf6+ Kh5 4.Kf5!) 3.Qe8+ Kg7 4.Qf7+ Kh6 5.Qf6+ Kh5 6.Kf5!

```

Three times the same trick thus (Kh8?? Qf8#).

The remaining four rook moves, **b) Rb7 or Rg2 c) Rg1 and e) Ra7** either lead to the Philidor position or to similar positions, or they lead to the following if black starts to check the WK. Note that in all case we start with a one or more checks and then play Kf6 in order to set up the position for the Philidor position. If the next move of black isn't check we either will reach the Philidor position or one of positions that occur when playing the Philidor position out. In the case that black DOES give check we get for example with Ra7:

```
[Variant "From Position"]
[FEN "6k1/r7/4KQ2/8/8/8/8/8 w - - 0 1"]

1.Qd8+ Kh7 2.Kf6 Ra6+? 3.Kf7! Ra7+ 4.Kf8! Rb7 (4... Ra1 5.Qc7+ Kg6 6.Qg7+) (4... Ra2 5.Qd7+ Kg6 6.Qe6+) (4... Ra6 5.Qd3+ Rg6 6.Kf7) (4... Rg7 5.Qh4+ Kg6 6.Qg4+) 5.Qh4+ Kg6 6.Qe4+

```

These were the easiest moves... The hard ones need a lot more work. But right now I have no time to continue. I'll update this answer another time if I have time again. Here is one variant of the hardest reply of black: **a) Kh7**:

```
[Variant "From Position"]
[FEN "8/6rk/4KQ2/8/8/8/8/8 w - - 0 1"]

1.Qd4! Kh6 2.Kf6 Rg6+ 3.Kf7 Kh5 4.Qh8+ Rh6 5.Qc8! Kg5 6.Qc1+ Kh5 7.Qe3! Rg6 8.Qh3 Kg5 9.Qg3+

```

---
Tags: endgame, theory, rooks, queen-and-rook-endgame
---


# Question
Title: How to get a list of top number of moves in stockfish uci format?
This is what I have written so far:

```
stockfish.postMessage("uci");
stockfish.postMessage("ucinewgame");
stockfish.postMessage(`isready`);
stockfish.postMessage(`position startpos d2d4`);
stockfish.postMessage(`go depth 10`);

```

What this returns is "`bestmove e2e4 ponder d7d5`". But how can I have it so it returns me the top best n number of moves in a list in order rather than just having just best move. I have heard to use something called `multipv` but I do not know how to use, please help with examples.

# Answer
> 1 votes
You can use the uci **setoption** command or directive to change the engine internal parameters or options.

```
* setoption name <id> [value <x>]
    This is sent to the engine when the user wants to change the internal parameters
    of the engine. For the "button" type no value is needed.
    One string will be sent for each parameter and this will only be sent when the engine is
    waiting. The name and value of the option in <id> should not be case sensitive and can inlude
    spaces. The substrings "value" and "name" should be avoided in <id> and <x> to allow
    unambiguous parsing, for example do not use <name> = "draw value".
    Here are some strings for the example below:
       "setoption name Nullmove value true\n"
       "setoption name Selectivity value 3\n"
       "setoption name Style value Risky\n"
       "setoption name Clear Hash\n"
       "setoption name NalimovPath value c:\chess\tb\4;c:\chess\tb\5\n"

```

In your case this can be:

```
stockfish.postMessage(`setoption name multipv value 3`);

```

This will set the engine to emit its top 3 best lines.

In the uci specification, `multipv` is the id, and 3 is the value.

### Reference:

UCI protocol

---
Tags: stockfish, uci
---


# Question
Title: Shatranj puzzle by Aladdin - white to play and win
```
[Title "White to play and win"]
[fen "3qrb2/4k3/2p1NpRp/P3pPpP/2Pp2r1/BP1R1pP1/2Qnpr2/5B1K w - - 0 1"]

```

This is attributed to Ala'Addin (aka Aladdin).

Reminder, the rules of Shatranj are here.

# Answer
From *The Complete Chess Addict* by Mike Fox and Richard James

```
[Title "White to play and win"]
[fen "3qrb2/4k3/2p1NpRp/P3pPpP/2Pp2r1/BP1R1pP1/2Qnpr2/5B1K w - - 0 1"]

1. Rg7+ {Remember the shatranj bishop moves 2 squares diagonally so can't take the rook} Kd6 {The shatranj bishop is still defending the pawn on h6} 2. c5+ Kd5 3. Rd7+ Ke4 {The shatranj queen can only move one square diagonally so the rook can't be taken} 4. Re3+! Kxe3 (4...dxe3 5. Qd3+ Kxf5 6. Ng7#) (4...Kxf5 5. Ng7#) 5. Bc1+ {the shatranj bishop} Ke4 6. Qd3+ Kxf5 {the queen is protected by the f1 bishop!} 7. Ng7#

```

Nice that the replayer also works for shatranj.
> 1 votes

---
Tags: puzzles, shatranj
---


# Question
Title: Is there a free online chess repertoire tool?
Is there a free online chess repertoire tool? It can be some place where you register, save variations and comments, and navigate with a board what you do. I was used to *chessply*, but apparently it disappeared.

# Answer
> 12 votes
In addition to the other answers, there are a few sites to consider. These include annotation and comment features as mentioned by the OP.

**Listudy.org**
Upload a PGN and then you play the computer interactively. You play moves from your repertoire and the computer plays the opponent moves. This is also open source.

**ChessTempo.com**
Similar functionality in the "Opening Trainer." The interface is a bit different but it tracks what lines you have learned a bit differently which is nice.

**lichess.org**
As B.Swan has pointed out in a comment, the Study feature includes this. Further, Hauptideal points out in a comment you can use the Analysis feature's book icon to access master statistics, lichess statistics, and statistics of any lichess account you want.

---

There are also other related sites worth exploring to understand their capabilities and how they may supplement the resources above.

**ChessTree.com**
Import/export PGNs. Search databases, get statistics. See opening relationships in a graphical tree.

**OpeningTree.com**
Import/export PGNs. Import and analyze a user's openings from a database, PGN, etc, including popular online chess sites.

# Answer
> 7 votes
There is already an offline program which has a lot of my ideas implemented:

http://www.chesspositiontrainer.com/index.php/en/features

But there is no good online tool which comes even close to that, let alone surpassing the linked offline tool. And I think an online tool, which stores the individual repertoire databases on a serve, would be much better, because then you could use the tool from any device, PC, tablet or smartphone. And if professionally made the online tool could easily surpass the offline tool linked above.

# Answer
> 6 votes
I was looking for the exact same thing and could not find what I wanted so I ended up building this free tool mychessnotebook.com ! It is a text editor which will automatically replace FEN formulas with pictures representing the chessboard (upon PDF export).

# Answer
> 5 votes
https://www.chess.com/openings

This opening explorer is so incredibly comprehensive and intuitive that I cannot imagine anything better. Just make sure you use the website, not the mobile app. The app is trash. The website is better optimized for mobile than the mobile app.

# Answer
> 4 votes
You may have a look at https://chess-repertoire-companion.com

It is free, online and still under development. You can use it from all your devices.

# Answer
> 0 votes
maybe openings101.org is what you are looking for.

---
Tags: opening, software, repertoire
---


# Question
Title: Why no notation for "Resigns" or "Lost on time"?
Suppose a chess game was decisive but didn't go to checkmate. Why does its notation not say whether the loser resigned or lost on time?

There are plenty of NAG symbols; even some ($136-$139) relating to time pressure. Why not for "White/Black resigns" or "White/Black lost on time"?

If we don't know because the only information known is what's on the scoresheets, then that doesn't answer the question; it merely redirects its focus: Considering that this fact is needed so that people know, and can say, how the game ended, why hasn't FIDE made it a law that players should record this on their scoresheets?

I know that players are not obliged to record this. I'm asking *why* it has not been thought necessary to oblige players to do this.

I know that PGN has a `Termination` tag, whose value is a string which someone might use to explain how come the game ended. But a game's score can be stated in a context which is not PGN. Even in a PGN file, the tags pertaining to a game are not part of its score (what PGN calls its "movetext"). Even among PGN tags, `Termination` is optional.

# Answer
> 4 votes
An answer to your question needs to go back to the beginning of PGN, which was invented by Steven Edwards in conjunction with countless contributors. Let's quote the man:

> ...it is important that future revisions to PGN must include a public discussion period. In fact, those of you who were reading the chess newsgroups back in the 1992-1994 time frame will recall the many polls and extensive discussion articles. I personally received uncounted hundreds, perhaps thousands of e-mails on the chess standards topics...

This teamwork under Stevens lead happened on rec.games.chess (to be found here). Todays kids can think of a discord server.

It is unlikely someone is going through all of it, and sadly, Edwards has passed away.

Most likely, they couldn't see a need for this since you really only miss the distinction between flagging and resigning, and what's the point of knowing when there is no move time indication anyway.

Another hint could be given by the paper scoresheets they had at their hands; if these didn't feature checkboxes for termination info (I've seen more that do, but 10 years later and in Europe), then they might just have missed it completely.

NAG came a year later, again done by Edwards, who wisely reserved indecies for future definition. Apparently it never occured to Edwards to attribute some of these reserved glyphs to the different terminations that he instead incorporated as 'optional tag pairs'.

Again, the why he did so is most likely lost with the man. But keep in mind these protocols were designed to allow for a client independent way of simply parsing a chess game, and NAG in particular to annotate games very efficiently. The related termination data may not even be at hands when the stagist had to type in scoresheet data via keyboard, so much better to have the option, but not the duty to.

# Answer
> 0 votes
> why hasn't FIDE made it a law that players should record this on their scoresheets?

The annotations on the scoresheet that FIDE requires all have to do with enforcing the FIDE Laws of Chess.

1. If you want to claim a draw via the 50 move rule you need to be able to show via your scoresheet that 50 moves have been made since the last pawn move or capture
2. If you want to claim a draw for 3-fold repetition, possibly with repetitions many moves apart you need to show this with the moves recorded on your scoresheet
3. If you want to complain about your opponent disturbing you by making repeated draw offers you better have been recording all those draw offers with a "=" or else the arbiter isn't going to take you seriously.
4. If you want the result of your game to be recorded in the tournament results correctly then make sure you put the result on your scoresheet, sign it and get your opponent to sign also.

Whether the game was decided by resignation, flag fall, phone going off, player not arriving in time, some other kind of default, etc. requires no special notation to satisfy any of the laws.

FIDE does not (or at least tries not to) make unnecessary rules. So, with no good reason for making it a rule, FIDE declines to make such a rule.

---
Tags: rules, fide, time-control, notation, resigning
---