# Question
Title: Which kinds of openings are good against much stronger and much weaker opponents?
I had an idea: build two opening repertoires, one good against much stronger opponents, and one good against much weaker opponents.

So two questions:

* Which kinds of openings are good against much stronger opponents?
* Which kinds of openings are good against much weaker opponents?

.

* Mainlines or sidelines?
* Open or closed?
* Tactical or positional?
* Sharp or slow?
* Chaotic or quiet?
* Theory-heavy or theory-light?

When playing against much weaker opponents, an opening can be good either because it maximizes your winning probability (or more precisely the winning probability plus half of the drawing probability) or because it allows you to relax and play on autopilot without needing to focus intensely.

Against much weaker opponents, Black should probably not play the French and the Slav, because this would allow White to play the drawish Exchange variations, and a draw would be a bad result for the much stronger player (though of course still not as bad as a loss).

What about the London + Caro-Kann + Slav with ...Bf5, a system which I currently play, is this system good against stronger or weaker opponents?

I did some research on ChessBase, and the conclusion is that surprisingly a very large rating gap does not alter the usual frequencies at which openings are played. Which proves that when they face much stronger or much weaker opponents, almost no one tries to exploit the gap in strength by choosing specific openings. E.g. When White is much stronger than Black, White doesn't play 1.e4 2.Qh5 at a much higher frequency than usual.

# Answer
> 1 votes
> Which kinds of openings are good against much stronger opponents?

Openings where you know them the best and are most familiar with the plans arising from the openings.

> Which kinds of openings are good against much weaker opponents?

Openings where you know them the best and are most familiar with the plans arising from the openings.

Look, in any situation the best openings are dependent completely on the individual playing them.

If you deviate from playing the openings you know best (including the plans arising from them) then you are deliberately choosing to play openings which are inferior for you, where you will have a smaller advantage against a weaker player and bigger disadvantage against a stronger player.

Of course, if you are trying to learn a new opening then you have to go through a period where you are deliberately handicapping yourself until you get to know the opening and its plans really well, but that's the price for extending your repertoire.

# Answer
> 1 votes
My answer is going to be a bit vague, because I know nothing about your skills and knowledge. It’s basically a riff on the way Aleksander Wojtkiewicz approached playing in open tournaments.

First, you’ll want to be playing towards middlegame positions you are comfortable with playing, regardless of opponent. Which ones those are will be unique to you.

Against weaker players, choose variations that limit your risk, and rely on your own better understanding of chess to carry you to victory. By selecting less double-edged lines you both limit the likelihood you will destroy your own game with a mistake, and increase the likelihood your opponent *will* self-destruct. (After all, the simple reason they’re lower rated is because they’re more likely to blunder than you are. Wear them down and wait for the gift.)

Against stronger players, choose more enterprising lines. In a long, slow game against a higher rated player, the “blunder ratio” will be tilted against you, so you want instead a tense battle where it’s difficult to come back from a mistake. The odds you can win a grind-it-out game against a player with better technique are lower than the odds they’ll make a mistake against you in a knife-edged position, giving you an opening for a win.

These variations can coexist within the same opening, or be from completely different openings. Depends on what you like, what positions you play well.

---
Tags: opening
---


# Question
Title: Is it possible to put special pieces on a chess.com custom board?
I would really like to create custom positions with custom pieces (and maybe even variants) to play with my friends because we have always enjoyed playing custom variants. So for example a board with the camel instead of knights. Is there a way to do this on chess.com or an equivalent website?

# Answer
> 1 votes
Probably the most advanced diagram creator in the whole Internet is the Board Painter of Musketeer Chess. There are others, but none like this.

It has almost FOUR HUNDRED different fairy pieces for each colour (400 white and 400 hundred black), including not only an impressive zoological collection with every animal that could possibly be imagined, and with every strange object that might be thought of as a Fairy Chess piece, but also traditional pieces and special boards for Japanese Shogi, Chinese Xiangqi, Chinese Weiqi (also known as Go), and many other historical or regional Chess-like games for playing almost any variety of Chess ever invented.

The board can be made of any colours, not just black and white, and with an enormous number of rows and columns for those who, as it is my case, love playing in gigantic boards with legions of Chess men battling on them.

I have played Grand Triple Chess (a variety of 24 x 16 squares, totalling 384 squares) using this amazing diagramme creator. The game is now available in Evo Chess, but when it was not available, we used to play by the method of creating a diagramme for every move, converting the diagramme to an image, and sending the image to the opponent. It works perfectly well.

The Board Painter of Musketeer Chess is fairly complex, You can even mark specific squares and indicate moves with arrows and symbols of various forms and colours. Endless number of possibilities, but the Board Painter is not very easy to learn, which means that You will need an ample time for experimenting with it and learning how to use it correctly. Once You know its sophistication, You will have a truly impressive tool at Your disposal.

I know it in detail, therefore if You have questions, be kind to ask and with pleasure I shall help Your study. Because study You will need, do not expect to know how to use all of its incredible resources on the very first day.

A fine piece of on-line software, available here.

---
Tags: analysis, chess-variants, online-chess, unorthodox-pieces
---


# Question
Title: The simplest approach for king & pawn vs king & pawn endgames
I'm trying to study king & pawn endgames, where both sides have one or multiple pawns remaining. So far it seems really puzzling to me - while I know the basic principles of opposition and outflanking, I'm unable to apply them efficiently when there's more than one pawn remaining and I'm basically guessing every time.

I am trying to solve the following problem with white to move:

```
[FEN "8/p7/8/8/1K6/4k3/2P5/8 w - - 0 1"]

```

I can see no way how to do it efficiently, other than calculating move-by-move and almost certainly making a mistake on the way...

**So, is there any simpler way, how to do this?** I'm thinking about something like square-rule etc.

# Answer
> 3 votes
The first thing you need to know is the rules for K+P vs K, when is it a win, when is it a draw.

Apart from the square rule, which you already know, there are 3 rules.

**1**. For pawns on files b through g, when the pawn is behind the halfway line then the king has to be able to get to one of the 3 squares two squares in front of the pawn in order to win. Otherwise it is a draw:

```
[Title "b-g pawn behind halfway"]
[fen "8/8/3KKK2/8/4P3/8/8/8 w - - 0 1"]

```

**2**. For pawns on files b through g, when the pawn has crossed the halfway line then the king has to be able to get to one of the 3 squares one square in front of the pawn in order to win. Otherwise it is a draw:

```
[Title "b-g pawn crossed halfway"]
[fen "8/8/3KKK2/4P3/8/8/8/8 w - - 0 1"]

```

**3**. For a and h pawns the king has to get to b7 or b8 and g7 or g8 respectively in order to win. Otherwise it is a draw.

```
[Title "a and h pawns"]
[fen "1K4K1/1K4K1/8/8/P6P/8/8/8 w - - 0 1"]

```

In all of these positions, if black can stop white getting the king to one of the key squares marked then black can draw.

Looking at the position you give it is fairly straightforward to see that it is a win for white. If black didn't also have the a pawn then the plan would be to push the c pawn up the c file and the king up the b file as necessary to protect the pawn.

Since black *does* have a pawn, the one thing white has to be careful of is knowing what to do after black pushes the a pawn to a5, possibly with check and this requires a bit of calculation. (Note that if it were black to move first then this tactic would draw immediately as black can then stop white getting the king two squares ahead of the pawn.)

If this a pawn check comes after the moves 1. c4 Kd4 2. c5 then white must not capture because black would just take the c pawn. Instead white pushes the king on to b5 and although black can queen the a pawn, black queens the c pawn first and wins thanks to move Qh8+ skewering the black king on d4 against the black queen on a1.

```
[FEN "8/p7/8/8/1K6/4k3/2P5/8 w - - 0 1"]

1. c4 Kd4 2. c5 a5+ 3. Kb5 a4 (3...Kd5 4. c6 Kd6 5. Kb6 {Black can't stop the c pawn}) 4. c6 a3 5. c7 a2 6. c8=Q a1=Q 7. Qh8+

```

If black moves to e4 on the first move then white has time to capture the black pawn after a5+ and still come back to b5 to protect the pawn and shepherd it home.

```
[FEN "8/p7/8/8/1K6/4k3/2P5/8 w - - 0 1"]

1. c4 Ke4 2. c5 a5+ 3. Kxa5 Kd5 4. Kb6 {and with the pawn beyond the halway line white's king is on one of the key squares on square in front and queening is guaranteed.}

```

An excellent book which covers this and many other useful endgame ideas and principles is *Amateur to IM* by Jonathan Hawkins.

# Answer
> 3 votes
Sorry to bring the news to you: Basically no, you have to calculate until kingdome come. This doesn't say the situation is hopeless, as there are a lot of basic principles beside those you already mentioned.

I made a pawn endgame primer for my chess kiddies, and here is a compressed version for you. You can simply google the keywords for more material.

Independent (not even restricted to pawns)

* Calculate. If possible, count. (Square rule etc)
* Find key features of the position
* Make a plan
* Make candidate moves
* Calculate variants
* Break if clear (usually: if promotion happens)

Dependent on situation

* Square rule
* Zugzwang (one- and both-sided), Tempo win and Tempo loss, Triangulation
* Opposition (close, far, diagonal, general)
* Bodycheck and Outflanking
* Critical, mined and corresponding squares
* Passers (simple, protected, far, races between)
* Good (connected, side-by-side) and bad (lagging, double, isolated) pawn structures

Now to your position. It is quite hard (I'm an endgame god and I had to think :-) No wonder, it's an endgame study by the great Grigoriew, 1931. You can look into the other answer for details (typical engine warning: 2...Ke5 is just a feeble attempt to make White play 2.Kb5?? Kd5! with a two-side zugzwang. After 2.Ka5! Ke6 3.Ka6! -still no sell!- Kd5 3.Kb5 Black has only delayed the inevitable. Also now a6+ is not really the relevant line). These two moves you had to find, and they are easy to find once you see the zugzwang.

So, working down the lists:

* Key features: White has the better king position and can guide the pawn as well as stop the enemy one.
* Plan: Since Kc5/Kb5 are futile (wastes only time), plan is immediately pushing through the passer. Candidate obvious.
* Calculating only after the sneaky Ke5. Also, in the double-zugzwang position, you must calculate 4...Ke6 5.Kc6 a5 6.Kb7 a4 7.c6 a3 8.c7 a2 9.c8Q+ or 4...Ke5 (now the same moves) 9.c8Q a1Q 10.Qh8+ (Black has a bad hair day).

So the motives are:

* better king position
* double zugzwang
* mined field b5
* passer race with two typical win motives: queening with check/skewer at the end.

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


# Question
Title: What do QGA players usually play when White doesn't play exactly 1.d4 d5 2.c4?
* If Black plays the KID, then Black can play Nf6, g6, Bg7, O-O, d6 against everything.
* If Black plays the QGD, then Black can play d5, e6, Nf6, Be7, O-O against everything.
* If Black plays the Slav ...Bf5, then Black can play d5, c6, Nf6, Bf5, e6 against everything.
* If Black plays the Slav Chebanenko (Chameleon), then Black can play d5, c6, Nf6, a6 against everything.
* If Black plays the Semi-Slav, then Black can play d5, c6, Nf6, e6 against everything.

Everything other than 1.e4. Though I mean technically Black could also play the same against 1.e4. Against 1.e4, the KID is essentially the Modern-Pirc, the QGD is essentially the French, the Slav ...Bf5 is essentially the Caro-Kann.

In some order. Like if White plays 1.c4, Black won't be able to immediately play 1...d5, Black will first have to play 1...e6 (QGD) or 1...c6 (Slav) and only then 2...d5.

But if Black plays the QGA, what does Black do when White doesn't play exactly 1.d4 d5 2.c4? What does Black do when White plays 1.c4 or 1.Nf3 or 1.d4 2.Nf3? Does Black play ...d5 and then whenever White plays c4 Black immediately answers ...dxc4? Would this transpose to lines of the QGA? What if White postpones playing c4 or never plays c4? What if White plays c4 but not d4?

# Answer
> 5 votes
**It is a matter of taste**

It depends on what kind of QGA they like to play, but assuming they like the main lines, there is a bunch of standard moves Black wants to get in anyway and that they can play whether or not White has gone for d4-c4:

**...e6, ...Nf6, ...c5, ...Be7, ...0-0, ...a6**

As long as they follow that scheme, they will always be able to meet a delayed c4 with ...dc4 with reasonnable play - although each move order comes with its own subtelties, so sometimes you don't want to hurry with ...Be7 but start developing the queenside.

In particular, after **1.d4 d5 2.Nf3**, most QGA afficionadoes would go for **2...e6** or **2...Nf6**.

Note that if White never plays c4, Black's center is under much less pressure, allowing them a wider choice than in sharper lines. For instance, I have sometimes chosen the following line as White, hoping to transpose into a Catalan by playing c4 no earlier than move 6:

**1.Nf3 d5 2.g3 e6 3.Bg2 Nf6 4.0-0 Be7 5.d4**

But instead of the mundane **5...0-0 6.c4**, some of my opponents went for original play with **5...b5!?** or even **4...b5!?**

# Answer
> -1 votes
> What do QGA players usually play when White doesn't play exactly 1.d4 d5 2.c4?

It very much depends if they are a good player or a bad player. A good player adapts their opening moves according to what their opponent plays and that will obviously vary according to the moves white plays and what the black player knows and is comfortable with. A bad player plays "formula chess". That's a big part of what makes them a bad player.

> If Black plays the KID, then Black can play Nf6, g6, Bg7, O-O, d6 against everything

If black wants to lose then that is an excellent way of doing it. If black doesn't want to lose then a more intelligent approach is required.

Here is a game I played a few years ago against a player rated more than 200 points higher than me who was learning the KID. All his previous games that I could find showed him replying to 1. d4 with 1...Nc6 and so I prepared extensively for this.

When he played a weird double fianchetto KID instead I happily played the crude "150 Attack" against it (so called because it is the kind of caveman approach taken by players with old style English grades around about 150 = 1800 FIDE).

```
[Title "Towers (1793) - Prasath (2034), NCA Div 1, 2016"]
[fen ""]

1. d4 Nf6 2. Nf3 g6 3. Nc3 Bg7 4. e4 O-O 5. Bf4 b6 6. Qd2 Bb7 7. Bd3 d5 8. e5 Ne4 9. Qe3 Nxc3 10. bxc3 e6 11. Bh6 Qe7 12. h4 c5 13. Bxg7 Kxg7 14. h5 c4 15. hxg6 fxg6 16. Qh6+ Kg8 17. Bxg6 hxg6 18. Qh8+ Kf7 19. Rh7+ Ke8 20. Rxe7+ Kxe7 21. Qh7+ Rf7 22. Qxg6 Bc8 23. Ng5 Rf8 24. Ke2 Bd7 25. Rh1 Re8 26. Qf6# 1-0

```

---
Tags: opening, queens-gambit, transpositions, queens-gambit-accepted, repertoire
---


# Question
Title: Has any researcher tried adversarial examples against chess engines?
Even with all the compute in the world, chess engines cannot compute very deeply. So, they have to make use of pruning heuristics and discard moves from the analysis.

Seems possible that even the best heuristics will mistakenly discard good moves, and conversely go down bad paths that initially look good from a heuristic standpoint.

Have researchers tried to identify when this tends to happen, and if this can be taken advantage of, similar to adversarial examples in Deep Learning? E.g. an expert with deep understanding of a chess engine internals could concoct a series of moves to force the chess engine to make bad moves.

I play chess.com occasionally, and I've noticed something like this happening, where the chess engine will evaluate the same move as exceedingly good, and then as exceedingly bad.

# Answer
Yes. Antifish was an attempt in 2018 to train a LC0 style network specifically to beat stockfish. It turns out that even when searching specifically for weaknesses, chess engines are really strong.
> 5 votes

# Answer
The problem with this question is that it's not clear how an adversarial engine would work. In a comment you write:

> making moves where the payoff is beyond the chess engine's calculable horizon

But what is "calculable horizon" to you? Let's say you define it as "the engine does not find the refutation after thinking for 10 minutes on a $1000 2023 desktop". Now what if:

1. Someone lets the engine think for 20 minutes
2. Someone uses a $2000 desktop

And the engine finds the refutation - is the adversarial engine still adversarial? If yes, then the definition of "adversarial" is very arbitrary. If no, then it's not well-defined in the first place.

Accordingly, the question is too vague to answer.

PS: There are positions where the engine does not find the key move after thinking for a "very long time" (inverted commas because this term is also not well-defined, c.f. the above), but they're rare, so an engine that makes a good move in rare positions at the cost of making not-so-good moves in more common positions will lose elo in self-play.
> 1 votes

---
Tags: engines
---


# Question
Title: How good is this unnamed White opening system? d4, Nf3, e3, c4, Nc3 (in some order)
White is playing a QGD Tarrasch with colors reversed.

It's a bit like the Colle except that White plays a little bit more ambitiously, by moving his c-Pawn to c4 rather than to c3, and by developing his Queen's Knight to c3 rather than to d2. So it can't be worse than the Colle.

In the QGD and the Semi-Slav, Black will want to play ...c5. In the Semi-Slav, Black loses one tempo by playing ...c7-c6 (it loses one tempo because Black will eventually play ...c5 anyway) in order to threaten to play ...dxc4 followed by ...b5 winning the c4-pawn, in order to induce White to play 5.e3 to defend the c4-Pawn at the price of locking his queen's bishop behind the pawn chain. But here, in this White system, White locks his queen's bishop voluntarily, without Black having played ...c7-c6. So it's like a Semi-Slav where Black is one tempo up. Black will play ...c5 in one single move rather than in two.

# Answer
> 1 votes
> How good is this unnamed White opening system? d4, Nf3, e3, c4, Nc3 (in some order)

How good any set of opening moves by one side is depends entirely on what moves the opponent plays. A key part of play at higher levels is to try and trick the opponent into a transposition whereby the opponent's moves give them a bad game.

This principle can be taken even further. Often a reversed opening is entirely different in character. For instance the Dutch Defence and Bird's Opening are usually very different. Similarly when white plays the English and black replies with 1...e5 and it turns into a sort of reversed Sicilian it is usually completely different in character.

So, bottom line: just how good your sequence of moves is for white depends entirely on what black plays.

---
Tags: opening, 1.d4, queens-gambit, queens-gambit-declined, colle-system
---


# Question
Title: Most people say that the best opening for beginners to improve is 1.e4 e5. But after 2.Nf3, what should we teach beginners to play: 2...Nf6 or 2..Nc6?
The players under consideration here, the so-called "beginners", are players who are below 1100 Elo, players who do not yet know what openings to play, players who do not know anything about openings.

"Best" here means best for them to improve quickly and eventually become strong players. Only the long term improvement matters. The short term improvement is irrelevant.

# Answer
If we follow the same logic that sustends the "play 1...e5" advice, beginners should play 1...Nc6 :

* It is a simpler move to explain logically: the Pe5 is under attack, we protect it while developing. Good, sound reasonning that will be helpful even when the beginner will have to think by themselves in an unknown position.
* By leaving more choice of opening to White (Ruy Lopez, Italian, Scotch, Ponziani...) rather than imposing our scheme (Petroff), we can reach a wider variety of positions and thus develop our chess experience.
* Hopefully, slighlty less specific knowledge would be needed at once: in the Petroff, we have to know, at least, 1.e4 e5 2.Nf3 Nf6 3.Nxe5 d6! 4.Nf3 Nxe4 and how to avoid trouble on the e-file. After 2...Nc6, even without knowing anything by heart, we expect to reach a playable position with natural moves (...Bc5 or ...Be7, ...Nf6, ...0-0, ...d6, etc.). But this is more or less true given the need to look after f7 in the Italian or after e5 in the Ruy Lopez.
> 4 votes

---
Tags: opening, beginner, 1.e4, petroff-defense, open-games
---


# Question
Title: Drastic difference between perft and search + evaluation performance
I'm creating my own chess engine and noticed a significant time difference between running perft and the search + evaluation. At depth 5, perft on the initial position searches 4,865,609 nodes in about 1 second. Searching for the best move at depth 5 only searches 514,699 nodes but takes around 10 seconds.

I'm using negamax with alpha-beta pruning for searching and the simplified evaluation function for evaluation. I get that evaluating the position takes time, but I thought searching much fewer nodes would make up for it.

Is it normal to see such a large time difference between perft and searching for the best move?

Search Code:

```
const INITIAL_ALPHA: isize = (std::i32::MIN) as isize + 1;
const INITIAL_BETA: isize = (std::i32::MAX) as isize - 1;
const MATE_VALUE: isize = std::isize::MIN + 1;

pub fn best_move(&self, board: &Board, depth: usize) -> (isize, Option<Move>) {
    let moves = self.move_gen.generate_moves(board);
    let mut best_move = None;
    let mut best_score = std::isize::MIN + 1;

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = -self.negamax_alpha_beta(&new_board, INITIAL_ALPHA, INITIAL_BETA, depth);
        if score > best_score {
            best_move = Some(mv);
            best_score = score;
        }
    }

    (best_score, best_move)
}

fn negamax_alpha_beta(&self, board: &Board, mut alpha: isize, beta: isize, depth: usize) -> isize {
    if depth == 0 {
        return evaluate(board);
    }

    let moves = self.move_gen.generate_moves(board);

    if moves.len() == 0 {
        if self.move_gen.attacks_to(board, self.move_gen.king_square(board)) != 0 {
            return MATE_VALUE;
        } else {
            return 0;
        }
    }

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = -self.negamax_alpha_beta(&new_board, -beta, -alpha, depth - 1);
        if score >= beta {
            return beta;
        }
        if score > alpha {
            alpha = score;
        }
    }
    alpha
}

```

Evaluation Code:

```
pub const PAWN_VALUE: isize = 100;
pub const KNIGHT_VALUE: isize = 320;
pub const BISHOP_VALUE: isize = 330;
pub const ROOK_VALUE: isize = 500;
pub const QUEEN_VALUE: isize = 900;
pub const KING_VALUE: isize = 20000;

pub const PAWN_PIECE_SQUARE_TABLE: [isize; 64] = [
    0,  0,  0,  0,  0,  0,  0,  0,
    50, 50, 50, 50, 50, 50, 50, 50,
    10, 10, 20, 30, 30, 20, 10, 10,
     5,  5, 10, 25, 25, 10,  5,  5,
     0,  0,  0, 20, 20,  0,  0,  0,
     5, -5,-10,  0,  0,-10, -5,  5,
     5, 10, 10,-20,-20, 10, 10,  5,
     0,  0,  0,  0,  0,  0,  0,  0
];

pub const KNIGHT_PIECE_SQUARE_TABLE: [isize; 64] = [
    -50,-40,-30,-30,-30,-30,-40,-50,
    -40,-20,  0,  0,  0,  0,-20,-40,
    -30,  0, 10, 15, 15, 10,  0,-30,
    -30,  5, 15, 20, 20, 15,  5,-30,
    -30,  0, 15, 20, 20, 15,  0,-30,
    -30,  5, 10, 15, 15, 10,  5,-30,
    -40,-20,  0,  5,  5,  0,-20,-40,
    -50,-40,-30,-30,-30,-30,-40,-50,
];

pub const BISHOP_PIECE_SQUARE_TABLE: [isize; 64] = [
    -20,-10,-10,-10,-10,-10,-10,-20,
    -10,  0,  0,  0,  0,  0,  0,-10,
    -10,  0,  5, 10, 10,  5,  0,-10,
    -10,  5,  5, 10, 10,  5,  5,-10,
    -10,  0, 10, 10, 10, 10,  0,-10,
    -10, 10, 10, 10, 10, 10, 10,-10,
    -10,  5,  0,  0,  0,  0,  5,-10,
    -20,-10,-10,-10,-10,-10,-10,-20,
];

pub const ROOK_PIECE_SQUARE_TABLE: [isize; 64] = [
    0,  0,  0,  0,  0,  0,  0,  0,
    5, 10, 10, 10, 10, 10, 10,  5,
   -5,  0,  0,  0,  0,  0,  0, -5,
   -5,  0,  0,  0,  0,  0,  0, -5,
   -5,  0,  0,  0,  0,  0,  0, -5,
   -5,  0,  0,  0,  0,  0,  0, -5,
   -5,  0,  0,  0,  0,  0,  0, -5,
    0,  0,  0,  5,  5,  0,  0,  0
];

pub const QUEEN_PIECE_SQUARE_TABLE: [isize; 64] = [
    -20,-10,-10, -5, -5,-10,-10,-20,
    -10,  0,  0,  0,  0,  0,  0,-10,
    -10,  0,  5,  5,  5,  5,  0,-10,
     -5,  0,  5,  5,  5,  5,  0, -5,
      0,  0,  5,  5,  5,  5,  0, -5,
    -10,  5,  5,  5,  5,  5,  0,-10,
    -10,  0,  5,  0,  0,  0,  0,-10,
    -20,-10,-10, -5, -5,-10,-10,-20
];

pub const KING_OPENING_PIECE_SQUARE_TABLE: [isize; 64] = [
    -30,-40,-40,-50,-50,-40,-40,-30,
    -30,-40,-40,-50,-50,-40,-40,-30,
    -30,-40,-40,-50,-50,-40,-40,-30,
    -30,-40,-40,-50,-50,-40,-40,-30,
    -20,-30,-30,-40,-40,-30,-30,-20,
    -10,-20,-20,-20,-20,-20,-20,-10,
     20, 20,  0,  0,  0,  0, 20, 20,
     20, 30, 10,  0,  0, 10, 30, 20
];

pub const KING_ENDGAME_PIECE_SQUARE_TABLE: [isize; 64] = [
    -50,-40,-30,-20,-20,-30,-40,-50,
    -30,-20,-10,  0,  0,-10,-20,-30,
    -30,-10, 20, 30, 30, 20,-10,-30,
    -30,-10, 30, 40, 40, 30,-10,-30,
    -30,-10, 30, 40, 40, 30,-10,-30,
    -30,-10, 20, 30, 30, 20,-10,-30,
    -30,-30,  0,  0,  0,  0,-30,-30,
    -50,-30,-30,-30,-30,-30,-30,-50
];

pub fn is_endgame(board: &Board) -> bool {
    no_queens(board) || (has_queen_with_most_one_minor_piece(Color::White, board) && has_queen_with_most_one_minor_piece(Color::Black, board))
}

fn no_queens(board: &Board) -> bool {
    board.bb_piece(Piece::Queen).count_ones() == 0
}

fn has_queen_with_most_one_minor_piece(color: Color, board: &Board) -> bool {
    let has_queen = board.bb(color, Piece::Queen).count_ones() != 0;
    let mut result = false;

    if has_queen {
        let pieces = (board.bb(color, Piece::Knight) | board.bb(color, Piece::Bishop) | board.bb(color, Piece::Rook));
        let has_no_other_pieces = pieces.count_ones() == 0;
        let has_one_minor_piece = (pieces & !board.bb(color, Piece::Rook)).count_ones() <= 1;

        result = has_no_other_pieces || has_one_minor_piece;
    }

    !has_queen || result
}

pub fn evaluate(board: &Board) -> isize {
    eval_material(board) + eval_position(board)
}

fn eval_material(board: &Board) -> isize {
    let color = board.active_color();

    let pawn_eval = piece_difference(color, Piece::Pawn, board) * PAWN_VALUE;
    let knight_eval = piece_difference(color, Piece::Knight, board) * KNIGHT_VALUE;
    let bishop_eval = piece_difference(color, Piece::Bishop, board) * BISHOP_VALUE;
    let rook_eval = piece_difference(color, Piece::Rook, board) * ROOK_VALUE;
    let queen_eval = piece_difference(color, Piece::Queen, board) * QUEEN_VALUE;
    let king_eval = piece_difference(color, Piece::King, board) * KING_VALUE;

    pawn_eval + knight_eval + bishop_eval + rook_eval + queen_eval + king_eval
}

fn piece_difference(color: Color, piece: Piece, board: &Board) -> isize {
    board.bb(color, piece).count_ones() as isize - board.bb(!color, piece).count_ones() as isize
}

fn eval_position(board: &Board) -> isize {
    let color = board.active_color();

    let pawn_eval = eval_piece_position(color, Piece::Pawn, board) - eval_piece_position(!color, Piece::Pawn, board);
    let knight_eval = eval_piece_position(color, Piece::Knight, board) - eval_piece_position(!color, Piece::Knight, board);
    let bishop_eval = eval_piece_position(color, Piece::Bishop, board) - eval_piece_position(!color, Piece::Bishop, board);
    let rook_eval = eval_piece_position(color, Piece::Rook, board) - eval_piece_position(!color, Piece::Rook, board);
    let queen_eval = eval_piece_position(color, Piece::Queen, board) - eval_piece_position(!color, Piece::Queen, board);
    let king_eval = eval_piece_position(color, Piece::King, board) - eval_piece_position(!color, Piece::King, board);

    pawn_eval + knight_eval + bishop_eval + rook_eval + queen_eval + king_eval
}

fn eval_piece_position(color:Color, piece: Piece, board: &Board) -> isize {
    let pieces = board.bb(color, piece);

    let piece_square_table = match piece {
        Piece::Pawn => PAWN_PIECE_SQUARE_TABLE,
        Piece::Knight => KNIGHT_PIECE_SQUARE_TABLE,
        Piece::Bishop => BISHOP_PIECE_SQUARE_TABLE,
        Piece::Rook => ROOK_PIECE_SQUARE_TABLE,
        Piece::Queen => QUEEN_PIECE_SQUARE_TABLE,
        Piece::King => {
            if is_endgame(board) {
                KING_ENDGAME_PIECE_SQUARE_TABLE
            } else {
                KING_OPENING_PIECE_SQUARE_TABLE
            }
        },
    };

    let mut score = 0;
    let iter = BitboardIterator::new(pieces);
    for square in iter {
        match color {
            Color::White => score += piece_square_table[63 - square as usize],
            Color::Black => score += piece_square_table[square as usize],
        }
    }
    score
}

```

# Answer
> 0 votes
Without seeing your code, I would guess that your evaluation function is implemented inefficiently. I once wrote a search + PST engine and I got around 10 MN/s on one core.

What you want to do with PST is to update it incrementally throughout search. So rather than iterating over the entire board at each leaf node, which will take quite a while (though even that shouldn't be so slow), keep the current evaluation updated through make and unmake move operations. So in the start position the evaluation would be 0. Then if you do a search and in search make the move e2-e4 you update the score by subtracting the Pe2 PST-score and adding the Pe4 PST-score. When you end at a leaf your evaluation is already computed and you can just use it. Then, when you back up from search and unmake e2-e4 you simply subtract the Pe4 PST-score and add the Pe2 one.

---
Tags: engines, performance
---


# Question
Title: What are examples of chess positions where the best move for a human to play is a game-theoretic error?
I'm looking for positions where the game-theoretic perfect move is actually a mistake for any human to play (because it would lead to complications that they can't be expected to handle), and conversely - the most recommended move for a human who wants to maximize their odds, is one that is a game-theoretic error (e.g., turns a forced mate to a draw).

I'm thinking about something along the following lines - black is in a material disadvantage, but managed to get to a position where they have the following moves:

1. One which gives perpetual check, securing a draw.
2. One which leads to a forced mate against white; but the mating sequence is too difficult for a human to find, and any deviation would free white to exercise their advantage and win.

While the game-theoretic correct play (and the one that will likely be played by a strong AI) is 2, but any human would be advised to play 1.

It doesn't have to be this exact scenario, but the closer to it, the better. It can be either a constructed position or one from an actual game.

PS. I'm pretty sure I've seen such examples in the past, but a search didn't come up with any results...

# Answer
I'll attempt to back up my comment with a slightly constructed example: https://syzygy-tables.info/?fen=3kr3/8/8/1B6/2p1N3/2N5/8/4K3\_w\_-\_-\_0\_1

```
3kr3/8/8/1B6/2p1N3/2N5/8/4K3 w - - 0 1

```

The only winning move in this position is Bxe8, leading to the famously difficult to win NN vs P endgame. Instead, a human might simply take the pawn and then try to win with BNN vs R.

I'm sure someone else can come up with a better example (as here you could argue that a human should instead try NN vs P), but I think this kind of approach might be one way to go.
> 2 votes

# Answer
There are many such positions, mainly because engines know only to play the best moves, and sometimes the best move is equivalent to "resign". You might not find them very interesting as a result.

```
4r2Q/4kp1p/2p3pP/8/p7/PqP5/1P2RP2/1K6 b - - 19 42

```

Stockfish recommends 1...Qe6, but Black is so clearly busted after 2. Rxe6+ that he might as well resign. Granted, Black is also busted after 1...Kd6 (only move that doesn't lose the rook with check) 2. Qd4+ followed by collecting the rook, but at least White has to play 2. Qd4+. If White just grabs the rook, Black draws with 2...Qd1+ - Qb3+ perpetual.
> 1 votes

# Answer
This answer will be a bit tangential, for which I apologize.

Well known opening which leads to quite irrational positions (for both humans and engines) is anti-moscow gambit in semi-slav, which was quite topical in correspondence play until recently.

Its first branching point is reached after:

```
[fen ""]
[Startply "16"]

1.d4 d5 2.c4 c6 3.Nf3 Nf6 4.Nc3 e6 5.Bg5 h6 6.Bh4 dxc4 7.e4 g5 8.Bg3 b5

```

Where white can choose between 9. Be2, 9. h4 and 9. Ne5. White has in exchange for a pawn marveolous center and lead in development, though black has a lot of surprising defensive resources at his disposal. In all three options recently black found safe paths to equality.

As an example let me offer my game against ICCF IM Josef Kloster:

```
[fen ""]
[Startply "1"]
[Event "GER-SLO2020"]
[Site "ICCF"]
[Date "2020.02.01"]
[Round "-"]
[White "Sirk, Matija"]
[Black "Kloster, Josef"]
[Result "1/2-1/2"]
[WhiteElo "2330"]
[BlackElo "2472"]
[Board "7"]
[WhiteTeam "Slovenia"]
[BlackTeam "Germany"]

1.d4 Nf6 2.c4 e6 3.Nf3 d5 4.Nc3 c6 5.Bg5 h6 6.Bh4 dxc4 7.e4 g5 8.Bg3 b5 9.Be2 Bb7 10.h4 g4 11.Ne5 Nbd7 12.O-O Rg8 13.Nxg4 b4 14.Na4 Nxe4 15.Bxc4 h5 16.Ne3 Qf6 17.Qxh5 O-O-O 18.Rad1 Nxg3 19.fxg3 Qh6 20.Qf3 c5 21.Ba6 Bxa6 22.Qc6+ Kb8 23.Qxa6 Qxe3+ 24.Rf2 Ne5 25.Qb5+ Ka8 1/2-1/2

```

Even with assistance of engine this game was very though to play, since in positions like this you have to second-guess engine at every move - the only thing you can be sure about is that neither yourself neither engine have very good understanding of the position.

Interesting was also this game between Nakamura and Ding, where black main mistake was 16. ... Rg8:

```
[fen ""]
[Startply "1"]
[Event "Sinquefield Cup"]
[Site "Saint Louis, MO USA"]
[Date "2016.08.14"]
[EventDate "2016.08.04"]
[Round "9"]
[Result "1-0"]
[White "Hikaru Nakamura"]
[Black "Ding Liren"]
[ECO "D44"]
[WhiteElo "2791"]
[BlackElo "2755"]

1. d4 d5 2. c4 c6 3. Nf3 Nf6 4. Nc3 e6 5. Bg5 h6 6. Bh4 dxc4 7. e4 g5 8. Bg3 b5 9. Be2 Bb7 10. h4 g4 11. Ne5 Nbd7 12. Nxd7 Qxd7 13. Be5 Qe7 14. b3 cxb3 15. axb3 a6 16. Qc1 Rg8 17. O-O Nh5 18. d5 Qxh4 19. g3 Qg5 20. dxc6 Qxe5 21. cxb7 Rb8 22. Nd5 exd5 23. Qc8+ Ke7 24. Rxa6 Nxg3 25. Bxb5 Ne2+ 26. Bxe2 f6 27. Re6+ Qxe6 28. Qxb8 1-0

```

So maybe the best move for humans after all is 6. Bxf6, which leads to more rational if drawish positions.

On endgame side very hard to win for humans but rather easy for engines (as long as they are equiped with tablebases) are endgames with two knights versus pawn. Not all of them are won (see Troitsky line), but even won ones often lead to draws. Here Karjakin scored a very hard win 4 years ago:

```
[fen ""]
[Startply "1"]
[Event "Isle of Man Masters"]
[Site "Douglas IMN"]
[Date "2018.10.24"]
[EventDate "2018.10.20"]
[Round "5.10"]
[Result "1-0"]
[White "Sergey Karjakin"]
[Black "Samuel Sevian"]
[ECO "C84"]
[WhiteElo "2760"]
[BlackElo "2634"]
[PlyCount "183"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 O-O 8. a4 b4 9. a5 d6 10. d3 Be6 11. Nbd2 Qc8 12. h3 Rb8 13. Nc4 h6 14. Be3 Rd8 15. Qe2 Bf8 16. Nfd2 g6 17. Ba4 Qb7 18. Qf3 Nh7 19. Qg3 Bg7 20. f4 exf4 21. Bxf4 Nf6 22. Be3 Nd7 23. Qf2 Nc5 24. Bxc6 Qxc6 25. Bd4 Bxd4 26. Qxd4 b3 27. c3 Nd7 28. Qe3 d5 29. exd5 Bxd5 30. Qxh6 Re8 31. Ne3 Ne5 32. c4 Bxg2 33. Nxg2 Nxd3 34. Re3 Qc5 35. Kh1 Nf2+ 36. Kh2 Qd6+ 37. Kg1 Rxe3 38. Qxe3 Nxh3+ 39. Kh1 Kg7 40. Re1 Rh8 41. Qe5+ Qxe5 42. Rxe5 Ng5+ 43. Kg1 Rd8 44. Rd5 Rxd5 45. cxd5 Kf6 46. Nxb3 Ne4 47. Ne3 Ke5 48. Kg2 f5 49. Nc1 f4 50. Nc2 Kxd5 51. Nb4+ Kc4 52. Nxa6 Kb5 53. Nxc7+ Kxa5 54. Nd3 Nd2 55. Ne6 Kb5 56. Nexf4 Nc4 57. Ne6 Nxb2 58. Nxb2 g5 59. Nd4+ Kc5 60. Nf5 g4 61. Ng3 Kd4 62. Kf2 Kc3 63. Nd1+ Kd3 64. Ke1 Kc4 65. Kd2 Kd4 66. Nc3 Kc4 67. Nce2 Kd5 68. Kc3 Kc5 69. Nf4 Kc6 70. Kc4 Kd6 71. Nd3 Kc6 72. Ne5+ Kd6 73. Kd4 Ke6 74. Nc4 Kf6 75. Ne3 Ke6 76. Nef5 Kd7 77. Kd5 Kc7 78. Nd4 Kd7 79. Ne6 Ke7 80. Nc5 Kf7 81. Kd6 Kf6 82. Nce4+ Kf7 83. Kd7 Kf8 84. Nd6 Kg7 85. Ke6 Kg6 86. Nde4 Kg7 87. Ke7 Kg8 88. Kf6 Kh7 89. Nf5 Kg8 90. Ke7 g3 91. Nf6+ Kh8 92. Kf8 1-0

```

Related are endgames of king+rook versus king+bishop, which are often objectively drawn, but practically very hard for defending side due to myriad of tactical complications. So while objectively accepting draw offer in these positions is best, practically attacking side has great chances for victory - so it's humanely better to play it until 50 move rule or sweet victory.

For the last example a lot of very lost positions (K+R against K, K+Q against K+R, etc.) are played very differently by tablebases and by humans. Human player will try to trick his opponent when defending, setting stalemate traps. On the other hand tablebase will play moves that prolong the game before mate the longest, even if they are simple to counter. Try playing K+R against K against computer and against human player and I think you will find mating human player a bit harder. So optimal defence in lossing position is different for human than for machine - machine plays to prolong game against best attack, while human is trying to trap the winning side with suboptimal but tricky moves.
> 0 votes

---
Tags: engines, advantage
---


# Question
Title: Is Stockfish reliable as far as draw conclusions is concerned?
I just stumbled across this endgame : https://www.365chess.com/game.php?back=1&gid=134885&m=24

Basically, Black has only a Queen, White has Queen and Rook. Black resigns.

But here comes the tricky part:

If I put the game in a computer (here Stockfish 15), it does not find the winning ending game for White, even after a depth 70+ analysis. (I used stockfish-mac , https://github.com/daylen/stockfish-mac/wiki/User-Guide/). Black maintains perpetual check.

Though I'm not an expert of chess endgames, it does not seem to me that this position is documented as a theoretical draw. And this was an actual resignation from chess Grand Master and International Master. I suppose they knew what they were doing, even if Stockfish nor I can't find the winning position.

So basically I assume the game was losing for Black but Stockfish can't prove it.

I don't know what to do with this information.

a) Is it a Stockfish limitation? Should the program be completed by an endgame database, as seems to be hinted on the software help page (see syzygy) ?

b) But then, does this mean that without an endgame database, Stockfish 15 is faulty ? These bases are TeraBytes, which makes them pretty unusable for most people

c) One might argue that I've come across a very specific case, but is it really ? If Stockfish can't handle this basic situation, can it be trusted for other cases ? After all, many game evaluations rely ultimately on endgame evaluation.

d) By the way, the 50 move draw rule which is a 100 depth Stockfish analysis seems out-of-reach for Stockfish in reasonable time on a normal computer

e) Maybe Stockfish is right, this game was a draw, but then why did the chess masters decide it was not, and why is this not a theoretical draw documented (I couldn't find anything on google after a short search)

f) If Stockfish is right, that means that 365chess.com includes deceiving results, which is disappointing to me as I use it to check after strength of openings

Any expert insight about this would be appreciated.

Thanks

# Answer
> These bases are TeraBytes, which makes them pretty unusable for most people

I suspect you don't completely understand how these tablebases are used.

According to the Syzygy webpage, a total of 939 MB of data is required for 5-piece tablebases, 156 GB for 6-piece and 16.7 TB for 7-piece.

So, first of all, you could have a 5-piece tablebase for less than 1GB and your engine would be able to look up KQR vs KQ (5 pieces) in the tablebase and get an immediate answer. Not prohibitive at all in terms of data space required. With a decent sized SSD the 156 GB for a 6-piece tablebase is also reasonable.

However that's not the end of the story. If you have a 6-piece tablebase that will still turbocharge your engine when analysing endgames with 7 or more pieces because whenever the engine analysis reaches a position with 6 pieces it will be able to immediately look it up in the tablebase with no further calculation required.

> So basically I assume the game was losing for Black but Stockfish can't prove it.

The position you give is a draw in the tablebases so your assumption here was wrong.

> a) Is it a Stockfish limitation? Should the program be completed by an endgame database, as seems to be hinted on the software help page (see syzygy) ?

It is a limitation, yes, in the same way that an engine without an opening book is limited. In both cases the engine will take longer (and may never reach) to calculate the best moves.

> b) But then, does this mean that without an endgame database, Stockfish 15 is faulty ?

No. It just means that you will get better results from it if you use tablebases. As already pointed out, smaller 6-piece or even 5-piece tablebases will still improve performance.
> 1 votes

# Answer
Browsing through other answers here I found this website https://www.shredderchess.com/online/endgame-database.html

based on a 1TB 6-pieces endgames database, that gives the answer:

The game is a draw.

Black should not have resigned. Sorry for the noise.
> 0 votes

---
Tags: engines, endgame, stockfish, draw, computer-chess
---


title: Are there any hard mate-in-2 problems?

text:
# Question
Title: Are there any hard mate-in-2 problems?
I'm interested to know if there are any particularly challenging mate-in-2 problems. Since the second move will be essentially forced, the problem essentially comes down to 1 move. Typically, the search space is not enormous: white (assuming white to mate) does not have many pieces for the first move, and black has even fewer.

So: are there any good examples of hard mate-in-2 problems? And what are the elements of such a problem?

# Answer
As you say, what could be difficult about a mate-in-2? Or, how can make mates in 2 difficult? The answer is probably one of the most common problem devices, the Grimshaw, named after 19th century composer, Walter Grimshaw.

The basic idea is that two opposition pieces are each stopping a mate so you make a move which has to be met by one or other of the pieces moving to a square where it blocks the other piece. These subtle first moves can be very difficult to find, although the level of difficulty is in the eye of the beholder. Three times world puzzle solving champion, GM John Nunn, almost certainly doesn't find the same problems difficult that I do.

Here is a simple "Grimshaw" mate-in-2:

```
[Title "White to play and mate in 2"]
[fen "8/B2K3Q/5p2/3k4/2p2P2/p6p/r7/b7 w - - 0 1"]

```

Knowing it's a "Grimshaw" and seeing as how black only has 2 pieces that can interfere with each other makes it much easier, but without that knowledge it would be frustrating tough.

Of course, top problem solvers know all about Grimshaw which makes 2 movers easy for them.
> 1 votes

# Answer
Hard for whom indeed.

* Even the chess computer from the museum can solve a #2 in a jiffy.
* Take a GM with no experience in solving. I daresay: no particular advantage over a ELO 1800 unexperienced solver.
* On the other hand, if you are a composer yourself and know all the tricks of the trade, hardly a #2 will stump you. For solving contests, this might be turned against you (I ran into a problem where the solution was hacking away a piece, nobody of the illustre circle solved it.)

The answer to your second question (what makes up difficulty) thus strongly depends on the solver.

* In general, the more tactical chaos, the more difficult the problem.
* Long moves.
* Pin defences.

I googled "difficult twomover", the result was essentially nil. :-)
> 0 votes

---
Tags: problems, checkmate
---


# Question
Title: Why are there no strong ASIC-based chess engines?
If I'm correct (I may be not) there were no attempts to hardcode any strong chess engine directly into silicon and try to optimize it all the way to the transistor level. Is there any reason for that, other, than costs? For a long time there were many really strong CPUs (like Stockfish). Recently there were also some really strong TPU (Alpha Zero) and GPU (Leela Zero)-based engines, but as far as I'm aware up until now no one has tried to create a powerful ASIC chess engine.

I do know, that FPGAs are a bad choice for creating engines due to their low memory bandwidth as well as highly limited clock speeds.

However except for costs ASICs do look like a holy grail of chess engines. I'm not sure, why it's a bad idea (or why no one is doing that, if it isn't), however I do believe, that Stockfish rewritten from CPU code to an integrated circuit could possibly gain over 200 ELO.

Expense in the range of tens of thousands of dollars may be the reason, but Alpha Zero was significantly more expensive even than that.

# Answer
Belle was a chess computer created by Joe Condon and Ken Thompson at bell labs. Move generation and position evaluation was implemented in hardware. It was the first computer to achieve master play with a USCF rating of 2250.
> 3 votes

# Answer
> Expense in the range of tens of thousands of dollars may be the reason

The thing that you're missing is that this is a dramatic underestimate for anything that will be competitive. If you want to beat a 64 core CPU (which will be a lot cheaper) you will need some serious horsepower meaning you need a well designed chip on a relatively recent process. That's going to cost at least a few million dollars (and you will likely end up with a few thousand chips).

Making matters worse, the cost isn't really the same type as AlphaZero. Alphazero was research in machine learning and is essentially just a way to test out improvements in general algorithms for reinforcement learning. An asic by contrast will be a fully custom effort that won't be applicable to other games or more general research problems.
> 2 votes

---
Tags: engines, hardware
---


title: Yusupov, Alburt and Silman

text:
# Question
Title: Yusupov, Alburt and Silman
Yusupov's books (*Build up Your Chess* and *Boost Your Chess*) are really interesting, and I'm working with them

However, I find the chess pocket Book (by Lev Alburt) and the *How to Reassess your chess* **Workbook** (Silman) complementary

Elo 1350 FIDE

Learning from these three books is time consuming. So here are my (two) question(s) : are the Yusupov books sufficient and are the two other books (tactics and strategy) really useful ?

# Answer
> 2 votes
> are the Yusupov books sufficient?

The Yusupov books are more than just two books. The ones you quote are each a series of three books and there is a third series, *Chess Evolution*.

The three books in each series are

1. The Fundamentals
2. Beyond the Basics
3. Mastery

So, in the Build up Your Chess series you have *Build up Your Chess: The Fundamentals*, *Build up Your Chess: Beyond the Basics* and *Build up Your Chess: Mastery*.

There is an enormous amount of excellent material in these books from one of the world's best chess teachers. Just working through these books will improve your chess understanding and play.

They will definitely be sufficient to make you a better player. However, they are very unlikely to be sufficient to turn you into a GM or even an IM.

# Answer
> 1 votes
The Yusupov series is really good and enough, so that you do not have to get other books. However, if you like, you can get some collection(s) of annotated games. Nevertheless, I would recommend Alburt that you could carry with you for "casual reading" when the chess board is not with you (since Yusupov recommends working on a chessboard).

I also recommend the Soviet Chess Primer.

I would not recommend Silman's books though. You may search r/chess on Reddit for some reasons.

Edit the Dutch Steps Method is also really good.

---
Tags: books, training
---


# Question
Title: Which gambits do engines rate positively?
I often hear about "dubious" gambits - those that may be successful against mediocre opponents, but with correct preparation or against an engine are inaccurate.

Which gambits do the engines rate as either the best or almost-best move in the given situation? That is, which are the non-dubious gambits, according to engine analysis?

# Answer
I will start by some gambits which are legitimate tries for advantage (for white) or for equality (for black) - so gambits which are not dubious as in they are as good as possible.

Most common example is **Marshall attack** in Ruy lopez, which is today studied so well it's practically book draw. White players commonly today play anti-marshall lines to dodge it.

```
[fen ""]
[Startply "16"]

1. e4 e5 2. Nf3 Nc6 3. Bb5 a6 4. Ba4 Nf6 5. O-O Be7 6. Re1 b5 7. Bb3 O-O 8. c3 d5

```

In Semi-Slav complex there are two very respected gambits. First of them is **Anti-Moscow gambit**, which leads to very irrational positions:

```
[fen ""]
[Startply "14"]

1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. Nc3 c6 5. Bg5 h6 6. Bh4 dxc4 7. e4 g5

```

And **Marshall gambit**:

```
[fen ""]
[Startply "11"]
1.d4 d5 2.c4 e6 3.Nc3 c6 4.e4 dxe4 5.Nxe4 Bb4+ 6.Bd2

```

English and Benoni (due to transposition) players will be familiar with **Kasparov gambit**:

```
[fen ""]
[Startply "12"]

1. d4 Nf6 2. c4 c5 3. Nf3 cxd4 4. Nxd4 e5 5. Nb5 d5 6. cxd5 Bc5

```

In this line of Phillidor **Shirov gambit** is probably most critical. Position can also be reached through Pirc move order:

```
[fen ""]
[Startply "9"]

1. e4 e5 2. Nf3 d6 3. d4 Nd7 4. Nc3 Ngf6 5. g4

```

Lets switch to gambits which promise white "merely" equality in case of black best play - so gambits which are not dubious as in they do not lead to worse position.

Most promising of these probably is **Urosov gambit**, even though it is old enough to be considered romantic. Most lines in it promise white at least some advantage, except 4. ... Bb4+, which tends to lead to equalish endgames. Black can easily dodge it though by transposing to open variations of two knights defence.

```
[fen ""]
[Startply "9"]

1. e4 e5 2. Bc4 Nf6 3. d4 exd4 4. Nf3 Nxe4 5. Qxd4

```

**Evans gambit** also promises at least equality for white in all lines. However black has available plenty sound defences to choose from.

```
[fen ""]
[Startply "7"]

1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. b4

```

Staying in Italian complex I believe that good old **Møller attack** is still considered book draw:

```
[fen ""]
[Startply "17"]

1. e4 e5 2. Nf3 Nc6 3. Bc4 Bc5 4. c3 Nf6 5. d4 exd4 6. cxd4 Bb4+ 7. Nc3 Nxe4 8. O-O Bxc3 9. d5

```
> 3 votes

---
Tags: opening, engines, gambits
---


# Question
Title: How to come up with candidate moves or ideas in positions "with no action"?
Here is an example position:

```
[fen ""]
[Startply "40"]

1. e4 e5 2. Nf3 Nc6 3. c3 Nf6 4. d4 exd4 5. e5 Nd5 6. cxd4 Bb4+ 7. Bd2 O-O 8. a3 Ba5 9. Bc4 Nb6 10. Ba2 Bxd2+ 11. Qxd2 d5 12. h3 Bf5 13. Nc3 h6 14. O-O a6 15. Qf4 Bg6 16. Nh4 Bd3 17. Rfd1 Bh7 18. Bb1 Ne7 19. Bxh7+ Kxh7 20. Qg3 Qd7

```

White to play. I am clueless as to how to progress the game. I am trying to understand stuff without an engine, as this proved as the only way to improve for me.

I mostly care, in general, what are standard ways to progress such positions, given that there are no tactics? I want to play the least creative move - just what "makes sense" to play here. However, I have no idea what that is.

I have some ideas, but no continuations or ways to compare them.

Here is my thought process, I would appreciate some guidelines as to where I go wrong.

1. f4, starting a king side attack. Drawbacks: opens my king, f5 is protected, g4 isn't possible yet.
2. Ok, maybe unblock g5? move the queen? With tempo to d3, and then f4 g5? is it even worthwhile?
3. So my ideas are not so great. Let's maybe disrupt black's plans. ..Nc4 looks juicy. Is it? b3 kicks the knight away, and Na5 isn't scary, just move the c3 knight to defend.
4. Another idea for black: attack the center. c5 or f6. c5 dxc5 looks bad for black.
5. ..f6 seems better, but then just f4 (and not to begin with, because why commit?) if takes, white gets a protected passer and black gets a temporary file, better for white.
6. So black's ideas are also not great.
7. Why did black play Qd7? (rated ~2000 on lichess) I have no idea.
8. Just play Rac1 to improve the rook and wait? c6 seems to kill that idea.

I mainly care about the thought process, and where I could improve it, and less about the specific moves in this specific position. Positions "like this" are where I usually either go wrong or waste all of my time.

---

# Answer
For positionnal play, don't start thinking about moves, start from the position evaluation.

There are many ways to evaluate a position, one suggestion is to look sequentially at:

* material
* king security
* direct threats
* piece activity
* pawn structure

Here, going very fast, this is how I would think about the position:

Material is equal. wK is slightly safer than bK, because White has more space on the kingside and there is a possible check on the b1-h7 diagonal. No immediate threats. Queens and knights are well placed for both sides, with the Nh4 position quite peculiar: far from the center but it might be useful if f5 becomes available or if White develops an initiative against the bK. ...Nc4 jumps have to be checked. There are no open files for rooks, and only Black has a rapid way to create some with ...c5 or even ...f6, while While may hope for a rook-lift on the third rank or to support the majority on the kingside.

Indeed, the pawn structure with Pe5 vs Pc7 defines most of the future plans: White has a better center and space, and each side wants to be active on the side of their majority: ...c5 questions White's center, opens the c-file and creates an isolated passed pawn on d5, while f4-g4-f5 could lead to a mating attack, suffocation, or just a passed e-pawn in a distant endgame.

A premature f4 might be counter-productive: if White piece don't provide enough support, Black could organize a blocade with ...Nf5, ...g6, ...h5, or possibly ...f5 - although no bN can easily reach e6. To activate his position, White rather needs to move the queen out of the way (most probably to d3), use the g-pawn, and be ready to re-route the Nh4 - if chance happens, through f5; more probably via g2-e3. The wK might feel airy then the pawns rush forward, but it would still be reasonnably covered, say, on h2. The key question I would try to solve with calculation is: should I improve the rooks' placement beforehands ? Rd1 is a bit passive but at least it's protecting d4, but Ra1 is totally out of play. On the other hand, would Rac1 prove useful ? We have no target on the c-file. Isn't Rf1-Rad1 or Re1-Rad1 too slow ?

So lets' try to be more concrete: 21.Qd3 Kg8 (gotta check if 21...g6 changes much) 22.g4 brings two positionnal threats: f4-f5 and Nf5. Sounds nice, but 22...Nc4 threatens a fork on b2 and forces us to slow down with 23.Rab1, and that rook will remain passive for a while. So why not start with 21.Rac1, ensuring that any ...Nc4 will be met with Rc2 from where the rook can join the kingside later ? I see two ways for Black to use that extra tempo: 21...Rac8 planning ...c5 asap, or 21...g6 intending to cross our plans with 22.Qd3 f5 (very commiting) 23.ef6 (not taking en passant exposes us to a blocade with a bN trying to reach e6, possibly faster than anything we can engineer on the g-file) 23...Rf6 when a lot as changed : Black's castle has been weakened, the e-file is open, the Nh4 will certainly aim for the outpost on e5, g6 and f2 are soft points... Meanwhile 21.Rf1 Nc4 22.b3? Nd2 is a failure, but 22.Ra2!? followed by 23.b3 could do the job, and there seem to be no tactical issue with 21.Re1.

Well, let's stop there. My candidate moves are 21.Qd3, 21.Rc1 and 21.Re1, and the lines I would want to explore further and evaluate before choosing my move are:

* 21.Qd3 Kg8 22.g4 Nc4 23.Rab1 c5 (then maybe 24.f4, 24.Nf5, 24.Kh2, 24.Ng2)
* 21.Qd3 g6 (I will spend time checking this only if the previous line is tempting for White)
* 21.Rc1 Rc8 22.Qd3 Kg8 23.g4 c5 (then 24.f4 or 24.Nf5)
* 21.Rc1 g6 22.Qd3 f5 23.ef6 Rf6 (then 24.Nf3 or 24.Re1)
* 21.Rc1 g6 22.Qd3 f5 23.Kh2 (if the previous line is fine for Black)
* 21.Re1 planning 22.Rad1

In blitz, I might go for a rook move because I don't have a good feeling about expending on the kingside while leaving such a passive rook on a1 or b1. But in case I'm wrong that wouldn't be the first time my intuition lets me down!
> 4 votes

# Answer
In the long-run, the ideal solution is to improve your positional intuition, such that candidate moves almost come "automatically" to you. They simply seem natural. However, right now what you can do is ask three questions (paraphrased from Aagaard's book, "Grandmaster Preparation: Positional Play"):

1. What are the worst placed pieces (mainly for your side).
2. What are some weaknesses (for both sides).
3. What does my opponent want to do?

For 1), this basically comes down to which pieces are inactive, not doing much, etc. For example, in your position the a1-rook is out of play. You could argue the a2-bishop is poor too. The bishop does attack d5, put this pawn can be reinforced 'permanently' with ...Ne7-...c6. So, a goal may be to improve this rook and bishop, either by putting them in a more active location, or by exchanging them off (e.g., maybe move the knight, offer a bishop trade with Bb1). For your opponent, you could perhaps look at their pieces. For example, identify their worst placed pieces, and maybe try to keep them from being activated somehow. Or, identify which of their pieces are best-placed, and aim to push them off their posts (or trade them off).

For 2) Weaknesses can range from anything including weak squares, weak pawns, a weak king, etc. For your side, you should aim to hopefully eliminate any of your weaknesses. E.g., if you have a weak pawn, seek to exchange it off, or protect it (if you believe it requires defense). Or if you have a weak king (i.e., a king with poor shelter, such that your opponent has realistic means to attack it), aim to improve its defensive resources. E.g., if it's on an open file, consider moving it off it. Or, maybe bring more of your pieces in its vicinity. For your opponent, you should aim to capitalize on their weaknesses, and also try to prevent them from getting rid of said weaknesses. E.g., for pawn weaknesses, prevent your opponent from making these pawns non-weak, and also try to attack them if possible. Going back to the d5-pawn, I mentioned how it could be strongly reinforced with ...Ne7-...c6. So, maybe one plan might be playing b4, getting ready to play b5, which would attack a pawn on c6. If you can discourage ...c6, the d5-pawn would remain somewhat weak. You could then attack it with Nc3 (which also helps your goals of activating the a1-rook).

For 3), this is the art of prophylaxis. Ask yourself how you would play as your opponent, if it were their move and you were playing their side. Then, aim to defend against any worthy ideas that look dangerous. Going back to the ...c6 idea again, this is something I'd want to discourage as White. Also, ...f6 looks like a natural pawn break Black might try, in order to break down White's strong centre and open some lines (which would maybe improve the f8-rook). So, I'd try to prevent ...f6, or if that's not realistic, simply aim to be prepared for it. E.g., castle and put a rook on e1, so that it can capitalize on the e-file if it's opened.
> 6 votes

# Answer
There is a method you can use as a starting point: compare the following properties of your and your opponent's position (in this order):

1. **King safety**: check the fields around your king and count the influences on each of them. If you find "neutral" or "enemy"-squares (ones where opponent's influences and yours balance out or your opponent even has the upper hand) your king is in grave danger!
2. **material balance**: count the pieces (in pawn units, Q=9, R=5, B=3 but 2B=7, N=3, in endgame K~4-5)
3. **center influence**: like with king safety count, your and opponent's influences for the fields e4, e5, d4 and d5.
4. **extended center**: Do the same for the fields adjacent to the center: c4, c3, d3, e3, f3, f4, f5, f6, e6, d6, c6, c5
5. **piece mobility**: For each piece count the number of squares it *can* go to (not only squares it *should* go to! Even if it won't move there it might be valuable to be able to take something moving there.) Build pairs of pieces with your opponents pieces, like i.e.: "my one rook is better than his one rook, but his other rook is better than my other rook, so that cancels out".
6. **space**: Do you have your fair share of the board, more or even less?
7. **special**: if the position has something special, like an imminent threat, blocked pieces which can't get out, etc..

At last sum it up: advantages and disadvantages *can* (but do not necessarily) cancel each other out.

You might come up with something like: my opponent has advantage in material (he owns 1 pawn unit more), but my pieces have more mobility (I have 3 better posted/more mobile pieces). You need to do something dynamic to make use of your better mobility. This might not result in mating him, but you might eventually get your pawn back.

---

Addendum: analyzing the example position, as requested per comment:

1. King safety: whites position is unblemished, the square g7 is neutral -\> Advantage white
2. Material: equal
3. Center: white owns d4 and e5, black owns d5 and e4
4. extended center: white owns c5, black owns c4, f6 is neutral, all the other squares are in the respective players possession.
5. piece mobility: wQ:9, bQ:11, wR1:3, bR1:5, wr2:6, bR2:6, wN1:3, bN1:3, wN2:7, bN2:5
6. space: white has a small advantage (e5).

The position is about equal. White has a small space advantage and a better king position, offset by a very small advantage in mobility of the black pieces. White should reinforce his position by activating his pieces, especially the rooks (that means: maximize the number of squares they influence).

A plausible plan could be Rd-f1 (or Rd1-d2/d3, Ra1-f1), f2-f4 and attacking the black king/striving for spatial advantage).
> 0 votes

# Answer
You've got kingside pawn majority and you're up a pawn. The opponent has two weakly protected squares adjacent to the king (f7 and g7). The initiative is definitely in your hands. Launch an attack on the king by advancing your pawns and getting rooks on f and g files behind them. I would start with a Queen check from d3 and then push the f-pawn. The check is to prevent blockade on f5.
> 0 votes

# Answer
To be (very) simple :

1. What is the threat of your last opponent's move ?
2. If no threat : is there any tactic for you (mating or capturing) ?
3. If you do not find any tactic, develop and activate your pieces
4. and then : it is time to think about strategy

during each step, look at check-capture-threat (as much for your moves as for your opponent's). You'll have to choose between your two or three best candidate moves. Once you have selected your best candidate move, check that all is well by repeating the previous phases specifically for this selected move.
> -1 votes

---
Tags: positional-play, middlegame, candidate-move
---


# Question
Title: Why is Bb8 better than Bc7 in this position?
```
[fen "r2q1rk1/pp3ppp/n1pb2b1/2Pp4/3Pn3/P2B1N2/1PQ2PPP/RNB1R1K1 b - - 0 12"]
[Startply "20"]

```
1. e4 e5 2. Nf3 Nf6 3. Nxe5 d6 4. Nf3 Nxe4 5. d4 d5 6. Bd3 Bd6 7. O-O O-O 8. c4 c6 9. Re1 Bf5 10. Qc2 Na6 11. a3 Bg6 12. c5

Here black's dark-square bishop is under attack. To my surprise, both Stockfish and the database prefer Bb8 to Bc7. To me, Bc7 is a more "natural" move and Bb8 builds a prison for its teammate (rook).

Why is Bb8 better than Bc7 in this position?

# Answer
> 25 votes
> Why is Bb8 better than Bc7 in this position?

It's all about the a6 knight. It has no future on that square. It needs to relocate via either b8 or c7. c7 gives it a better circuit than b8 because it can then go directly to e6 where it would enable trying to swap off the dark squared bishop via Bf4. Black's position is a bit cramped and could benefit from swapping a minor piece or two, particularly if white goes for obvious queenside expansion starting with b4.

The b8 circuit doesn't look as good because it then goes to d7 and that's not a great square in this position and it still doesn't look to be anywhere great. Na6-b8-d7-f6 is only going to cause problems for the knight on e4.

Meanwhile it's not clear where the a8 rook belongs. An argument could be made for leaving it on a8 in the meantime from where it could later support an a pawn push. However the knight remains the main priority.

---
Tags: bishops, petroff-defense
---


# Question
Title: Will repetitive thoughts affect chess calculation and visualization?
I have an issue wherein my thoughts are on repeat. My counselor told me to pick an affirmation that I should repeat all the time. Will such repetitive thoughts affect my ability to visualize and calculate?

# Answer
> 3 votes
I think that chess calculation is one of the most difficult parts of chess training.

If my memory does not betray me, in the first book that was written about chess calculation "Think Like a Grandmaster", the former world chess campionship candidate Alexander Kotov recommended to think about every line just once.

However, it is a difficult task. Also, there are other books about the topic. What I have found useful is practicing chess calculation. The more you practice, the more that you will be better at. Following this line of thought, I play a daily "long" game on lichess.org (Long games in lichess.org are called classic). I also avoid any other of time control. It is true that the best chess players play blitz daily. However, I have noticed that avoiding blitz in combination of a daily LONG chess game has helped me to improve my chess calculation.

There are other options like solving chess puzzles daily. If you go in that direction. You need to try to solve them perfectly. You need to pick chess puzzles according your level.

Why is it important to try to solve them perfectly? The idea is that you need to put your maximum effort to improve. The same with the daily chess game.

One strategy to save time, it is to play just ONE daily game and ONE chess puzzle. Of course, you can do more, but I have noticed that it is better to try very hard, and if you play a lot of games or if you solve a lot of puzzles it is more difficult, even though not impossible.

---
Tags: psychology, calculation, visualization
---


title: QGD is 3... Be7 better than 3...Nf6

text:
# Question
Title: QGD is 3... Be7 better than 3...Nf6
`3...Be7` a.k.a the Alatortsev Variation is a possible response as black for QGD players

When I checked with the database `3...Nf6` is the most played move instead of `3...Be7`.

* When black plays Nf6 they have to worry about both `4.Bf4` and `4.Bg5` but playing `3...Be7` limits white's option on where to put the bishop.
* If white plays `4.Nf3` provoking `4...Nf6` after `3...Be7` then they cannot go with any `Nge2` plans later.

```
[FEN ""]

 1. d4 d5 2. c4 e6 3. Nc3 Be7

```
* From the above points is `3...Be7` better than `3...Nf6`?
* Why is `Nf6` the more common move when it requires black to prepare for both `Bf4` and `Bg5`?
* Are there any drawbacks for black on playing `3...Be7` that are not present with `3...Nf6`?

**EDIT** threads that discuss this

# Answer
**3...Be7 is not stronger than 3...Nf6, nor vice versa. Both moves have their up and downsides.** As you correctly stated in your question 3...Be7 works well against the popular variation 3...Nf6 4.cxd5 exd5 5.Bg5 with White planning to later play e3, Bd3, Nge2. However playing 3...Be7 has it's own downsides, most obviously the fact that the bishop is already committed to e7 and will need to lose tempi to move to b4 or d6 later in the game.

For this reason one of the most popular ways to play against 3...Be7 is 4.cxd5 exd5 5.Bf4 where White will again continue with e3 and Bd3. Here White can choose later to play with Nf3 or Nge2, in the case of Nf3 White will be able to jump into the e5 square with a strongly supported knight. The Black bishop has missed out on the opportunity to challenge the strong f4 bishop from d6 in one move, so Black may lose a tempo later.

This isn't even touching on all the subtleties involved in systems where White maintains the tension and doesn't play 4.cxd5. **I will give one example to illustrate a line where 3...Be7 isn't ideal:** 3...Nf6 4.Bf4 Black can comfortably reply with 4...c5! 5.dxc5 Bxc5 and the bishop got to develop in one move. **However in the case that 3...Be7 is played instead things are quite different:** 4.Bf4 c5? 5.cxd5! exd5 6.e4! and Black would clearly prefer to have their knight already developed to f6 in this position.
> 5 votes

# Answer
> Why is Nf6 the more common move when it requires black to prepare for both Bf4 and Bg5?

First of all, black has to prepare for Bf4 and Bg5 in the case that white plays the intermediate move Nf3. So, that is not a serious consideration.

> Are there any drawbacks for black on playing 3...Be7 that is not with 3...Nf6?

Yes. 3...Be7 tells white that black is not going to play Bb4 whereas black is almost certain to play Nf6. Playing Nf6 first delays giving white this information.
> 2 votes

---
Tags: opening, strategy, theory, queens-gambit, queens-gambit-declined
---


# Question
Title: Can someone spot the issue with my search + evaluation?
I am working on a chess engine and believe I'm using my evaluation function in Negamax and Minimax with alpha beta pruning wrong. A couple days ago, I implemented Negamax with alpha beta pruning and noticed a large performance hit compared to the other aspects of my code like move generation. I originally thought the evaluation function was the issue but now believe it is because of my search/evaluation.

I implemented Minimax with alpha beta pruning to compare the two algorithms as their results should be the same. What I found was that at an odd depth both algorithms search the same number of nodes, but they are searching more than I believe they should (e.g. depth 3 on the starting position searches 4,314 nodes, when I have seen it should be closer to 500). When the depth is even, Minimax outperforms Negamax (e.g. depth of 4 on the starting position searches 52,452 nodes in Negamax and 17,899 in Minimax), but even these seem higher than they should be as I've seen they should be closer to 1,500. Also, these algorithms are using the same evaluation function but are returning different best moves and corresponding evaluations.

More than likely I'm using the result from the evaluation function wrong, or my evaluation function is not performing the correct relative evaluation.

If it helps anyone understand my code better, the `board.clone_with_move()` function, clones the board state, applies the move to the new board, and returns the new board. Applying the move also changes the new board's active color.

Negamax Code:

```
const INITIAL_ALPHA: i32 = std::i32::MIN + 1;
const INITIAL_BETA: i32 = std::i32::MAX - 1;

pub fn best_move_negamax_ab(&self, board: &Board, depth: u8) -> (i32, Option<Move>) {
    let moves = self.move_gen.generate_moves(board);
    let mut best_move = None;
    let mut best_score = std::i32::MIN + 1;

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = -self.negamax_alpha_beta(&new_board, INITIAL_ALPHA, INITIAL_BETA, depth - 1);
        if score > best_score {
            best_move = Some(mv);
            best_score = score;
        }
    }

    (best_score, best_move)
}

fn negamax_alpha_beta(&self, board: &Board, alpha: i32, beta: i32, depth: u8) -> i32 {
    if depth == 0 {
        return evaluate(board) as i32;
    }

    let moves = self.move_gen.generate_moves(board);
    let mut alpha = alpha;

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = -self.negamax_alpha_beta(&new_board, -beta, -alpha, depth - 1);
        if score >= beta {
            return beta;
        }
        if score > alpha {
            alpha = score;
        }
    }
    return alpha;
}

```

Minimax Code:

```
const INITIAL_ALPHA: i32 = std::i32::MIN + 1;
const INITIAL_BETA: i32 = std::i32::MAX - 1;

pub fn best_move_minimax_ab(&self, board: &Board, depth: u8) -> (i32, Option<Move>) {
    let moves = self.move_gen.generate_moves(board);
    let mut best_move = None;
    let mut best_score = std::i32::MIN + 1;

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = self.alpha_beta_max(&new_board, INITIAL_ALPHA, INITIAL_BETA, depth - 1);
        if score > best_score {
            best_move = Some(mv);
            best_score = score;
        }
    }

    (best_score, best_move)
}

fn alpha_beta_max(&self, board: &Board, alpha: i32, beta: i32, depth: u8) -> i32 {
    if depth == 0 {
        return evaluate(board) as i32;
    }
    let moves = self.move_gen.generate_moves(board);
    let mut alpha = alpha;

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = self.alpha_beta_min(&new_board, alpha, beta, depth-1);
        if score >= beta {
            return beta;
        }
        if score > alpha {
            alpha = score;
        }
    }
    return alpha;

}
fn alpha_beta_min(&self, board: &Board, alpha: i32, beta: i32, depth: u8) -> i32 {
    if depth == 0 {
        return evaluate(board) as i32;
    }
    let moves = self.move_gen.generate_moves(board);
    let mut beta = beta;

    for mv in moves {
        let new_board = board.clone_with_move(&mv);
        let score = self.alpha_beta_max(&new_board, alpha, beta, depth - 1);
        if score <= alpha {
            return alpha;
        }
        if score < beta {
            beta = score;
        }
    }
    return beta;
}

```

Evaluation function code:

```
use crate::board::Board;
use crate::pieces::{Piece, Color};
use crate::bitboard::BitboardIterator;

pub static PAWN_PIECE_SQUARE_TABLE: [i16; 64] = [
    100, 100, 100, 100, 100, 100, 100, 100,
    150, 150, 150, 150, 150, 150, 150, 150,
    110, 110, 120, 130, 130, 120, 110, 110,
    105, 105, 110, 125, 125, 110, 105, 105,
    100, 100, 100, 120, 120, 100, 100, 100,
    105,  95,  90, 100, 100,  90,  95, 105,
    105, 110, 110,  80,  80, 110, 110, 105,
    100, 100, 100, 100, 100, 100, 100, 100,
];

pub static KNIGHT_PIECE_SQUARE_TABLE: [i16; 64] = [
    270, 280, 290, 290, 290, 290, 280, 270,
    280, 300, 320, 320, 320, 320, 300, 280,
    290, 320, 330, 335, 335, 330, 320, 290,
    290, 325, 335, 340, 340, 335, 325, 290,
    290, 320, 335, 340, 340, 335, 320, 290,
    290, 325, 330, 335, 335, 330, 325, 290,
    280, 300, 320, 325, 325, 320, 300, 280,
    270, 280, 290, 290, 290, 290, 280, 270,
];

pub static BISHOP_PIECE_SQUARE_TABLE: [i16; 64] = [
    310, 320, 320, 320, 320, 320, 320, 310,
    320, 330, 330, 330, 330, 330, 330, 320,
    320, 330, 335, 340, 340, 335, 330, 320,
    320, 335, 335, 340, 340, 335, 335, 320,
    320, 330, 340, 340, 340, 340, 330, 320,
    320, 340, 340, 340, 340, 340, 340, 320,
    320, 335, 330, 330, 330, 330, 335, 320,
    310, 320, 320, 320, 320, 320, 320, 310,
];

pub static ROOK_PIECE_SQUARE_TABLE: [i16; 64] = [
    500, 500, 500, 500, 500, 500, 500, 500,
    505, 510, 510, 510, 510, 510, 510, 505,
    495, 500, 500, 500, 500, 500, 500, 495,
    495, 500, 500, 500, 500, 500, 500, 495,
    495, 500, 500, 500, 500, 500, 500, 495,
    495, 500, 500, 500, 500, 500, 500, 495,
    495, 500, 500, 500, 500, 500, 500, 495,
    500, 500, 500, 505, 505, 500, 500, 500,
];

pub static QUEEN_PIECE_SQUARE_TABLE: [i16; 64] = [
    880, 890, 890, 895, 895, 890, 890, 880,
    890, 900, 900, 900, 900, 900, 900, 890,
    890, 900, 905, 905, 905, 905, 900, 890,
    895, 900, 905, 905, 905, 905, 900, 895,
    900, 900, 905, 905, 905, 905, 900, 895,
    890, 905, 905, 905, 905, 905, 900, 890,
    890, 900, 905, 900, 900, 900, 900, 890,
    880, 890, 890, 895, 895, 890, 890, 880,
];

pub static KING_OPENING_PIECE_SQUARE_TABLE: [i16; 64] = [
    19970, 19960, 19960, 19950, 19950, 19960, 19960, 19970,
    19970, 19960, 19960, 19950, 19950, 19960, 19960, 19970,
    19970, 19960, 19960, 19950, 19950, 19960, 19960, 19970,
    19970, 19960, 19960, 19950, 19950, 19960, 19960, 19970,
    19980, 19970, 19970, 19960, 19960, 19970, 19970, 19980,
    19990, 19980, 19980, 19980, 19980, 19980, 19980, 19990,
    20020, 20020, 20000, 20000, 20000, 20000, 20020, 20020,
    20020, 20030, 20010, 20000, 20000, 20010, 20030, 20020,
];

pub static KING_ENDGAME_PIECE_SQUARE_TABLE: [i16; 64] = [
    19950, 19960, 19970, 19980, 19980, 19970, 19960, 19950,
    19970, 19980, 19990, 20000, 20000, 19990, 19980, 19970,
    19970, 19990, 20020, 20030, 20030, 20020, 19990, 19970,
    19970, 19990, 20030, 20040, 20040, 20030, 19990, 19970,
    19970, 19990, 20030, 20040, 20040, 20030, 19990, 19970,
    19970, 19990, 20020, 20030, 20030, 20020, 19990, 19970,
    19970, 19970, 20000, 20000, 20000, 20000, 19970, 19970,
    19950, 19970, 19970, 19970, 19970, 19970, 19970, 19950,
];

pub fn is_endgame(board: &Board) -> bool {
    no_queens(board) || (has_queen_with_most_one_minor_piece(Color::White, board) && has_queen_with_most_one_minor_piece(Color::Black, board))
}

fn no_queens(board: &Board) -> bool {
    board.bb_piece(Piece::Queen) == 0
}

fn has_queen_with_most_one_minor_piece(color: Color, board: &Board) -> bool {
    let has_queen = board.bb(color, Piece::Queen) != 0;

    if has_queen {
        let pieces = board.bb(color, Piece::Knight) | board.bb(color, Piece::Bishop) | board.bb(color, Piece::Rook);
        let has_no_other_pieces = pieces == 0;
        let has_one_minor_piece = (pieces & !board.bb(color, Piece::Rook)).count_ones() <= 1;

        return has_no_other_pieces || has_one_minor_piece;
    }
    true
}

pub fn evaluate(board: &Board) -> i16 {
    let color = board.active_color();

    let pawn_eval = eval_piece_position(color, Piece::Pawn, &PAWN_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::Pawn, &PAWN_PIECE_SQUARE_TABLE, board);
    let knight_eval = eval_piece_position(color, Piece::Knight, &KNIGHT_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::Knight, &KNIGHT_PIECE_SQUARE_TABLE, board);
    let bishop_eval = eval_piece_position(color, Piece::Bishop, &BISHOP_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::Bishop, &BISHOP_PIECE_SQUARE_TABLE, board);
    let rook_eval = eval_piece_position(color, Piece::Rook, &ROOK_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::Rook, &ROOK_PIECE_SQUARE_TABLE, board);
    let queen_eval = eval_piece_position(color, Piece::Queen, &QUEEN_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::Queen, &QUEEN_PIECE_SQUARE_TABLE, board);

    let king_eval = if is_endgame(board) {
        eval_piece_position(color, Piece::King, &KING_ENDGAME_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::King, &KING_ENDGAME_PIECE_SQUARE_TABLE, board)
    } else {
        eval_piece_position(color, Piece::King, &KING_OPENING_PIECE_SQUARE_TABLE, board) - eval_piece_position(!color, Piece::King, &KING_OPENING_PIECE_SQUARE_TABLE, board)
    };

    pawn_eval + knight_eval + bishop_eval + rook_eval + queen_eval + king_eval
}

fn eval_piece_position(color:Color, piece: Piece, piece_square_table: &[i16; 64], board: &Board) -> i16 {
    let pieces = board.bb(color, piece);

    let mut score = 0;
    let iter = BitboardIterator::new(pieces);
    for square in iter {
        match color {
            Color::White => {
                let index = (7 - square / 8) * 8 + square % 8;
                score += piece_square_table[index as usize];
            }
            Color::Black => {
                score += piece_square_table[square as usize];
            }
        }
    }
    score
}

```

# Answer
> 1 votes
The primary issue you have is with the evaluation function. For a standard minimax implementation, it is supposed to be implemented such that the result is an absolute evaluation. I.e. a positive score means the position favors white, and negative meaning the position favors black. However, this is not the case for Negamax. When implementing the Negamax algorithm, the evaluation must return a score relative to the side to move (i.e. if it is Black-to-Move, a positive score indicates that the position favors black). This would explain why the results have an odd-even effect. The evaluation function is wrong for either Minimax or Negamax when it is Black-To-Move during the evaluate call, but it is correct when it is White-To-Move during the evalutate call.

It looks like the evaluation is wrong for Minimax. Does the returned best move make sense when you run the search, or does it seem to be unstable?

Another issue that might not be problematic, is that your initial Alpha and Beta values are not quite right. Since Max Int32 is 2,147,483,647 and Min Int32 is -2,147,483,648, your intial alpha and beta values are not the negative versions of each other, so the values do not stay constant as they go down the recursive Negamax calls. I'm not sure if this is actually going to cause problems, but I think you should set INITIAL\_BETA = -INITIAL\_ALPHA at the top.

---
Tags: engines, minimax
---


title: Nonstandard game results

text:
# Question
Title: Nonstandard game results
Any standard chess game will end in 1:0,0:1,or 1/2:1/2. Can you give some games where *very* nonstandard results occurred (word of mouth is OK, but solid evidence is better)?

* By §E10.2, any individual result can only be from the set of regular results 0,1,1/2.
* A 0:0 is a "standard nonstandard" result (for example, both players didn't show up) and thus not interesting here.
* A 1/2:1 or 1:1 is very wacky (while not directly ruled out) and I doubt we ever see one.
* This practically leaves only a 1/2:0, which is possible by §E10.2 (and §E12.9). Do you have an actual example?

# Answer
> A 1/2:1 or 1:1 is very wacky (while not directly ruled out) and I doubt we ever see one.

1:1 has occurred, apparently, in English chess.

Check out the obituary for Steve Boniface on the Chess Arbiters Association site.

> One year at Paignton, one of his favourite events, Steve had the evening off while the other controllers organised a blitz tournament at the playing hall. On his way back from the pub (almost certainly one that was in the CAMRA Good pub Guide) he could not resist dropping in at the hall to see how things were going. One of the controllers came running up: "We're glad you're here, Steve. There's been a dispute - could you sort it?" A boy of about ten was playing a man in his late seventies and the boy was winning easily. He got a pawn to the eighth rank and announced a queen, but not finding a queen to hand he left the pawn in situ. When on his next move he attempted to move his pawn as a queen the man claimed a win for an illegal move (they were playing the blitz rule that illegal moves lose). Steve knew the final round was being delayed and the man was adamant that he must have the win; the small boy was looking very confused. Having checked that the result would not make any difference to any prize money, Steve came up with a quick and unique solution. He took the man off to one side and informed him that he had won the game. He then did exactly the same thing with the young lad. One point each: truly a modern judgment of Solomon!

The obituary also appears on the site for the Bristol League where he played most of his chess. According to this report from the Guernsey chess festival he also had an inventive approach to pairing.

I'm not sure his arbiting decisions would meet with approval today.

1/2:1 occurs regularly although you don't see it because the pairings are changed. It happens often in the first round of a tournament like this.

* Player A requested a half point bye in the first round.
* By mistake the arbiter pairs A with B
* B sits there for half an hour until the default time expires and claims their full point
* Either the arbiter realises a mistake was made or the next day player A points out their bye request and the pairings are changed retrospectively to show player A getting a half point bye and player B getting a full point bye. If this happens to several players then you have several players appearing to get full point byes in the same round. Clearly not possible according to the rules but less embarrassing than declaring to the world that the result was 1/2:1.

> This practically leaves only a 1/2:0, which is possible by §E10.2 (and §E12.9). Do you have an actual example?

This could happen where player B is disqualified for some heinous crime but opponent, player A, cannot mate by any series of legal moves. Player B definitely gets 0 but player A cannot be given 1 and so is given 1/2.
> 27 votes

---
Tags: rules, scoring
---


# Question
Title: Time control for casual clock simul at home
I have hosted a simul at our house last Sunday against 5 players who were friends and acquaintances of mine. It was fun, but it took a bit too long, because I allowed everyone to use as much time as they wanted, plus, the players' wives and girlfriends were sitting around, chatting with some of the players and after the event we had pizza etc.

We started around 2h30 pm and it ended at 7h30. Therefore, I decided that next time I will use clocks, I already looked online for suggestions and found out that, even an International Master with a rating of 2500 for example has 10 min more on the clock than the participants. So, if I play against two players of similar strength (1500) and three others who are around 1000 - 1100 - 1200, I feel I should adjust my extra time to their strength as well.

What are the normal guidelines for using clocks in simuls?

# Answer
> 4 votes
The normal way of running a simul is that the players only play their move when you come to the board. They then make their move. You then make your move and move on to the next board.

If it is a serious simul with many players then the strict rule is no passing. If the player does not make a move when you arrive at the board then they lose. For a more friendly simul like yours a rule like "3 passes are allowed" would be more normal. That means the player can instead of moving say "I pass" and you move on. They can only do this a total of 3 times.

If you are really going to use clocks, do you have 5 clocks? Kasparov in his prime used to give simuls against very strong players with clocks. More information here.

I think the approach Kasparov used was 2 hours for all the moves for all the players including Kasparov. Players could move when they wanted and Kasparov likewise could make a move on any board any time it was his turn on that board.

If you feel you really want to use clocks then I would suggest something similar although with maybe less time, say 90 minutes.

---
Tags: rules, chess-clocks, simultaneous
---


# Question
Title: London system plan against Qxb6 when white has time to go a3 and Rc1 getting out of pin
In the London system where white doesn't develop the `b1` knight early the `Qxb6` followed by `a3` is considered a mistake due to the following sequence

```
[FEN ""]

 1. d4 d5 2. Bf4 Nf6 3. e3 c5 4. c3 Nc6 5. Nf3 Qb6 6. Qb3 c4 7. Qxb6 axb6 8. a3 b5 {[%draw arrow,b5,b4,red][%draw arrow,a8,a1,green]}

```

Black manages to play `b4` and undouble the b pawns + creating weakness on white's queenside mainly because of the pin on the a file.

Now if we consider the sequence where white moves the `b1` knight early.

```
[FEN ""]

 1. d4 d5 2. Bf4 Nf6 3. e3 c5 4. c3 Nc6 5. Nd2 Qb6 6. Qb3 c4 7. Qxb6 axb6 8. a3 b5 9. Rc1 {[%draw arrow,a3,b4,green][%draw arrow,c3,b4,green]}

```

Qxb6 is not considered the best move here as well. `Qc2` is the better move because now black cant win a tempo with `Bf5`.
But...
after `Qxb6` white manages to unpin the rook and `b4` doesn't seem like an option anymore due to the `a3`,`c3` pawns. On the other hand white can try his typical `e4` breaks.

**What is a plan for black in this situation since `b4` break isn't feasible anymore.**

# Answer
> 2 votes
You are absolutely right: 5.Nd2 instead of 5.Nf3 makes a huge difference here.

The position after 9 moves is much more pleasant for White exactly for the reason you are pointing out: Black lacks counterplay on the queenside and has no constructive plan. The best they can do is to develop solidly, not blunder anything, and get ready for the inevitable e3-e4 that White will soon push. I would suggest **...Bf5, ...e6, ...h6, ...Be7, ...O-O, ...Bh7.** Never take on e4 if White can take back with the f-pawn, or even with piece. Be patient and don't try desperate attempts like ...f6 and ...e5 that would only help White to open the center.

What about the Nf6 ?

* ...Nh5 to exchange the strong dark-squared bishop would be very helpful, but that will not happen: if c7 is not available, then White can simply anticipate with h3.
* ...Ne4 exchanging one knight (after ...Bf5 and before f2-f3, if allowed) is a passive but solid plan. White will gain some elbow room to engineer e3-e4 faster, but after that's done holding passively against White's space advantage will be easier with one less piece.
* my favorite, if we are given enough time, is ...Nd7 followed by ...Nb6 and ...Na4, pointing to the only weakness in White camp, the b2 pawn. If we are allowed this, White's manoeuvers will be hampered by the need to look after ...Nxb2 but also after piece sacs like ...Bxa3 or ...Nxc3 creating great passers.

However, my best advice for Black is to refrain from 6...c4?! if the wN is already on d2, and possibly to avoid 5...Qb6 altogether.

---
Tags: opening, strategy, theory, middlegame, london-system
---


# Question
Title: Is bughouse a win for a team with excess time?
In bughouse it is a huge advantage during the game to have more time on your clocks than your opponents.
So I wonder what happens if one team starts with a time advantage (from now on called the time lords).
Say, the time lords have 10 mins, while their opponents have only 5 mins.
This way the time lords can move on either board, and their opponents must always move on the same board.

> Does this guarantee a win for the time lords, assuming perfect play?

This is an entirely theoretical question! No musings on weaknesses and skills, please.
For example, assuming that chess is a win for white (or for black), the answer to my question is yes, as the time lords can enforce the whole game to be played on one board, they can sit on the other.
But I expect some simpler argument that doesn't use any unproven hypothesis.
Maybe the time lords can even win in a dozen moves or so, no matter what the other team does.

ps. Note that this also gives an asymmetric way to play bughouse without a clock.

# Answer
If both your clocks are ticking down you lose regardless of how much time advantage you have. So, if the "timelords" refuse to move on both of their boards this is how they will lose.

A team can only afford to let *one* of the two clocks tick down to have any chance to win.

If the timelords refuse to move on one game they need to move on the other and their opponents have to make them use more time than the difference between their (total) time and opponents time. Your example of 10min vs. 5min is not ideal to show this mechanism. Instead, let the time be:

> Timelords: 8min
> Opponents: 5min

Now, the clocks are started and the timelords don't play on one board. On the other board the opponent has to make the timelord think for 3min+ more than he himself has thought to win the game. Once the timelord has less than his opponents time + 3min on his clock the opponent could also refuse to play and the timelord will lose on time first.

Start (first board TLs refuse to play):

> Timelords: 8min / 8min
> Opponents: 5min / 5min

After, say, 4 minutes of play:

> Timelords: 4:00 / 5:00 (-3min)
> Opponents: 5:00 / 4:00 (-1min)

Once the opponent can make the timelord use more time than himself he can let the time run out.
> -1 votes

---
Tags: chess-variants, winning, bughouse
---