How much elo is a good king safety function worth?

Discussion of chess software programming and technical issues.

Moderator: Ras

Whiskers
Posts: 243
Joined: Tue Jan 31, 2023 4:34 pm
Full name: Adam Kulju

How much elo is a good king safety function worth?

Post by Whiskers »

I'm implementing king safety into my engine Willow and am wondering how much ELO gain is feasible to get out of it. Currently I have a basic king safety function (attack tables for the middlegame, the results of which are scaled by how many defending pawns are near the king) and have gotten ~50-60 elo from it in self play which is a good start.

If you have a good king safety implementation in your engine (or even if you don't :wink:), how much of an improvement is it?
User avatar
algerbrex
Posts: 608
Joined: Sun May 30, 2021 5:03 am
Location: United States
Full name: Christian Dean

Re: How much elo is a good king safety function worth?

Post by algerbrex »

~46 Elo apparently, though I didn't remember.

Note, however, I don't consider my king safety function good. It's pretty basic and only takes into account attacks around the king. I don't have a concrete engine to cite, but I suspect a good king safety - one takes into account a variety of factors like king attacks, pawn structure, checking moves, etc. - is worth 100 Elo or more.
User avatar
emadsen
Posts: 440
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: How much elo is a good king safety function worth?

Post by emadsen »

I got 63 Elo. But the benefit to your engine may be more or less depending on what other features it has or lacks. Search and evaluation features interact in non-linear ways.
Erik Madsen | My C# chess engine: https://www.madchess.net
jdart
Posts: 4398
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: How much elo is a good king safety function worth?

Post by jdart »

#1 thing to focus on in my opinion is having a bug-free implementation of search and eval.
Many weak engines are weak because they are buggy.
That said, king safety is very important. It doesn't matter as much if you are playing weak opponents,
but if you play an engine that has good king safety eval and yours is weak, you will be smashed.
jhonnold
Posts: 122
Joined: Wed Feb 17, 2021 3:16 pm
Full name: Jay Honnold

Re: How much elo is a good king safety function worth?

Post by jhonnold »

chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: How much elo is a good king safety function worth?

Post by chrisw »

Whiskers wrote: Thu Feb 02, 2023 9:59 pm I'm implementing king safety into my engine Willow and am wondering how much ELO gain is feasible to get out of it. Currently I have a basic king safety function (attack tables for the middlegame, the results of which are scaled by how many defending pawns are near the king) and have gotten ~50-60 elo from it in self play which is a good start.

If you have a good king safety implementation in your engine (or even if you don't :wink:), how much of an improvement is it?
Absolutely no where near as much as if you used a simplest of simple tiny NNUEs instead. +300 Elo minimum.

HCE king safety. Compared to none at all +200. Compared to what you’ve already done, maybe 50-100.
Whiskers
Posts: 243
Joined: Tue Jan 31, 2023 4:34 pm
Full name: Adam Kulju

Re: How much elo is a good king safety function worth?

Post by Whiskers »

chrisw wrote: Sat Feb 11, 2023 5:48 pm
Whiskers wrote: Thu Feb 02, 2023 9:59 pm I'm implementing king safety into my engine Willow and am wondering how much ELO gain is feasible to get out of it. Currently I have a basic king safety function (attack tables for the middlegame, the results of which are scaled by how many defending pawns are near the king) and have gotten ~50-60 elo from it in self play which is a good start.

If you have a good king safety implementation in your engine (or even if you don't :wink:), how much of an improvement is it?
Absolutely no where near as much as if you used a simplest of simple tiny NNUEs instead. +300 Elo minimum.

HCE king safety. Compared to none at all +200. Compared to what you’ve already done, maybe 50-100.
Right now I definitely do not have the programming knowledge to train my own NNUE net, and using an already trained one like SFs feels like cheating. Maybe eventually I'll get good enough at coding :P