title: Storing chess position in 24 Bytes

text:
# Question
Title: Storing chess position in 24 Bytes
I want a fast way to search how many times a certain position has appeared in a database of hundreds of thousands of games. I researched the best way to store positions in a database but all of the solutions were quite large and were stored as strings.

I thought of a different way and I was wondering if this would work or if there are some corner cases I did not consider.

Remember, the point of this storage would be to quickly search if a position had ever been reached before and not used to reconstruct entire games.

The first table would be int id, and BINARY(8) `pieceExist`

Starting from the top left of the board and reading to the right a1 would be set in a 64 bit number if any piece exists in that square and a 0 otherwise.

I would search this table first and retrieve a list of ids where pieces were in the same position as the board I am looking at

The next table would be int id (foreign key from the first table) Binary(16) `pieceSpecification`

This table specifies what piece is in each position, for every square where a piece exists you create a 4 bit number which would specify color and type of piece, which would has only 12 unique combinations. You would not need to store any information on where this piece is placed on the board as that is specified in the 64 bit number in the other table.

You would then find all ids where the `pieceSpecification` number you constructed has an equivalent value in the table.

You could probably off the database do a joint on the two sets of ids to see how many times your position has appeared in the database.

I reckon this approach has many benefits. Space in the database is minimized and searches would hypothetically be able to be completed in a matter of milliseconds.

Let me know if there are any problems with this or perhaps a better approach I could use.

# Answer
You can use the first 64 bits to encode which squares are occupied, and then encode what's in the occupied squares one by one, using four bits per square for up to 32 occupied squares.

The four bits allow sixteen possible piece types. There are only twelve types of pieces, but this lets us get in some additional necessary information. Here's an example encoding scheme.

0 - white pawn
1 - black pawn
2 - white knight
3 - black knight
4 - white bishop
5 - black bishop
6 - white rook that can't be castled with
7 - black rook that can't be castled with
8 - white rook that can be castled with
9 - black rook that can be castled with
A - white queen
B - black queen
C - white king if white has the move
D - black king if black has the move
E - the king that doesn't have the move
F - a pawn that has just advanced two squares

This should be enough to specify the position (piece locations, player to move, castling rights and en passant, but not fifty-move counter or move number).
> 6 votes

# Answer
24 bytes is 24 * 8 = 32 * 6 bits, giving us 6 bits for each of the 32 units, with none to spare. 6 bits gives just enough info to specify a square, with none to spare.

Specify, in this order, the positions of wK, wQ, 2 wRs, 2 wBs, 2 wNs, 8 wPs, then likewise for Black. Code that a unit is "off the board" by giving its position as the same as its side's king. However, this encodes only one-box positions: it fails to encode positions where a side has (say) 2 Qs.
> 2 votes

# Answer
You are on the right track.

With most databases, your most efficient organization would be a single user-defined table with two fields: your 64 (64 x 1) bit "square occupied" field, and your 128 (32 x 4) bit "next piece ID" field. The you instruct the database engine to sort the table and construct an index on the first field.

Don't worry about how to link the two fields or how to scan for the foreign key. Let the database engine do it; they're very good at this.
> 2 votes

# Answer
If you're just wanting to know whether a position has been occurred before (or keep count of occurrences), use a Zobrist hash. I believe X-piece endgame tables use Zobrist hashing. That boils down a unique representation of a position to a 64-bit integer. Polyglot opening books also use Zobrist hashing, and have standardised Zobrist keys, which might be useful for future compatibility (looking up occurring positions in an openings book)

Scanning through your approach you're not taking into account castling possibilities, en-passant possibilities, nor who is to move. These are important, because a position where the White king can castle is different to one with the exact same piece configuration but White cannot castle.
> 2 votes

# Answer
The fastest way to search a database is to use the same format as the database. Searching a tree database with a FEN is slow as a conversion is needed for each move. Although a shorter position storage would be useful, it's not likely to happen soon.
> 1 votes

---
Tags: programming
---


title: Did Fischer really have a 180 IQ?

text:
# Question
Title: Did Fischer really have a 180 IQ?
I have read many times that Bobby Fischer had an IQ of 180. Did he really have that high of an IQ? Does anyone have proof that he was ever even tested (like a citation from an early book about him)?

Sure, Fischer was an intelligent guy, but I tend to think that someone once made up that number, and it just stuck. Lately, I have seen the same, suspiciously rounded, number given to Kasparov and Carlsen.

A 180 IQ is so rare that most people have probably never met someone, who was officially tested, with such a high IQ. Thus, maybe they just assumed it must be super high, and threw out a number. 180 is in the 99.9999712895 percentile. 140 is already considered a genius and is in the 99.3790320141 percentile.

How can one even tell by just listening to his interviews if he was that intelligent? Is there any legitimate way to prove that claim or disprove it?

# Answer
From Quora: What was Bobby Fischer's IQ? (2018):

> Short answer: In 1958, when Fischer sat a Stanford-Binet test at the age of 15, **his score was 180-187.** But in today’s terms, Bobby Fischer’s IQ should be **148–155 on the Fifth edition of the Stanford-Binet test**, and **150-160 on the WISC-V/WAIS-IV tests** administered by Mensa.

The only reference provided for the 180-187 score is a link to the webpage The Mind of Bobby Fischer by Frank Brady where it states that

> In previous writings I have cited Fischer's I.Q. as in the range of 180, a very high genius. My source of information is impeccable: a highly regarded political scientist who coincidentally happened to be working in the grade adviser's office at Erasmus Hall - Bobby Fischer's high school in Brooklyn - at the time Fischer was a student there. He had the opportunity to study Fischer's personal records and there is no reason to believe his figure is inaccurate. Some critics have claimed that other teachers at Erasmus Hall at that time remember the figure to be much lower; but who the teachers are and what figures they remember have never been made clear.

The given rationales for the deflation of the score per today's standard are the Flynn effect based on a large meta-analysis that every year general intelligence increases by 1/3 IQ points, and the revised editions of the S-B test.
> 18 votes

# Answer
First of all, that test is considered by some psychologists a pseudoscience that doesn't measure intelligence at all.

I have Asperger disorder and hypercalculia as Bobby supposedly had. I once did the test after coming from a pub, having drunk a couple of beers, and I scored 133.

Far from being a genius, I am very stupid in most of facets of life; that test just measures one of the nine types of intelligence (logical-mathematical).

Source

I don't know if Bobby scored 180, but I can trust it. Why so? My top pick on tactics trainer is 2400 on chess.com (while I am a poor 1800 ELO player, my spatial intelligence is really bad). Bobby probably would reach \>3000 on tactics, and probably demolish that test, being close to the highest possible score, 200.

I guess many GMs or intelligence officers could score 180 if I got 133 drunk. Carlsen has 2900 ELO in blitz games, that tells a bit about his genius on logical intelligence and that test is also timed.
> 13 votes

# Answer
No.

I met Fischer twice at age 11 and 13.

He displayed nothing at all, which indicated he was not any sort of genius. Back then, his chess was still only good, not outstanding.

He was more an idiot savant who exceeded at one thing and was quite average at best at so many other, more important, things than chess.
> 2 votes

# Answer
As a psychologist, I don't see how he possibly could have scored a 180 IQ on the Stanford-Binet. He was a notoriously lousy student at anything other than chess and that test measures knowledge across a broad spectrum. On interview shows later in his life, his vocabulary was equivalent to an average eighth grader. (He read in several languages but spoke all of them poorly--including English.) His understanding of the world was superficial at best. You have to be intellectually gifted in a number of areas to attain a genius IQ. This he was not. He fits into the category of idiot savant more than genius, and I've evaluated plenty of both.
> 2 votes

---
Tags: history, famous-players, fischer, iq
---


title: Number of distinct checkmate positions

text:
# Question
Title: Number of distinct checkmate positions
What is the number of distinct checkmate positions in each of the following categories given the following conditions?

1. We are not interested in whether the position can be forced or not or even what sequences of moves can produce the positions. Similarly, these positions are irrespective of player color.
2. Promotion is only allowed if it will produce a set of pieces not possible from the initial set like 3 knights.
3. Redundant pieces like duplicate attackers and other pieces not contributing to the mate are not present.

Then how many exist in each of these categories?

1. A checkmate can exist on a corner, edge or the center, that is to say with 3 adjacent squares, 5, or 8.
2. Let n denote the number of pieces on the board excluding kings. Consider the number of partitions in 2 parts of n. Except for the single case of giving all of the pieces to one player this is the number of ways to divide the pieces between black and white. Of course this doesn't account for what the pieces are, but the question is only about the total number not what the positions actually are.
3. Then what is the number of checkmates for each relevant partition of each n subdivided by corner, edge, or center? Individual solutions for n=1 up to n=30 as much as possible (not that any positions with 32 pieces would satisfy condition #3. It is probably satisfied only for much smaller n). Although it is obvious I should also mention that for n\>15 the real number of relevant partitions is smaller because neither player can have \>16 pieces.

Again it doesn't matter whether the solution is constructive or not. I suppose a full solution at all is unlikely and a constructive solution would a wonderful bonus.

# Answer
I haven’t come across this question before. I don’t have the time to execute it, but hope these remarks and suggested approach are helpful.

First let’s clarify: (1) without loss of generality, white is mating black (2) position must be legal - in particularly white king must be on the board even if it doesn’t otherwise contribute to the mate. (3) legitimately promoted non-standard material is fine. (4) position must be minimal in that no subset of pieces can be removed to allow a position which still satisfies 1,2&3 above.

An algorithm could involve putting bK and the checking unit(s). Then consider all the flights, and the different ways they might be blocked. If a black unit might also interfere with check, then that interference needs to be covered. Then can find all the positions for wK if it’s not already placed. This gives a long list of positions which can be checked briefly for legality.

Mostly the positions will be left/right symmetric but there are a very few involving castling.

There are also some quite subtle positions where the position is only mate if we cannot prove that en passant is legal defence. Even some involving dead position rule.
> 3 votes

---
Tags: theory, checkmate, mathematics
---


# Question
Title: How to parse PGN string from an API with PHP?
I'm sending a request to the chess.com API to https://api.chess.com/pub/player/hikaru/games/2021/03

It will return all the games played by Hikaru in March of 2021, the interesting data is in the PGN key, however it seems to be stored in a string making parsing and extracting the data relatively difficult.

I am currently using PHP to send my curl request but I can't find a reliable way to parse the data within the PGN key to extract data like, opening, Elo, and most importantly the actual moves.

I considered using a regex which would work in most cases, but I worry the problems that may occur with a weird username.

# Answer
Parsing PGN string is quite straightforward, as you can simply follow the specification \[Wikipedia alternative\], and you can do it manually by processing it line by line.

There are already existing libraries that do this, for example, since you are using PHP, this is one PGN parser in PHP: https://github.com/amyboyd/pgn-parser
> 2 votes

---
Tags: programming, pgn
---


# Question
Title: How good can you get at bullet chess without playing standard?
I hate standard chess. Sitting there on your ass for hours on end obsessing over every single little move... it's a nerd's game. It's often talked about as being a game of intelligence, but there's a reason why computers are so much better at chess than humans, while there's no robot out there creating breakthroughs in mathematics or science. Because it's not about intelligence, it's tedious calculation and nothing else. Ultimately, all it comes down to is doing the calculations and memorizing the lines. It's a game for computers, not for humans.

It is for this exact reason that so many games end in draws. Because there's a limit to the degree that we humans can calculate and memorize lines, hence the best players are often equally good at it, hence nobody is at an advantage, hence it's a draw.

But I'm fascinated by bullet chess, or as a maximum, 3 minute blitz. Now, this is a game for humans. It's not about how nerdy you are with your calculations, it's about something that is a bit more ... intangible. It's about *instinct*... *intuition*, ... a certain feel for the flow of the game. These are human notions that you can't program into a computer, and that's what makes it so fascinating to me. I mean, a computer can play bullet too, but importantly, the computer does not think of bullet like a human does. The human plays it differently. However, in standard chess, both the human and the computer are doing the same thing: endless calculations.

So with that in mind, my question is, how good can you get at bullet chess, without playing standard chess at all?

For what it's worth, I am ranked 2300 on lichess (bullet), 2000 (3-min blitz) and 1800 (10-min rapid).

# Answer
I think that bullet is a skill that is half chess, but half is simply the ability to think and move quickly, which is the domain of young people. Yes, you can clearly get very good at it relative to your standard level of play. Your ratings seem to prove that.

I still question whether bullet is really good for your chess on a deeper level, but you do not seem to care about that, so if you are having fun, by all means, enjoy it. Nevertheless, this may still ultimately make you plateau permanently since bullet is very shallow in terms of depth of understanding. Plateaus vary from person to person, so just how good you can get will ultimately be something that you will have to just play and find out where you stand.

If you ultimately want to improve your depth of understanding, you do not have to choose between sitting there for hours, and bullet. You can play more using controls that are more of a happy medium.
> 12 votes

# Answer
Been there done that, done both.

You won't be much better than you can do OTB. Most players will be a few hundred rating points lower.

Top GMs can play speed chess almost as good as they do OTB. Most people play much worse.

How well you do at fast chess depends on how well you play. You would do much better if you played at a fixed increment that you must take between moves. In the old days that was ten seconds and we had weekly tournaments which greatly improved my OTB ability and kept me out of time trouble.

Bullet is its own game. If you enjoy it then go for it.

You should consider G10 and even tournaments at G30SD if you truly want to improve and also play slightly slower blitz games.

Do you have an OTB rating? I will guess that if you do not and start playing OTB it will be closer to 1500 or less. But you could be that genius that does really well.
> 2 votes

# Answer
My friends and I used to play chess everyday before school started in high school. We were all more or less novices, knew the rules and nothing more, absolutely terrible lol. Our games were probably between a 3-0 and 5-0 min control. We didn't really measure the time we just knew we had between 25-30 mins to play a few games before classes started. I remember thinking chess games were supposed to be an hour long ordeal or more, and that we were somehow breaking an unholy rule for our fast games, didn't care though, they were a lot of fun.

I graduated 11 years ago, and since then i've played online, 1 and 3 min only games. Initially i played a few 10min and even 5 min games but i quickly learned how ridiculously easy it is for people to cheat, (yeah i cheated a few times too, i was still new to the game and a sore loser... lol). Anyway since then, i've learned all my tactics and pattern recognition from just playing and watching other really strong players play. ChessNetwork (Jerry), Kingscrusher, agadmator and the ChessBrahs have been my main influences on Youtube and Twitch. The ChessBrahs Eric and Aman really pushed me to get better because they're so damn good and entertaining lol. Currently i'm 2135 bullet 2148 blitz on Lichess, and can easily maintain a 2100 rating in both. On Chess.com i'm 1950 bullet and 2018 blitz and can easily maintain and 2000-2050 rating in both. "SoDamnMetal" on both sites, hit me up for a game sometime. I feel like the cheaters are much more abundant on chess.com and my ping is not so good there either for some reason even though i live in the US.

Literally everything i know about chess is from bullet and blitz games and i find it hilarious how many people who get frustrated in bullet/blitz tournaments and say you absolutely cannot get better at chess through these time controls. These are the kind of people that rattle off theory and opening book moves like they're rain man or the next Bobby Fischer or something but you look at their profile and they're rated 1200-1500 xD. I know 0 about theory and openings, I believe the core of chess is tactics and pattern recognition, and your only limit is how much practice you put into them.

I'd like to get into a rapid and standard time control eventually but idk, the ease of cheating kind of has me jaded, plus the thrill of chess for me is the high octane, low time controls.
> 2 votes

# Answer
I belive you are wrong, if you look at players like Magnus Carlsen which can only see up to 10 moves in advanced (and of course not all moves but a small fraction) they can still beat an engine that looks 20 moves to the future because while they cant tell what will happen their intuition is high enough to understand how a position might evolve not by checking options but by understanding the dynamic between the diffrente pieces. To your question you would improve playing only bullet but you might want to consider blitz to improve not only your speed but also your tactics and general chess skill
> 0 votes

---
Tags: bullet-chess
---


title: Why is ...d5 the best move for Black?

text:
# Question
Title: Why is ...d5 the best move for Black?
I am learning chess and came across this position. Stockfish 11+ HCE (Depth 32/99) and Stockfish 13 (Depth 31/47) both says **...d5** is the best move for Black. But the next move is **exd6 e.p.**, leaving White's pawn at d6, defended by the e4-Knight and Queen, so Black cannot recapture it immediately with Bxd6.

Following along with the engine, Black doesn't really attacks the d6-pawn until at least 10+ moves later. So why did the engine suggest Black sacrifice the only central pawn it has for no apparent reason (at least to me)?

```
[FEN "r1bqkbnr/pp1p2pp/8/1p2P3/4N3/8/PPP2PPP/R1BQK2R b KQkq - 0 8"]
1. e4 e5 2. Nf3 Nc6 3. Bb5 f5 4. d4 fxe4 5. Nxe5 Nxe5 6. dxe5 c6 7. Nc3 cxb5 8. Nxe4

```

# Answer
> 4 votes
10+ moves later is enough! Note that material-wise, Black is already winning. The sacrifice Nc3 is far too speculative. What is the worst thing that could happen to Black? Nd6+, walling him in, or even followed by some Re1+ after exchange on d6. Thus, rather sacrifice a pawn while White hasn't even castled, than allow any swindles.

# Answer
> 2 votes
If you look at the position after move 8, Black is up material but has a relatively uglier position. It is in Black's interests to improve his position and if it involves giving back an adequate amount of material, then so be it. d5 forces White to waste time taking back the pawn, allowing Black to start developing his pieces.

---
Tags: engines, learning, sacrifice
---


title: Hashtable decreases playstrength

text:
# Question
Title: Hashtable decreases playstrength
I have implemented a simple variant of Zobrist keys to store and look up positional data, but whenever I let my engine play itself with either white or black using hashtables and the opponent doesn't, the player using the hashtable consistently performs worse.

I can rule out a significant computational load due to the hash key updates and storing/retrieval of data - the kilonodes per second are more or less within the same range. Secondly, I observe that in the endgame, a 9 ply depth of the player not using hashtables is met with about 11 plies for the player using hashtables. In the early game, there is almost no discernible advantage in search depth (**which is a side question - does that seem sensible?**). Still, given the increased endgame depth, one would expect a systematic benefit for the player using hashtables - all else being equal (no quiescence search, same allocated time for iterative deepening), that is.

Hence, I believe that the error has to do with storage or retrieval of data; or incorrect hash keys. The latter seems implausible based on tests. I would appreciate if anyone can point out a potential problem with the hashtable implementation.

Here is the code to insert data into the hashtable, which is called at each node when alpha beta returns a value:

```
void Hashtable::setHashData(int distanceToLeaf, int value, int alpha, int beta, std::tuple<char, char, char, char> preferredMove) {
    unsigned long index = Hashtable::hash % Hashtable::HASH_SIZE;
    if (((value > alpha) && (value < beta)) || (alpha == beta)) {
        Hashtable::table[index].type = NodeType::Exact;
        Hashtable::table[index].value = value;
    }
    else if (value >= beta) {
        Hashtable::table[index].type = NodeType::Upper;
        Hashtable::table[index].value = value;
    }
    else if (value <= alpha) {
        Hashtable::table[index].type = NodeType::Lower;
        Hashtable::table[index].value = value;
    }

    Hashtable::table[index].distanceToLeaf = distanceToLeaf;
    Hashtable::table[index].zobristKey = Hashtable::hash;
    Hashtable::table[index].preferredMove = preferredMove;
}

```

Here is the part of the alpha-beta-search function that invokes the hashtable. This part is executed *before* the possible moves at this position are determined and alphabeta is called recursively:

```
int Engine::alphaBeta(ChessBoard* board, Colour colour, char depth, int alpha, int beta)
[...]
if (useHashtable) {
    HashData data = Engine::transpos_table.getHashData();
    if ((data.zobristKey == Engine::transpos_table.hash) && (data.distanceToLeaf >= (depthLimit - depth))) {
        Engine::transpos_table.hashHits++;

        if ((data.type == NodeType::Exact))
            return data.value;
        else if ((data.type == NodeType::Lower) && (data.value < beta))
            beta = data.value;
        else if ((data.type == NodeType::Upper) && (data.value > alpha))
            alpha = data.value;

        if (alpha >= beta) return data.value;

        if (colour == Colour::White)
            return Engine::alphaBeta_preferredMove(board, Colour::White, depth, alpha, beta, data.preferredMove);
        else
            return Engine::alphaBeta_preferredMove(board, Colour::Black, depth, alpha, beta, data.preferredMove);
    }
}

```

The idea being that I either have searched a position fully (exact node- I can just return the value), or I can update alpha or beta if they provide an improvement of an earlier bound. Moreover, I can store the preferred move (may not be the best one due to an early cutoff) and pass that to an alpha beta implementation that executes this preferred move first (Engine::alphaBeta\_preferredMove).

Lastly, here is the code for updating the Zobrist key given a move (this has been tested to be self-inverse, but perhaps there is still a problem somewhere - and apologies for the lack of case statements, and the nasty std::get\<\> notation). Obviously, this gets called every time a move is made, and every time a move is unmade. "hk\_\[...\]" are (arrays of) random bitstrings per board feature that are initialized at the start.

```
    void Hashtable::updateHash(ChessBoard* board, MoveData move) {
    if (move.pieceMoved->colour == Colour::White) {
        hash ^= hk_blackToMove;
        if (move.pieceMoved->getPieceType() == PieceType::Pawn)
            hash = hash ^ hk_whitePawn[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_whitePawn[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Knight)
            hash = hash ^ hk_whiteKnight[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_whiteKnight[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Bishop)
            hash = hash ^ hk_whiteBishop[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_whiteBishop[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Rook)
            hash = hash ^ hk_whiteRook[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_whiteRook[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Queen)
            hash = hash ^ hk_whiteQueen[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_whiteQueen[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::King)
            hash = hash ^ hk_whiteKing[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_whiteKing[std::get<0>(move.dest)][std::get<1>(move.dest)];
        if (move.pieceTaken != nullptr) {
            if (move.pieceTaken->getPieceType() == PieceType::Pawn)
                hash = hash ^ hk_blackPawn[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Knight)
                hash = hash ^ hk_blackKnight[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Bishop)
                hash = hash ^ hk_blackBishop[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Rook)
                hash = hash ^ hk_blackRook[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Queen)
                hash = hash ^ hk_blackQueen[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::King)
                hash = hash ^ hk_blackKing[std::get<0>(move.dest)][std::get<1>(move.dest)];
        }
        if (move.isWhiteLRookCastling)
            hash = hash ^ hk_whiteLRookCastling;
        else if (move.isWhiteRRookCastling)
            hash = hash ^ hk_whiteRRookCastling;
    }
    else {
        hash = hash ^ hk_whiteToMove;
        if (move.pieceMoved->getPieceType() == PieceType::Pawn)
            hash = hash ^ hk_blackPawn[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_blackPawn[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Knight)
            hash = hash ^ hk_blackKnight[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_blackKnight[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Bishop)
            hash = hash ^ hk_blackBishop[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_blackBishop[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Rook)
            hash = hash ^ hk_blackRook[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_blackRook[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::Queen)
            hash = hash ^ hk_blackQueen[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_blackQueen[std::get<0>(move.dest)][std::get<1>(move.dest)];
        else if (move.pieceMoved->getPieceType() == PieceType::King)
            hash = hash ^ hk_blackKing[std::get<0>(move.orig)][std::get<1>(move.orig)] ^ hk_blackKing[std::get<0>(move.dest)][std::get<1>(move.dest)];
        if (move.pieceTaken != nullptr) {
            if (move.pieceTaken->getPieceType() == PieceType::Pawn)
                hash = hash ^ hk_whitePawn[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Knight)
                hash = hash ^ hk_whiteKnight[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Bishop)
                hash = hash ^ hk_whiteBishop[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Rook)
                hash = hash ^ hk_whiteRook[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::Queen)
                hash = hash ^ hk_whiteQueen[std::get<0>(move.dest)][std::get<1>(move.dest)];
            else if (move.pieceTaken->getPieceType() == PieceType::King)
                hash = hash ^ hk_whiteKing[std::get<0>(move.dest)][std::get<1>(move.dest)];
        }
        if (move.isBlackLRookCastling)
            hash = hash ^ hk_blackLRookCastling;
        else if (move.isBlackRRookCastling)
            hash = hash ^ hk_blackRRookCastling;
    }
    if (move.prevEnPassantPawn != std::tuple<char, char>(127, 127))
        hash = hash ^ hk_enPassantSquare[std::get<0>(move.prevEnPassantPawn)][std::get<1>(move.prevEnPassantPawn)];
}

```

# Answer
> 3 votes
There were three main issues - I was foolishly using unsigned long as a variable to store the hash instead of unsigned long long. I wrote a functionto detect hash collisions, and there were plenty. Lastly, there were two bugs with the hash generation that I have now fixed.

---
Tags: engines
---


# Question
Title: Is there some online chess board where you can teach a kid how to play?
A family friend wants to teach her grandchild how to play chess. The problem is that, due to the pandemic, they live apart from each other, so she has to do this online. Is there some website where the players can set up the board by themselves and only then start playing i.e. a website where you start the game as you would if you were playing OTB, which is by first setting up the board?

I am aware of Lichess' board editor (https://lichess.org/editor), which can be tweaked to work in the specific case from above (the kid can clear the board, set up the pieces by himself, send the invite link and then they may play), but I wonder if there is some better resource that I don't know of.

# Answer
> 3 votes
The websites lichess.com and apronus.com are your best options to chose from. They both do the same thing, but I suggest you use apronus.com.

You can set up the board by yourself, send an invite link, and do other things just like you want.

---
Tags: learning, online-chess, chessboards
---


# Question
Title: How do I play 30 second games on chess.com?
My current chess rating is approximately 1400 in 1 minute, 3 minute, and 5 minute games. I have seen some of the other players playing 30 seconds games whose rating is around 1200 but I cannot find an option to play 30 second games. How do I play 30 second games on chess.com?

# Answer
* Go into Live Chess.
* Click on the left button right above the "Play" button. It should currently display some time control.
* Click on the "More" button.
* Click on the "30 sec" button. For custom time controls, you can instead click on the "Custom" button and enter what you want.
> 7 votes

# Answer
Desperate to play 30 sec bullet in the chess.com app?

Go to: More -\> Watch -\> Top games.

If you're lucky you'll find some 30 sec games going on. If found, just click on it and wait for the game to end. A widget will then pop up showing stuffs related to the match. It will also have the button "New 30 sec". Yes! Click on that!

Also, to play next time, you can always click on one of your previous 30 sec games (I need not say the next step..).
> 2 votes

---
Tags: online-chess, time-control
---


# Question
Title: What are the differences between playing online and OTB?
What are some differences between playing online vs playing OTB (over-the-board)? If you are used to playing online, like myself, would playing OTB have a big impact on your play?

# Answer
Disclaimer: I don't belong to any sort of chess club, so OTB might mean something a little different for me and others like me.

One difference for me is the time constraints - OTB games for me are quite casual, and I don't own a chess clock, so while the players might rib each other during a particularly long "think", there aren't any hard and fast time rules. On the other hand, internet games always have the clock running, for obvious reasons. My play is worse online, probably because of that. For one thing, I never have the time to set aside an hour for an internet game, so I tend to choose the 10 min ones, resulting in shallower play. My OTB games, on the other hand, tend to go a lot deeper.

I haven't noticed any objective effect on my OTB games from playing on the internet, though. Since going online, I've been able to appreciate the lack of pressure in casual OTB games. The net effect is that I feel I play better OTB, so I'm more confident than I used to be.
> 15 votes

# Answer
I grew up playing Chess OTB with my father, but have since switched mostly to online chess. I sometimes attend a local chess club, and there we play more OTB games. When I play, I find that I'm a little bit less comfortable with OTB play, but not because of time constraints. For me, it's simply that I'm less used to the look and feel of the pieces compared to online. Even the slanted view of the board, and the fact that the pieces are 3D is sometimes strange after a long break from playing OTB.

On the other hand, once I get used to the fact that I'm physically moving pieces and hitting a clock after each move, there's no real difference. The biggest difference at that point comes in how the time controls are set. Online, you can typically pre-move pieces (move during your opponent's turn, so as to use less time), but such an option doesn't exist OTB. The best you can do is have a "delay" setting on your clock.
> 8 votes

# Answer
I'm surprised no-one mentioned illegal moves or touch-move rules - which are pretty much the biggest difference between OTB (tournament) and online play.

Obviously the software won't let you make an illegal move, like moving a piece into the wrong square or ignoring a check. If you make an illegal move in a blitz game OTB you could forfeit the game altogether. Also, if touch-move is enforced and you touch a piece, this is the piece you have to move, if you can do so legally.
> 8 votes

# Answer
You can expect many of your online opponents to use programs especially at slower time controls.

With OTB, there is none of that. You sit down, you punch the clock, and play. You talk to people about the game, get help from stronger players, play speed games between tournament rounds, and generally have a lot of fun.
> 5 votes

# Answer
I just wanted to make a comment regarding online ratings v. OTB ratings.

Most coaches that I have spoken to regarding OTB, USCF ratings vs an online long-time-control Internet rating suggest that the rating difference is generally between 100 and 130 points higher on the serious chess servers like ICC. This is generally said to be because either the pool of players is less skilled or the games are simply more informal.

I can personally move between OTB and computer-based play with no issues except for hitting the clock and writing down moves. When the game gets intense I frequently forget to write my moves and that is a very bad habit. But after 2 games or so I'm back in my stride and have all that worked out.

Hopefully come November when I get back to tournament play after years of not playing I will be able to just get back into the habit it without any issues.
> 5 votes

# Answer
The biggest difference for me between OTB and online is that online, the game is recorded automatically, so if it turns out it was interesting, I can analyze it and keep it for posterity.

In OTB I don't generally write down the moves, so if it happens to be interesting I end up regretting not having a record of it.

Other differences:

1. Naturally, online is purely about the game, while OTB has more of a social aspect to it.
2. This also leads me to play a bit more aggressively, because reaching interesting positions gets a higher weight in relation to purely maximizing winning odds.
3. OTB it's easier to place handicaps to make games more interesting. I don't know of a Chess Server that allows rated handicap games. Lichess' simul offering is lackluster. OTB there's no problem doing time odds, simul, or even material odds (though I rarely find a player interested in the latter).
> 3 votes

# Answer
I find blitz harder to play otb than online but really the way one plays otb should be the same as how they would play online as it's the same game and the same person playing the game. The main differences I find are the 3d pieces and board/surroundings, which can be quite daunting especially if I don't get regular'ish' practice otb, and I also tend to hesitate a lot more than I do online. I believe the hesitation aspect comes from the heightened fear of losing otb as apposed to online due to the personalization factor (opponent and onlookers) and as a result I tend to take less risks nor trust my intuition and as a result play worse, spend too much time and calculate less. I think really it's more of a psychological issue rather than a visual one and requires more self belief and trust in ones intuitive skills.
> 2 votes

# Answer
Before talking about my experience, I'll just say that I grew up playing OTB first at a young age, then started playing online. From your question, I also assume you haven't played OTB at a tournament yet.

Online games with long time controls are quite different to OTB. Staring a long time at the screen, on the same position, strain the eyes, and concentration can drop with the temptation to open a new tab during opponent's turn, or start some music. OTB, at most, sitting for a very long time can be uncomfortable, and keeping a straight back is hard once the game has gone on for long. Nevertheless, it's easier to keep concentration OTB than online.

With rapid and blitz games though, the difference is smaller. One key thing in OTB though is the feeling of hitting the clock in zeitnot, which is much more stressing than moving a piece online. Same for casual games, but like it was pointed out, it's easier to set up variants (try 4 man Blitz, it's great :))

The biggest difference between both though is that you're more physically involved OTB. In terms of comfort, you can settle down however you want in front of your computer, but you can't bring more than some food OTB at tournaments. Moreover, you see and touch the piece physically OTB; moving the mouse has a duller sensation because it's been held for a while in the same position. In tournaments, there's also the striking silence rythmed by hit clocks, it's very impressive the first time you experience it.

For all these reasons, I believe there's a big difference between playing online and OTB. Online is more convenient. OTB has a stronger, more unique feeling to it. If you can, try experiencing an OTB tournament for yourself.
> 1 votes

# Answer
Disclaimer: I never played online and never will.

Here are some differences maybe not yet mentioned.

* Cheating is a far bigger issue. (Especially the "incentive" for kids. I speak from dire experience.)
* You don't need a chess club and always find a partner, especially someone with the same strength.
* It's not really a social event online. Don't underestimate the "glue" factor of a club. (My personal and surely biased statistic says 100% of all women playing chess have a chess playing life partner. Improbable this will happen online...)
* You probably can "banter" online, but I guess it's not the same. Likewise for all psychological factors (Tal's demonic stare is legendary).
* On internet noone knows you are a dog. (Might also be relevant for kids, chess still has an "uncool" image.)
> 0 votes

---
Tags: online-chess, otb-chess
---


# Question
Title: How accurate is Chess Maniac's online rating estimator?
After decades away from tournament play, I decided to play in an open tourney my child entered. Trying to gauge how my game might have changed during my time away, I found an online rating estimator at Chess Maniac. I was surprised to find that it estimated me 500 points stronger than my (USCF) rating - which actually went down about 60 points at the tournament. So, how accurate is this estimator?

Edit: I realize the Chess Maniac page in question is just an estimator. I'm looking for answers indicating that it tends to overrate or underrate players and by how much. If it doesn't have a tendency one way or another, I'd like to know that.

# Answer
Absolutely inaccurate. ELO rating is determined by playing a whole game of chess, not by solving a few positions without any pressure.

Please play some online games for better estimate of your playing strength.
> 6 votes

# Answer
As I wrote in a comment above, I also believe that it is unrealistic for many reasons.

You could also think about it from a technical point of view. How would you program the evaluation function of that website (No idea whether that code is public or not.)?

The best you could do I believe is that you have each of the ten positions analyzed by an engine. Then you match the entered moves to the engine evaluation.

1. In the simplest case you just accept the best possible move and assign something like 200 ELO points to each correct answer (so as to cover roughly 2000 ELO point range from beginner level to World Champion). So you have a huge error just from the method used (not including all the other factors I mentioned in the comment).
2. If you want to do it a bit more fancy you could also accept second, third, etc. best moves and give ELO points for them, perhaps weighted (with an *arbitrary* weight). As you can see, all of this seems a bit random.

---

In summary a few points not related to the technical difficulties mentioned above:

* The ELO system is made to measure the *relative strength of players*, not the absolute strength (which might not even exist) as this site is trying to achieve. So by design, the ELO rating only tells you how strong you are relative to all other ELO rated players, not how strong you are overall.
* Players might have the same rating but completely different strength and weaknesses. How do you expect to measure all the different factors with just 10 puzzles?
> 2 votes

# Answer
I have an 850 rating on chess.com and I got a 1430 rating on the chess maniac estimator.

I mostly play unrated games on chess.com so perhaps my rating is a bit higher, closer to 950. That would mean the estimator is +500 which is the same as what you discovered.
> 0 votes

---
Tags: rating, online
---


# Question
Title: Transposition Tables Bug, implementation produces different results
I've been writing my chess engine for 2 months now, and I've come across this bug that I can't manage to solve. Basically, when I disable my transposition table, the engine plays fine and the minimax search selects one of the best options every time. With that said, when I enable them once again, it results in the selection of different moves than the optimal, which should not be happening (as their purpose is efficiency oriented).

```
    if maximizing_player:

        max_eval = -1*10**5

        for state in possible_states:

            node+= 1
            eval = hawkins.minimax(self, state, depth-1, alpha, beta, False, castling_chance, last_move, quiet)
            if eval[0] > max_eval:
                max_eval = eval[0]
                chosen = state
            alpha = max(alpha, eval[0])
            if beta <= alpha:
                cut += 1
                break
        transposition_table[mx] = (max_eval, chosen)
        return (max_eval, chosen)

    else:

        min_eval = 1*10**5

        for state in possible_states:
            node += 1
            eval = hawkins.minimax(self, state, depth-1, alpha, beta, True, castling_chance, last_move, quiet)
            if eval[0] < min_eval:
                min_eval = eval[0]
                chosen = state
            beta = min(beta, eval[0])
            if beta <= alpha:
                cut += 1
                break
        transposition_table[mx] = (min_eval, chosen)
        return (min_eval, chosen)

```

This is a simple minimax search implementation. When the depth reaches zero, I have a separate call to return a static evaluation. With that said, in my mind, I'm recording the best move possible and its score into a transposition table that has "mx" (the string that contains my game state) as a key. A little bit above the code snippet embedded, I wrote the following:

```
        if mx in transposition_table.keys():

        return transposition_table[mx]

```

So when we would find our "mx" once again, it would not spend resources trying to the best move possible. Could you please help me find what wrong with my implementation?

# Answer
> 2 votes
I am not sure I understand your exact code but my guess here is that you return a transposition table result, no matter the depth of the entry. So if you encounter a position and calculate it one ply deep, store it in the transposition table, and then the next iteration you want to search two plies deep but instead retrieve a one ply deep evaluation from the transposition table. The way around this is to store the depth in the transposition table entry and then only accept an entry if its depth is greater or equal than the required depth.

Another issue to take note of is that with an alpha beta search, for most nodes you won't know the exact evaluation, only an upper or lower bound. So if you store something in the transposition table you also have to remember whether the evaluation is an upper or lower bound, and then when retrieving have logic accordingly.

---
Tags: engines, transpositions
---


# Question
Title: What does this algebraic notation expression mean?
What does this algebraic notation expression mean?

```
exd5

```

There is no such notation as x. There is only a, b, c, d, e, f, g, and h. I don't know how this algebraic notation works.

# Answer
The "x" means "captures". So, exd5 means the e pawn captures the piece on d5, which may be either a pawn or a more valuable piece.

If the piece doing the capturing is not a pawn then the letter for the piece is used, e.g. Nxc3

Here is an example from the Scotch Gambit

```
[fen ""]

1. e4 e5 2. Nf3 Nc6 3. d4 exd4 4. c3 dxc3 5. Nxc3

```
> 14 votes

# Answer
For those of you (like me) who use this notation (x = capture) all the time: it's good to note that the confusion probably arises from a variant which uses a colon (:) to indicate captures. I've only seen it in old books myself, but Wikipedia lists it:

> A colon (:) is sometimes used instead of "x", either in the same place the "x" would go (**B:e5**) or at the end (**Be5:**), but this is not the FIDE standard.
> 2 votes

---
Tags: learning, beginner, notation
---


# Question
Title: What does an engine do if it has found the shortest mate?
For example, take this famous position from Kramnik vs. Deep Fritz, 2005:

```
[FEN "5N1k/6p1/7p/4P3/pp2Q3/4q3/1P4PP/2b4K w - - 0 1"]

```

Obviously White wins with Qh7#, and equally obviously, there are no possible better moves (since it's impossible to have a mate in 0).

If I let an engine run on this position, what does it do after finding the mate in 1? There's presumably nothing else to do since it has already found *the* best move. Does it just exit, then?

I tried running Stockfish 13 on this position, and it reaches depth 99/99 instantly, but I can't tell what it's doing afterwards.

# Answer
> 4 votes
It does what it was programmed to do. During any Alpha-Beta pruning, the computer would stop searching and just do nothing.

In another game, like an RTS, the computer would constantly go through a todo list. What should/can I build? What should/can I produce? How do I defend/attack? ...

Since a chess AI has only one objective, find the best move, there's no point in searching once it's objective if found.

---
Tags: engines, checkmate
---


# Question
Title: What does "White is down a rook for a pawn" mean?
I am not a native English speaker and I'm learning to play online chess. I often find a sentence with this pattern.

> White is down a rook for a pawn.

What does it mean? Could you elaborate on this sentence and make it much more understandable for me?

# Answer
It means that white is down a rook, and up a pawn compared to black. So black has one more rook than white, and white has one more pawn than black
> 33 votes

# Answer
Another aspect of the phrase you provided is how English uses "up" and "down". A player is considered "up" if they have an advantage. Likewise, being "down" mean a player has the worse position or piece count.

Because rooks are generally more valuable than pawns, whichever player still has the rook is in a better position and would be considered "up a rook for a pawn".

Combining these two ideas, "white is down a rook for a pawn" means that white has the worse end of the trade involving a rook and pawn. This means that white has lost a rook and only captured a pawn as compensation.
> 15 votes

---
Tags: terminology
---


# Question
Title: (Unbalanced) Double-Move chess - can white force a win?
I'm not talking about Marseillais chess (which is similar, but rules are added to reduce the advantage of the white), which is sometimes also called "balanced double-move chess".

In a Double-Move chess **both players** move **two times instead of once**. There is **no check, capture the king to win**.

Is the advantage of white sufficient? I.e. is it feasible to prove that white can always force a win?

Was a question like this examined in the past? I'm looking for references on any related work.

---

For example, if we were talking about Triple-Move chess (*both players move three times instead of once, there is no check, capture the king to win*), then white always wins on the "second move" by sacrificing the queen. That is, white makes their "first move" by: `pushing e pawn, queen to h5, queen to f7`, and black is lost!

To see why black is lost, observe the `f1 bishop`. It can capture the king on the next move either by `b5, d7, e8` or by `c4, f7, e8` (the white queen must be captured). If black captures the queen with anything but the king (i.e. spends two moves on the knight), then black does not have enough moves to defend both lines of attack from the bishop. Otherwise, if black captures with the king, then there are again two lines of attack from the `f1 bishop` and black again does not have enough moves to defend both. Black king gets captured on the "second move" in every scenario.

If we reduce the variant to Double-Move chess, is the advantage for white still significant enough such that we can possibly find the (least?) number of moves in which the white can force a win (capture black king), or is this variant as hard as solving the ordinary chess?

---

**Edit:** I'm aware that "If there was a perfect play from both sides, but each player was allowed to do 2 moves every time, would white win?" was asked before, but there it is not clear if the OP refers to the (balanced) Marseillais chess, or not. - Also, the answer there isn't useful as it simply states *"White would probably win. However, this is not certain..."* without further clarifications. (I.e. they appear to claim that it is as hard as ordinary chess, but this is not obvious.)

# Answer
We will prove that there exists a strategy for the white player that guarantees them a draw in the case of Double-Move chess.

Assume that such a strategy does not exist. This means that whatever move is made by the whites, there exists a strategy for the blacks leading to a win for them, i.e., the black player has a winning strategy. However, if the whites move a knight forth and back, the position on the board will be the same for the black player, as it was the initial position for the white player! Therefore, after such a move, the black player is not able to guarantee a draw and thus the white player must have a winning strategy. This is a contradiction since we assumed that the whites do not even have a strategy guaranteeing them a draw.
> 4 votes

---
Tags: chess-variants, solving
---


# Question
Title: What is the negative thinking method in chess?
A long time ago, someone told me about the negative thinking method. There is a saying that in every position there is a move that will not worsen it. The method goes as follows.

You chose n candidate moves which are possible in the position. You try to find out some good moves. If you reject n-1 move because they are worsening the position you can immediately play the n-th candidate move.

It has its, flaws but it could be useful sometimes. I tried to find out more about this technique, but I did not have luck. Has anyone here heard about that or something similar?

# Answer
> 2 votes
Taken literally, this seems a bit absurd. You don't explicitly reject moves that are so awful that no chess player would seriously consider them in the first place. Furthermore, there isn't a simple dichotomy of bad moves and good moves, where all but one move is bad (so that the good one can be arrived at by a process of elimination). There is more typically a continuum between awful moves and excellent moves, with many of the non-excellent moves not being actually bad but just not as good as possible.

On the other hand (if taken less literally) this way of thinking is related to prophylaxis in chess, which is a recognized approach to chess planning. Petrosian was a virtuoso in prophylaxis. He likely sometimes made moves after determining that any plausible alternative left his position potentially vulnerable to some future threat.

---
Tags: calculation
---


# Question
Title: Pressing the clock using the same hand you use to move the pieces
I participated in a club and went to training. The guy who played against me is right-handed, so he placed the clock on the right. I'm left-handed, so I play with the left hand and press the clock with my right hand since it's closer. It's not very convenient to press it with my left hand, as it's too far.

I was told that in tournaments, I have to press the clock with the same hand I use to move pieces. This is very annoying; is it a real rule? And can I place the clock on the left side? Why does the right-handed player get to place the clock on his right and not the other way around?

# Answer
The numbers refer to rules in the FIDE laws of chess.

> 6.2. A player must press his clock with the same hand with which he made his move. It is forbidden for a player to keep his finger on the clock or to ‘hover’ over it.

The rule that you have to press the clock with the same hand that you use to move the pieces is there to prevent players from pressing the clock before they have completed the move: if one is in such a time trouble that this rule matters, he/she would very probably, perhaps unconsciously, press the clock before he has clearly released his hand from the piece if this rule was not enforced. Nobody wants to see their opponent's hand over the board when their clock is running and they need to make a move quickly.

Often, the player with the black pieces is allowed to decide which side of the board the clock is on. Technically, the arbiter may place the clock on the side of the board where he sees it better \[rule 6.5\]. Often the player with the black pieces may choose on which side of the board he sits on, amounting to the same. (But this is no longer a rule in the Fide laws; some tournaments may not allow even doing that, for example because of carefully adjusted digital boards; in these cases the clock is almost always on the queenside (black's right hand side and white's left hand side).
> 19 votes

# Answer
Yes, press the clock with the same hand you use to move pieces is an actual rule in official tournaments (see Article 6.2.b of the FIDE Laws of chess).

Concerning the placement of the clock before the game, *"the arbiter shall decide where the chessclock is placed"* (see Article 6.5 in the same link as above). However the arbiter doesn't always give a recommendation. In that case it is conventional that the player with the Black pieces chooses the side for the clock.
> 16 votes

# Answer
To back up the other answers, yes of course it's a rule. Moving with one hand and pressing the clock with the other is cheating.

As a right-handed player (i.e. I write with my right hand) I make the obvious choice, when I'm given it, of putting the clock on the left hand side. Moving with the left hand is just as easy as with the right but I need my scorebook / scoresheet on the right hand side so that I can write the moves with my right hand. That is much easier with the clocks on the left. That way the clock doesn't take space I need for my scorebook and my clock action doesn't interfere with writing the moves.

My advice is learn to move with your left hand. It is much easier than learning to write with your left.
> 7 votes

# Answer
Ignore where the clock is placed and only concentrate on quickly using the same hand to move a piece and tap the clock. After a time it will come naturally.
> 0 votes

---
Tags: rules, tournament, pieces, chess-clocks
---


# Question
Title: Why does the engine tell me to sacrifice a queen for bishop after a failed Scholar's mate?
I am a beginner. Recently I have looked at the computer-generated analysis of one of my games and I found a surprising recommendation. Why is it best to sacrifice my Queen in this situation, as the screenshot shows?

```
[FEN ""]
[StartPly "10"]

1. e4 e5 2. Qf3 c6 3. Bxc4 Nf6 4. d3 d6 5. Bg5 Bg4

```

---

# Answer
It's basically a trade. After you take the bishop, if the opponent takes your queen with the knight, then your bishop is no longer blocked by the knight and you can take their queen too. The advantage here is that after the trade, the opponent's king will have to take your bishop, and thus can no longer castle.
> 40 votes

# Answer
As @Ibrahim explains, you'll win the queen back, but after that White can even take the pawn on f7:

```
[FEN ""]
[StartPly "10"]

1. e4 e5 2. Qf3 c6 3. Bxc4 Nf6 4. d3 d6 5. Bg5 Bg4 6. Qxg4 Nxg4 7. Bxd8 Kxd8 8. Bxf7

```

and White is a pawn up.
> 36 votes

# Answer
The other answers already explain what's going on, but there's standard terminology for it:

*This is not actually a sacrifice, merely a queen **trade**, because **the knight is pinned** against the black queen.*
> 8 votes

# Answer
Then you can take f7 with bishop and you are one pawn up
> -4 votes

# Answer
Material superiority does not always equate with winning. A myriad of games have been won by players with less point values on the board.

For the reason above, running an analysis may not show the advantage of a particular move until a dozen or so moves later.
> -5 votes

---
Tags: engines, learning
---


# Question
Title: How many moves needed for a knight to go from any square to any other square?
I want to find a sequence of knight moves that has a given origin and destination squares, preferably with the minimum number of moves. I can iterate over knight moves and collect visited squares, until I visit the destination square. I am asking how many iterations would I need to not miss an answer for any given pairs of squares.

I am trying to find the minimum number of iterations needed for looking at piece moves needed to reach from one square to a different square. I know bishops can't reach every square. I guess the knight is the slowest piece, except pawns, thus the title question is right to determine this problem. So I want an answer for every piece to reach every pair of squares.

# Answer
> 15 votes
You are asking for the diameter of the knight's graph. I suppose you only want it for the ordinary 8x8 chessboard. (See OEIS sequence A232007 for diameters of knight's graphs on square boards of size nxn, in particular confirming my answer 6 for the case n = 8. The answer is alleged to be ceiling(2n/3) for n \> 4.)

The answer is 6. It takes 6 moves to get from a corner square to the opposite corner, say from a8 to h1.

There are many ways to get from a8 to h1 in 6 moves, e.g. a8-c7-e8-g7-h5-g3-h1.

To see that you can't get from a8 to h1 in less than 6 moves: First note that the Euclidean distance between a8 and h1 (measured from center to center and taking the side of a square as the unit of distance) is sqrt(7^2 + 7^2) = sqrt(98). The length of a single knight move is sqrt(2^2 + 1^2) = sqrt(5), so the maximum distance you can travel in 4 knight moves is 4 * sqrt(5) = sqrt(80) \< sqrt(98), so a knight can't get from a8 to h1 in 4 moves or less. But it must take an even number of moves (since a8 and h1 have the same color), so at least 6 moves are needed.

Finally I have to show that you can get from any square to any other in at most 6 moves. This will take a bit of case work.

I. Starting from e4, you can reach any square in at most 3 moves, **except** the squares a8, c2, c6, g2, g6.

To see this, take an 8x8 grid and write 0 on the square e4. Next, write 1 on each square that can be reached by a knight's move from e4. Next, write 2 on each unmarked square within a knight's move of a square marked 1. Finally, write 3 on each remaining square which is a knight's move from a square marked 2. You will see that every square has been marked except for the five squares a8, c2, c6, g2, g6.

II. Therefore, a knight can get from any square to any other via e4 in at most 6 moves, **unless** at least one of the two squares is a8, c2, c6, g2, or g6.

III. By the same procedure as in step I, you can show that from c6 you can reach any square in at most 4 moves.

IV. From c2 (or g6) you can reach any square in at most 5 moves.

V. From g2 you can reach any square in at most 5 moves.

VI. From a8 you can reach any square in at most 6 moves.

Therefore, a knight can get from any square of the 8x8 chessboard to any other in a maximum of 6 moves (5 moves if the squares have opposite colors).

**P.S.** @Laska pointed out in a comment that this argument can be simplified:

> I think the sufficiency argument can be simplified as the e4 statement also works for e5, d4 & d5. The tricky squares for e4 are those which are 2xsqrt(2) or 4xsqrt(2) away. No square is this distance from more than one of e4, e5, d4 & d5. So given any two squares there are at least two routes in 6 or less moves. They visit different squares in the centre 4: e4, e5, d4, d5. – Laska

# Answer
> 5 votes
The minimum number of knight moves required to be able to reach every square on the board, is 4 to 6, depending on which square you start from. Below is an overview; the number in each square indicates the minimum number of moves when starting from that square:

```
[6,5,5,5,5,5,5,6]
[5,5,5,4,4,5,5,5]
[5,5,4,4,4,4,5,5]
[5,4,4,4,4,4,4,5]
[5,4,4,4,4,4,4,5]
[5,5,4,4,4,4,5,5]
[5,5,5,4,4,5,5,5]
[6,5,5,5,5,5,5,6]

```

There are of course only 10 different sorts of squares, the rest of the board is these squares mirrored around a center line or a diagonal:

```
[6, , , , , , , ]
[5,5, , , , , , ]
[5,5,4, , , , , ]
[5,4,4,4, , , , ]
[ , , , , , , , ]
[ , , , , , , , ]
[ , , , , , , , ]
[ , , , , , , , ]

```

The minimum number of moves to reach each square on the board from each of these 10 types of squares are shown below. The starting square is indicated by 0.

```
[0,3,2,3,2,3,4,5]
[3,4,1,2,3,4,3,4]
[2,1,4,3,2,3,4,5]
[3,2,3,2,3,4,3,4]
[2,3,2,3,4,3,4,5]
[3,4,3,4,3,4,5,4]
[4,3,4,3,4,5,4,5]
[5,4,5,4,5,4,5,6], max = 6

[3,2,1,2,3,4,3,4]
[0,3,2,3,2,3,4,5]
[3,2,1,2,3,4,3,4]
[2,1,4,3,2,3,4,5]
[3,2,3,2,3,4,3,4]
[2,3,2,3,4,3,4,5]
[3,4,3,4,3,4,5,4]
[4,3,4,3,4,5,4,5], max = 5

[2,1,4,3,2,3,4,5]
[3,2,1,2,3,4,3,4]
[0,3,2,3,2,3,4,5]
[3,2,1,2,3,4,3,4]
[2,1,4,3,2,3,4,5]
[3,2,3,2,3,4,3,4]
[2,3,2,3,4,3,4,5]
[3,4,3,4,3,4,5,4], max = 5

[3,2,3,2,3,4,3,4]
[2,1,4,3,2,3,4,5]
[3,2,1,2,3,4,3,4]
[0,3,2,3,2,3,4,5]
[3,2,1,2,3,4,3,4]
[2,1,4,3,2,3,4,5]
[3,2,3,2,3,4,3,4]
[2,3,2,3,4,3,4,5], max = 5

[4,3,2,1,2,3,4,3]
[3,0,3,2,3,2,3,4]
[2,3,2,1,2,3,4,3]
[1,2,1,4,3,2,3,4]
[2,3,2,3,2,3,4,3]
[3,2,3,2,3,4,3,4]
[4,3,4,3,4,3,4,5]
[3,4,3,4,3,4,5,4], max = 5

[1,2,1,4,3,2,3,4]
[2,3,2,1,2,3,4,3]
[3,0,3,2,3,2,3,4]
[2,3,2,1,2,3,4,3]
[1,2,1,4,3,2,3,4]
[2,3,2,3,2,3,4,3]
[3,2,3,2,3,4,3,4]
[4,3,4,3,4,3,4,5], max = 5

[2,3,2,3,2,3,4,3]
[1,2,1,4,3,2,3,4]
[2,3,2,1,2,3,4,3]
[3,0,3,2,3,2,3,4]
[2,3,2,1,2,3,4,3]
[1,2,1,4,3,2,3,4]
[2,3,2,3,2,3,4,3]
[3,2,3,2,3,4,3,4], max = 4

[4,1,2,1,4,3,2,3]
[1,2,3,2,1,2,3,4]
[2,3,0,3,2,3,2,3]
[1,2,3,2,1,2,3,4]
[4,1,2,1,4,3,2,3]
[3,2,3,2,3,2,3,4]
[2,3,2,3,2,3,4,3]
[3,4,3,4,3,4,3,4], max = 4

[3,2,3,2,3,2,3,4]
[4,1,2,1,4,3,2,3]
[1,2,3,2,1,2,3,4]
[2,3,0,3,2,3,2,3]
[1,2,3,2,1,2,3,4]
[4,1,2,1,4,3,2,3]
[3,2,3,2,3,2,3,4]
[2,3,2,3,2,3,4,3], max = 4

[2,3,2,3,2,3,2,3]
[3,4,1,2,1,4,3,2]
[2,1,2,3,2,1,2,3]
[3,2,3,0,3,2,3,2]
[2,1,2,3,2,1,2,3]
[3,4,1,2,1,4,3,2]
[2,3,2,3,2,3,2,3]
[3,2,3,2,3,2,3,4], max = 4

```

This can be easily programmed using e.g. Dijkstra's Algorithm, and is a typical programming exercise when learning about pathfinding algorithms.

---
Tags: mathematics, tempo
---


title: Using Stockfish in Commercial Apps

text:
# Question
Title: Using Stockfish in Commercial Apps
Stockfish uses a GPLv3 license, which requires you to release your source code if you use it. This then makes your own code GPLv3. However, chess.com, chessable and decodechess all use Stockfish.

So, how do they use it without releasing their source code? Or, are they taking a risk?

I've read some stuff about pipes, wrappers, running off the server does not count as distribution. Perhaps someone with more knowledge on this can share what they know.

# Answer
I'm the Technical Lead of Chessable and the exact person who integrated SF on Chessable.

There are no license issues here because web app is not the same work as a Universal Chess Interface (UCI) chess engine.

Technically you do have the code because the whole UI in JavaScript is being sent to your web browser. Check your Google Chrome network tab, you will find all the JS source code there! We are doing client side JS Stockfish integration, so we can't stop you from copying the minified but working JS code. However, we are not going to give you the code like in GitHub format.

Thanks for trying our SF integration!

https://opensource.stackexchange.com/questions/11490/minified-gpl-code-inside-javascript-webapp is incorrect. The answer failed to address the UCI protocol. All communications via the engine is being done by the UCI protocol. The exact same code without any kind of modification can run on any other chess engines following the UCI protocol. Komodo on chess.com is an excellent example.

The engine and rest of the app is not considered a standalone work, which is what GPL is about. It's like Chessbase shipping their GUI and Fat Fritz 2. Did you ask Chessbase for source code of their GUI? The SF engine in JS is not an executable linking to the app. It's actually **you** who chooses a browser and run the SF. It does that by running web workers like Chessbase on a standard UCI protocol. Stockfish is not a library or derived work, it's an independent piece of code that your own browser runs it.

PS: Any views here are not my employer's and purely mine.
> 6 votes

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


title: Countering The Wayward Queen Attack

text:
# Question
Title: Countering The Wayward Queen Attack
I'm a new player =I just started playing again after an over 10 year hiatus. I'm (sadly) in the 600s.

I've been studying openings and I seem to do better in games where I can use the Italian game or Ruy Lopez. However, there's a strange game that I *continually* lose a slow and painful game against and it's the family of plays that have the queen out causing havoc early. In particular, the \[Wayward Queen Attack\]\[1\] has been at the heart of every game I've lost in the last 3 days.

I mostly contribute this to my lack of piece development out of fear of losing pieces to a queen. How should I counter it? \[1\]: https://en.wikipedia.org/wiki/Wayward\_Queen\_Attack "The Wayward Queen Attack"

# Answer
First of all, despite the stigma attached to early queen moves Nakamura has played the white side of `1. e4 e5 2. Qh5` several times in top level play, so it is a move you should treat with respect.

The best approach is probably to play moves like `2... Nc6` to protect the e pawn, `3... g6` to kick away the queen, then `Nf6`, `Bg7`, castles to get your king safe. Then if the white queen is still in the middle of the board try and attack it with your pieces.

Then you are in a normal game and if you blunder pieces because of your low rating then consider that your low rating is probably because of your poor tactical ability. To correct this you need to work on tactics. Learn about pins, forks, skewers, discovered attacks, etc. and do lots of puzzles to try and improve.
> 19 votes

# Answer
I have played against this opening in many blitz games online and I think it just amounts to unnecessary loss of tempo for white because because black can play 1.Nc6

protecting the pawn and also developing the knight. After white played Bc4 threatening mate on f7 black chases the Queen by playing g6, usually the Queen moves to f3 still attacking f7 then you can develop your other Knight by playing Nf6 white usually replies with c3 preventing Nd4... black usually has a good game after that.
> 6 votes

# Answer
I believe that `2...Qe7` is reasonable approach especially for beginner. It protects the e5 pawn; it protects the f7 square: less things to worry about. Black development plan would be something like this: `Nc6, g6, Bg7, Nf6, 0-0`.
> 3 votes

# Answer
Here's a great little trap where when you can try trapping their queen. The only out of the trap is accepting a queen exchange .
> 1 votes

# Answer
I have never lost against this and only a handful of people have tried it on me. Straightforward development does the job very nicely. Be patient and just play positionally and black will get a good game.

Nc6 protects the pawn. Threatening Nf6 attacking the queen and gaining the initiative. White could try Bc4 to get a mate but P-g3 stops that and white has a misplaced queen and trouble developing the king side horsey as well as it could have been.
> 1 votes

# Answer
Since White wants a scholar's mate, I will run over a sample line.

1. e4 e5 2. Qh5??? Nc6 3. Bc4 g6 4. Qf3 Nf6 5. Qb3 Nd4!

Simply kick White's queen around while developing.
> 0 votes

# Answer
Just play 1.e4 e5 2.Qh5 Nf6 3.Qxe5+ Be7 and you have a fine game, except for having one less pawn, which means nothing in the 600s. For that matter, the computer evaluates this position as an even game, meaning that Black has full compensation for the pawn.
> 0 votes

---
Tags: opening, queens
---


# Question
Title: Is acceptable to consult with your team during a match break?
### The context

I am not into chess, but The Queen’s Gambit revealed its interesting world, and something got stuck into my mind.

As shown by this article the movie had to make compromises, especially when depicting the tournaments which have quite strict rules, thus making them very boring for the commercial movie consumers.

### The issue

The last match was so long that it required an overnight break. During this break, the players consulted with their teams and the movie suggests that Beth winning was partially influenced by this help. **Is this possible in real-life tournaments?**

I tried finding an answer, but only got this Quora discussion which suggests that long (overnight) breaks during tournaments are something very rare today.

# Answer
> 24 votes
I haven't seen the series, but this was a quite common practice known as adjournment. It is indeed legal to ask for outside help, in the form of teammates and even computer programs during adjournment. However, they rarely happen anymore:

> With the advent of strong chess playing computer programs, which can be used to analyze adjourned positions, most tournaments have abandoned adjourning games in favor of shorter time controls. The first World Chess Championship not to use adjournments was the Classical World Chess Championship 1995, while the last one to use adjournments was the FIDE World Chess Championship 1996.

The Laws of Chess still have guidelines for adjournment, so it's possible to organize a tournament with these breaks, but I can't remember a recent high-level tournament which had them.

---
Tags: rules, tournament, team
---


# Question
Title: Why not 7.Bb4+ before playing Ne7 in the French Defence: Advance, Paulsen Attack?
After playing 5.Qb6 which I believe is the final move of the Advance variation of the French, my opponent played 6.a4. I followed with cxd4 and them by cxd4 as well. After that I couldn't remember the best theoretical move so I just played 7.Bd7, as I often find it hard to activate it later on when opening with the French.

```
[fen ""]
1. e4 e6 2. d4 d5 3. e5 c5 4. c3 Nc6 5. Nf3 Qb6 6. a4 cxd4 7. cxd4

```

I analysed the game with Stockfish and looked at the database on 365Chess, and saw that the most played move in this position was 7.Bb4+ which makes sense: developing the bishop with tempo, adding some pressure, without real risk before continuing development. However I let Stockfish run until depth 42 and these were the top 3 moves:

Bb4+ apparently isn't such a good move in this position. Any ideas why ? As I've said, I don't see the problem with playing 7.Bb4+ then 8.Nge7 for example. I acknowledge that it lets the opponent develop their knight on c3 but don't have the chess level to know why it's and advantage for them more than it is for me apparently.

# Answer
Look at the stockfish lines after Nge7, or, Bd7, or a6. In all of them, black play Na5-b3 sooner or later, and for that the knight on b3 needs the queen's support. In that regard, Bb4+ is really not helping after, say, white plays Nc3 and the bishop on b4 blocks the queen from controlling the b3 square. Apparently Stockfish likes the Na5-b3 maneuver so much that anything else is inferior here.

Actually, a4 is just terrible, so black should easily equalize here with or without Bb4 (from a French player perspective).
> 3 votes

---
Tags: opening, analysis, french-defense
---


title: A cool problem by Godfrey Heathcote

text:
# Question
Title: A cool problem by Godfrey Heathcote
I didn't get a thought of a better title :)

I am trying to solve a problem which is `white to move and mate in 2 moves`.

To be frank, I am not asking all problems here. On my own I solved more than 50 and stuck up in nearly 15 (*don't worry I will not ask all here itself, I am still trying to solve them*)

```
[FEN "8/qQ5p/3pN2K/3pp1R/4k/7N/1b1PP/8 w - - 0 1"]

```

# Answer
> 13 votes
1.Nd4! threatening 2.Rg4#

1...Kxd4 2.Qb4#

1...Bxd4 2.Qb1#

1...Qxd4 2.Qxh7#

2...exd4 2.Qxd5#

# Answer
> -1 votes
Qxa7

if d4 then simply move the queen back to b7 (mate)

if black moves the bishop instead then simply Qxh7 (mate)

---
Tags: problems
---


# Question
Title: Why won't elite players like Nakamura play a (fair) game against AlphaZero just to see how it goes?
You know, both for entertainment and to analyze what moves he made were blunders/sub-optimal?

Like, the handicap thing is not a real game, and also humiliating for the grandmaster.

Like how would a fair game between nakamura and AlphaZero go anyways? Would he even get to the endgame? What if we gave him takebacks? As well as more time?

# Answer
> 4 votes
If you'd be willing to sponsor such an event, I'm sure Nakamura will do it.

# Answer
> 4 votes
Not directly an answer to your question, but I suspect you'd be interested.

If Nakamura were trying, he'd probably get a draw (at least as White). That's because AlphaZero does not have contempt and will happily enter drawing lines if it believes it has the worse position.

Check out what happened when a few other humans tried it. The humans had White, played the Ruy Lopez, and lo and behold AlphaZero went into the Berlin Defence, accepted mass simplifications, and a draw. I'll just quote IM Malcolm Pein:

> We were so lucky in game one. It was pretty much miraculous, as in we didn't just park the bus in the Berlin Defence, more like we were so lucky we even guessed exactly beforehand where in the car park we'd park it.

**Edit:** actually, he might even win most games. That's because AlphaZero is nearly deterministic, so all Nakamura has to do is memorize the games which AlphaZero lost and keep repeating them.

# Answer
> 3 votes
A fair match without any handicap is just pretty pointless. You wouldn't ask Usain Bolt to race against a car, simply because "What is the point?".

The reason handicap matches are done is because there the result is in doubt. Will Nakamura beat Leela when starting up two pawns? Maybe, we don't know. That makes it interesting. Will he beat Leela or Stockfish with equal material in the normal starting position? No, he won't.

What if we give him takebacks or more time? Well, that is a handicap. Time odds are not that unusual for a handicap match. And sure enough, if you take away enough time from the engine's thinking time it would be an interesting contest once again. But that then is a handicap match.

# Answer
> 2 votes
AlphaZero is Google owned. There is no way anybody but Google can run it. It's not designed for standard PCs.

AlphaZero will beat Nakamura easily. It's like running a match between myself and Magnus Carlsen for the world title. Nobody wants to see it.

---
Tags: engines
---


# Question
Title: White's 'aggressive' attack after Sic. defense opening
Searching for the Mackenzie(?) or Mcallister (?) attack: White King’s pawn opening led to good center control with Bishop and both Rooks at d1 and e1.

Can’t the replay on Chess.com because I wasn’t signed in. I did beat a Masters level computer game.

# Answer
> 2 votes
There's an opening that's called "Ruy López Opening: Morphy Defense, Mackenzie Variation" but it only partially fits your description. It goes like this:

```
[FEN ""]
1.e4 e5 2.Nf3 Nc6 3.Bb5 a6 4.Ba4 Nf6 5.d4

```

It does have e4 and Bb5, but it has d4 instead of g4.

---
Tags: strategy
---


# Question
Title: Which of the pawns in front of the king should be moved in order to prevent a back-rank mate?
Assuming we're playing white and a bank rank mate is being threatened. Which one of the pawns (f, g, or h), in most cases, should be moved? Is there a general rule for this?

# Answer
> 8 votes
Of course, the **concrete position** is always more important than general "rules". However, as some guidelines of what is typically played:

* **f2-f3**: Rarely. It opens up a dangerous diagonal (a7-g1) and usually also the second rank (normally, the d- and e- pawns were moved early on). Even if Black can't mate directly, they can often at least kick White's king around.
* **f2-f4**: Occasionally, to immediately counter-attack a Black center position on e5 (if the second rank can be covered through other means).
* **g2-g3**: Occasionally. Also opens up a diagonal (a8-h1), but that can be okay if Black has no queen and light-squared bishop anymore to exploit it and/or if White can play their own light-squared bishop to this diagonal.
* **g2-g4 or h2-h4**: Occasionally. Can make sense to grab space when there are few pieces left (the pawns get vulnerable to piece attacks) or sometimes even to launch a counter-attack on Black's king.
* **h2-h3**: Statistically, probably the most played among the pawn moves. It creates the smallest weaknesses on paper - but as can be seen from the many alternatives, it's by far not a move that should be played in all positions. Especially not if Black controls h2 with another piece, obviously.
* **No pawn move at all**: The better the player, the more likely they are to try and parry the threat without actually moving pawns. Usually, moving flank pawns to open up a vital escape square for your king doesn't do anything else on the board (especially when moving to only the third rank) and can thus be seen as a waste of tempo (on top of creating structural weaknesses). Sometimes, that's a sacrifice you just have to make to prevent mate, but if there is another way (covering the checking square with a piece, blocking the way, etc.), it's often to prefer.

# Answer
> 4 votes
Adding to what @Annatar has already analyzed in-depth, you may see Grand master's saying never play f6/f3 (e.g. Ben Finegold), and take that as an unspoken rule. That is not the case. Those sayings do exist because those diagonals are often dangerous for the king(depends on the position and the existence of enemy bishop). Also, it becomes a meme :P So a little heads up to what you may see or you may have already seen, don't take those as a rule immediately.

Basically, you just have to be aware of dangerous diagonals, where the enemy can attack and the best pawn move will change accordingly.

---
Tags: checkmate
---


# Question
Title: In chess.com analysis, why is a rook promotion better than a queen promotion?
I was analyzing a game on chess.com and it showed me that, in the below scenario, it is better to promote to a rook instead of promoting to a queen. It also shows that it has a mate in 6 with the queen, but it also a mate in 4.

I am not sure why chess.com thinks it is mate in 6 and why the rook move is better. I am only ~1200 so I could be missing something obvious. Do you have any ideas?

The game can be seen below, or here on chess.com.

```
[fen "2k3r1/ppp4P/3rp1Q1/8/3P4/4q3/PPP5/1K1R2R1 w - - 0 1"]
1. d4 d5 Bf4 Nc6 Nf3 Bf5 e3 Nf6 Bd3 Bg6 Nc3 e6 Ne5 Be7 h4 Nxe5 Bxe5 Qd7 g4 Bxd3 Qxd3 O-O-O g5 Ne4 Nxe4 dxe4 Qxe4 Bd6 Bxg7 Rhg8 Bf6 Be7 Bxe7 Qxe7 O-O-O Qd6 Qxh7 Qa6 Kb1 Qd6 Qxf7 Rgf8 Qh5 Rxf2 g6 Rff8 g7 Rg8 Rhg1 Rd7 Qh8 Rdd8 Qh7 Qd5 h5 Qf3 h6 Qxe3 Qg6 Rd6 h7 Rgd8 g8=Q Rxg8 hxg8=Q+ Rd8 Qxd8+ Kxd8 Qh7 Qc1+ Rxc1 c5 Rg8#

```

# Answer
There's no reason why the rook promotion is better. Don't listen to engines in positions where there's such a big imbalance
> 8 votes

# Answer
Chess engines prefer to checkmate you as soon as they can, and if they can checkmate you in 10 moves, they look if they can also checkmate you in 9 moves. That's also why chess.com thinks rook promotion is better, because it saw a sooner mate. But if you see a mate in 3 and don't see the mate in 1, just play the mate in 3
> 2 votes

---
Tags: analysis, checkmate, pawn-promotion, chess.com
---


# Question
Title: Tools to analyse weaknesses based on Lichess history
Are there any tools that can find weaknesses in your games based on your Lichess history (eg, you often play a particularly bad line in a certain opening, or often fall for a certain trap), and then perhaps offers training to help rectify it?

# Answer
Yes. Certainly. AimChess does exactly that. You may want to pay for it.
> 2 votes

# Answer
I agree that AimChess is a paid service that seeks to give you customized answers using some fancy machine learning algorithms and normal engine play.

However, I think you can recreate most of this yourself from some combination of openingtree.com, the default opening book, and lichess insights. Specifically, I'd first look at openingtree and your insights to see which openings you struggle with. Within those openings, see if there are lines you are going for that are suboptimal by comparing your play against the masters database. Are you comfortable with the resulting positions you're getting, even if they are "best" play? If not, you should look at a collection of master games from those positions and see if you can guess the move. If you are aware of what to do but just don't like the positions, maybe you should look at different move orders that avoid the openings themselves.

Lichess insights on its own can also show you if you're too often moving your queen in specific openings, or if you are too rash in pawn moves, but nothing will ultimately beat you just putting in the time and energy to explore options within specific openings and see what typical plans players much higher rated than you attempt.
> 2 votes

# Answer
Lichess saves all chess games I played, and anybody can go to my profile page, filter on the games I lost, and see which openings I played there. Because I analyze a lot of my games, you can see where it went wrong.

Tool: lichess database and your own time

O jea, you can also see timing there, so you can also see in what time I played my blunders (rapid, correspondense, unlimited, ...)
> 0 votes

---
Tags: analysis, training, lichess, opening-traps
---


# Question
Title: Black's tools in the Caro-Kann Advanced Tal Variation
What are Black's plans to play for an advantage in this variation?

```
[FEN ""]

1. e4 c6 2. d4 d5 3. e5 Bf5 4. h4 h5 5. Bd3 Bxd3 6. Qxd3 e6

```

The kingside development seems so slow, allowing White to develop, castle, and break on c4 before Black has even castled. Is it sound to play Qb6, with c4 at some point as Black with plans to leave the king in the center? Where else is the compensation?

# Answer
I play the white side of this position often, and have an incredible winrate because to be honest, it feels very hard for black to develop naturally. Here's an example of how things can go wrong:

```
[FEN ""]

1. e4 c6 2. d4 d5 3. e5 Bf5 4. h4 h5 5. Bd3 Bxd3 6. Qxd3 e6 7. Bg5 Qb6 8. Nd2 c5 9. c4 Qxb2 10. Rd1 Qxd4 11. Qb3 Qxe5+ 12. Ne2 Qc7 13. cxd5 exd5 14. O-O

```

Black is able to win several pawns, but in order to "punish" white's play has to move their queen many moves in a row. While it appears black has done nothing "wrong," this position just so happens that white gets a huge initiative and is practically winning already because of the open lines against black's king and huge lead in development. Stockfish only thinks this is +0.6 or so, but as you keep playing through the variations, you'll see the evaluation rise and rise, sometimes even with best play from black. Leela loves this position for white. Here is an example game I played in this line that does not end well for the black player.

A more practical alternative for black is to try and trade the queens off instead of pawn grabbing. This is typically done with the maneuver Qa5+-\>Qa6 (or Qb6-\>Qa6) so that Qxa6 can be met with Nxa6, supporting a c5 break. Here's the beginning of a game between Nepo and Motylev, 2014 (https://lichess.org/0y7cwwGs) which black won:

```
[FEN ""]
1. e4 c6 2. d4 d5 3. e5 Bf5 4. h4 h5 5. Bd3 Bxd3 6. Qxd3 e6 7. Bg5 Qb6 8. Nd2 Qa6 9. c4 Bb4 10. b3 c5 11. Nf3 Nc6 12. dxc5 Bxc5 13. O-O Nge7 14. a3 Ng6 15. b4 Ncxe5 16. Nxe5 Nxe5 17. Qc3 Bd6

```

You can see how pinning the c4 pawn to the d3 queen means that black's center is more secure: the c5 break has the added benefit of not allowing for a later cxd5 exd5, opening up black's central king. White still had some play in the final position, but collapsed after a premature f4, which ultimately opened up the white king rather than opening up the black king. Black's play revolves around the pressure on white's center, which can sometimes collapse (and sometimes should collapse in order to expose black's king) and lead to double-edged positions that black has winning chances in.

To be honest, I think black's best line here is:

```
[FEN ""]
1. e4 c6 2. d4 d5 3. e5 Bf5 4. h4 h5 5. Bd3 Bxd3 6. Qxd3 Qa5+ 7. Nd2 (7...Qa6?! 8. e6!) e6 8. Nf3 Qa6

```

so that we get the same sort of play as in the previous game but ensure that white's bishop is stuck still on c1. Vidit won a brilliant game against Andriasian as black in this position in 2018 (https://lichess.org/QAd7qBrk).

Finally, to be complete, but at the risk of giving away some cutting edge opening theory, I think white can improve upon this opening by following a Leela recommendation:

```
[FEN ""]
1. e4 c6 2. d4 d5 3. e5 Bf5 4. h4 h5 5. Bd3 Bxd3 6. Qxd3 Qa5+ 7. b4!? (7...Qxb4+ 8. Nd2 e6 9. Rb1 Qe7 10. Ne2) Qa6 8. e6! Qxd3 9. cxd3 fxe6

```

There's a whole world of unexplored territory in this line, but play in it is unlike anything else I've ever seen, so I don't have any amazing recommendations for black except that taking the b pawn seems risky. Currently, this b4 pawn sacrifice seems to have been played only twice in 2018. Time will tell if it catches on in the future! I had a fascinating game from this position recently, where I won the opening battle but ultimately lost on time: https://lichess.org/gUqyAa1u/white. EDIT: The cat is out of the bag because on November 4, 2021, Jorden Van Foreest unleashed this line against his unsuspecting 2600 GM opponent at the FIDE Grand Swiss 2021 event. Check out how he won in \<15 moves here.

Enjoy, and good luck in the Caro!
> 27 votes

---
Tags: positional-play, caro-kann, advantage
---


title: Accidental moves in online chess

text:
# Question
Title: Accidental moves in online chess
If your opponent makes an accidental move, e.g. by slipping the mouse, and it is obvious that is was accidental, how should you continue? Should you just play the best move as if your opponent's last move was intentional? Some of my opponents have suggested that I should accept a draw in such situations. Others have asked me to make a dummy move, so that they could undo their last move by moving the piece back to the square where it was before.

# Answer
FICS has a "takeback" option; other sites may have something similar.

The link gives full details but the idea is that you type `takeback n` to request undoing n half-moves. Either player can do this so, if you make a mouse-slip, you can just type `takeback` to ask your opponent to undo that move (n=1 is assumed if you don't specify); if your opponent makes a mouseslip, you can still type `takeback` to allow them the chance to undo. In the second case, you don't have to wait for your opponent to reply while your clock ticks away: if you make your move, the takeback is modified to `takeback 2` so your opponent has the offer of undoing both his mistake and your reply to it. When offered a takeback, you can either accept or decline; making a move automatically declines. Accepting a takeback also resets the clocks to what they were at the moment when the mouse-slip was made.

On sites where this is not available, I'd recommend not making a dummy move, unless you were already in a losing position. You don't know that your opponent will behave honourably. They might exploit your generosity. I also wouldn't offer a draw unless, perhaps, a draw would have been a reasonable outcome before the mouse-slip. If your opponent was already losing, why should they gain half a point just by making a mouse-slip?
> 13 votes

# Answer
Mouse slips are a result of moving too fast.

Why should your opponent have the advantage of moving fast, without suffering the disadvantage of slipping once in a while? So in blitz I wouldn't accept any takebacks, it's just part of the game.

Of course in longer time controls you could show more leniency ...
> 12 votes

# Answer
If my opponent makes a mouse slip, I either offer a draw or continue with the best available move. It depends a bit on my mood. If I make a mouse slip, I just continue as usual and don't expect any favors in return. I can add that using a "click, click" method instead of drag and drop decreases the risk of mouse slips.
> 8 votes

# Answer
There is no 'right' answer to this. Personally, my rule is that I never give takebacks and I never ask for them. If I make a mouseslip then I'll live with it and if I come up against someone who whines or complains because I won't give a takeback then I'll add them to my no-play list.

It's probably no accident that this attitude seems to be more common the higher up the rating lists you go.
> 6 votes

# Answer
You can go either way, as many of the previous answers have suggested. If you feel like you shouldn't accept a draw (because you were winning, or because you don't feel obligated to offer a draw) that's perfectly acceptable. If you feel like offering a draw or allowing a takeback, that is your choice.

If it was a real game, there would be no takebacks because of the touch-move rule, and because you "accidentally" dropped a piece somewhere, then you would still be forced to play that move. So, them saying you should feel obligated to take the move back is unwarranted and at odds with what the rules in a real game would be.

TL;DR: Don't feel obligated to give a draw or make a dummy move because that isn't how a real game would work, but it's 100% your choice.
> 1 votes

# Answer
This is a matter of preference- there is no hard and fast rule. Generally, if it's just like a random blitz game or something, I will just play the best move and continue. If it's a long game (and my opponent tells me it's a mouseslip) for a tournament, I'm more inclined to offer a takeback/make some dummy moves.
> 1 votes

# Answer
I feel like there should NOT be a takeback because that is the opponent's problem and they need to deal with it. The pros of chess can easily recover from a mistake, and so should my opponent.
> 0 votes

# Answer
I think there should be takeback because it was not my fault the computer messsed up. I am currently outraged. Be a good sport person and offer a takeback.
> -1 votes

---
Tags: online-chess, etiquette
---


title: How did I get a checkmate in this game?

text:
# Question
Title: How did I get a checkmate in this game?
This is a position from an endgame I played that I do not understand. How did I get a checkmate in this game? Is this a glitch? I ask this because I am pretty sure that Black's queen could take my White queen.

# Answer
> 2 votes
The position shown is *not* checkmate. As you say, the queen can be captured. Even if that wasn't the case, there are two squares the king can escape to, and there's also a pawn that could move to block the check.

---
Tags: rules, endgame, checkmate
---