How much is castling worth?

Discussion of chess software programming and technical issues.

Moderator: Ras

Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

How much is castling worth?

Post by Mike Sherwin »

I've seen where it can be worth a lot or very little or even be worse even though it is not apparent by just looking at the position. How do strong engines evaluate castling?
User avatar
xr_a_y
Posts: 1872
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: How much is castling worth?

Post by xr_a_y »

Minic evaluate
- rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 at depth 23 to +46
- rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1 at depth 23 to +73

surely not enough ...
mhouppin
Posts: 116
Joined: Wed Feb 12, 2020 5:00 pm
Full name: Morgan Houppin

Re: How much is castling worth?

Post by mhouppin »

Stash 33.9 evaluation:

- With castling for Black

Code: Select all

+0.30, depth 27/35, 91.1M nodes
-> 1. d4 d5 2. c4 c6 3. cxd5 cxd5 4. Bf4 Bf5 5. e3 Nc6
6. Qb3 Qd7 7. Nf3 a6 8. Be2 e6 9. O-O Nf6 10. Rc1 Rc8
11. Nbd2 Be7 12. Ne5 Nxe5 13. Rxc8+ Qxc8 14. Bxe5 O-O
- Without castling for Black

Code: Select all

+0.98, depth 26/35, 112M nodes
-> 1. d4 d5 2. c4 e6 3. cxd5 exd5 4. Nc3 Nf6 5. Bf4 c6
6. e3 Bf5 7. a3 Bd6 8. Nge2 Kd7 9. Ng3 Bxf4 10. Nxf5 g6
11. exf4 gxf5 12. Bd3 Re8+ 13. Kf1 Kc7 14. Bxf5 Nbd7
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: How much is castling worth?

Post by Mike Sherwin »

xr_a_y wrote: Sun Aug 14, 2022 9:44 pm Minic evaluate
- rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 at depth 23 to +46
- rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1 at depth 23 to +73

surely not enough ...
I agree that 27 centi-pawns does not seem like enough.
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: How much is castling worth?

Post by Mike Sherwin »

mhouppin wrote: Sun Aug 14, 2022 9:55 pm Stash 33.9 evaluation:

- With castling for Black

Code: Select all

+0.30, depth 27/35, 91.1M nodes
-> 1. d4 d5 2. c4 c6 3. cxd5 cxd5 4. Bf4 Bf5 5. e3 Nc6
6. Qb3 Qd7 7. Nf3 a6 8. Be2 e6 9. O-O Nf6 10. Rc1 Rc8
11. Nbd2 Be7 12. Ne5 Nxe5 13. Rxc8+ Qxc8 14. Bxe5 O-O
- Without castling for Black

Code: Select all

+0.98, depth 26/35, 112M nodes
-> 1. d4 d5 2. c4 e6 3. cxd5 exd5 4. Nc3 Nf6 5. Bf4 c6
6. e3 Bf5 7. a3 Bd6 8. Nge2 Kd7 9. Ng3 Bxf4 10. Nxf5 g6
11. exf4 gxf5 12. Bd3 Re8+ 13. Kf1 Kc7 14. Bxf5 Nbd7
Seems reasonable. I wonder what Carlsen would say if black started off with out castling rights?
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How much is castling worth?

Post by hgm »

Evaluating opening positions with engines is pretty much useless. If it tells you anything, it is about the engine, not about the position. The only way to get info on the position is to play games from it with sufficient randomization, and observe the statistics of the outcome.
User avatar
xr_a_y
Posts: 1872
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: How much is castling worth?

Post by xr_a_y »

I used a a small random addition to evaluation in the first few moves to generate randomness and played 100 games.

Starting from "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1" we have :

Code: Select all

White vs Black: 48 - 7 - 46  [0.703] 101    (so a 70% win rate for white)
While starting with castling rights this is :

Code: Select all

 White vs Black: 18 - 13 - 69  [0.525] 100    (so a 52% win rate for white)
Sounds better to me.
User avatar
hgm
Posts: 28353
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: How much is castling worth?

Post by hgm »

That is nearly the same as the score you get from Pawn odds, right?

That would imply castling is worth about 100cP.
User avatar
xr_a_y
Posts: 1872
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: How much is castling worth?

Post by xr_a_y »

hgm wrote: Mon Aug 15, 2022 9:18 am That is nearly the same as the score you get from Pawn odds, right?

That would imply castling is worth about 100cP.
NNUE is aware of material (not of castling right for now), so score is already +400 from the beginning if f7 pawn is missing.

Anyway 100 games result is (missing f7 pawn)

Code: Select all

White vs Black: 82 - 12 - 10  [0.837] 104    (so 83% win rate for white)
But i see some strange games with very early queen sac by white, i'll have to check.
User avatar
xr_a_y
Posts: 1872
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: How much is castling worth?

Post by xr_a_y »

Yeah, something was buggy, very sorry @hgm :oops: , previous results are crap.

Here the good ones :

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
White vs Black: 93 - 50 - 457 [0.536] 600 => 53% white win rate

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQ - 0 1
White vs Black: 49 - 3 - 48 [0.730] 100 => 73% white win rate

rnbqkbnr/ppppp1pp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
White vs Black: 78 - 3 - 19 [0.875] 100 => 87% white win rate

Looks like castling rights is a bit less than f7 pawn odd.