Penalizing early queen development

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
niel5946
Posts: 82
Joined: Thu Nov 26, 2020 9:06 am
Full name: Niels Abildskov

Penalizing early queen development

Post by niel5946 » Wed Feb 17, 2021 10:35 pm

Hi.

I am in the middle of improving my evaluation function from one which just considered material and piece-square tables. I have just finished writing the evaluation code for all pieces other than the queen. I plan on evaluating the queen on two things: 1) Penalizing it, if it is attacked. And 2) Penalizing it for being developed early.

But my problem is that i can't find a way that seems optimal for nr. 2. I have considered making a developed_queen coefficient and then, if the queen isn't on it's starting square, give the penalty: developed_queen / moves_played. This just seems like it is firstly, too simple, and secondly, that it wouldn't work if I loaded an FEN from an opening position (where the amount of moves played would be unknown).

What do you think is the best way of de-incentivizing the engine from developing it's queen early on in the game?

Any help is much appreciated! :D
Author of Loki, a C++ work in progress.
Code | Releases | Progress Log |

Sesse
Posts: 284
Joined: Mon Apr 30, 2018 9:51 pm
Contact:

Re: Penalizing early queen development

Post by Sesse » Wed Feb 17, 2021 11:04 pm

Most engines have two different sets of evaluation weights for most features: Middlegame (which includes the opening) and endgame. In the endgame, centralizing the queen is great; in the middlegame, you want it more hidden.

How does the engine know which phase the game it's in, without counting the number of moves? Typically by counting the material on the board, and interpolating between MG and EG evaluations accordingly.

Mike Sherwin
Posts: 281
Joined: Thu Aug 20, 2020 11:25 pm
Full name: Michael J Sherwin

Re: Penalizing early queen development

Post by Mike Sherwin » Wed Feb 17, 2021 11:08 pm

niel5946 wrote:
Wed Feb 17, 2021 10:35 pm
Hi.

I am in the middle of improving my evaluation function from one which just considered material and piece-square tables. I have just finished writing the evaluation code for all pieces other than the queen. I plan on evaluating the queen on two things: 1) Penalizing it, if it is attacked. And 2) Penalizing it for being developed early.

But my problem is that i can't find a way that seems optimal for nr. 2. I have considered making a developed_queen coefficient and then, if the queen isn't on it's starting square, give the penalty: developed_queen / moves_played. This just seems like it is firstly, too simple, and secondly, that it wouldn't work if I loaded an FEN from an opening position (where the amount of moves played would be unknown).

What do you think is the best way of de-incentivizing the engine from developing it's queen early on in the game?

Any help is much appreciated! :D
It depends on how deep your engine searches. If it is a deep searcher bad queen moves will be detected. If your engine does not search very deep then crafting the queen evaluation to give less of a delta than say a knight or bishop or even a rook will cause the search to play a bishop knight or rook move that gains more over a queen move that gains less. Then in the middle game and especially the endgame you can widen the queen's delta.

Edit: Also discouraging early queen moves will cause the entire search to prune better and thus time to depth will improve.

niel5946
Posts: 82
Joined: Thu Nov 26, 2020 9:06 am
Full name: Niels Abildskov

Re: Penalizing early queen development

Post by niel5946 » Wed Feb 17, 2021 11:24 pm

Mike Sherwin wrote:
Wed Feb 17, 2021 11:08 pm
niel5946 wrote:
Wed Feb 17, 2021 10:35 pm
Hi.

I am in the middle of improving my evaluation function from one which just considered material and piece-square tables. I have just finished writing the evaluation code for all pieces other than the queen. I plan on evaluating the queen on two things: 1) Penalizing it, if it is attacked. And 2) Penalizing it for being developed early.

But my problem is that i can't find a way that seems optimal for nr. 2. I have considered making a developed_queen coefficient and then, if the queen isn't on it's starting square, give the penalty: developed_queen / moves_played. This just seems like it is firstly, too simple, and secondly, that it wouldn't work if I loaded an FEN from an opening position (where the amount of moves played would be unknown).

What do you think is the best way of de-incentivizing the engine from developing it's queen early on in the game?

Any help is much appreciated! :D
It depends on how deep your engine searches. If it is a deep searcher bad queen moves will be detected. If your engine does not search very deep then crafting the queen evaluation to give less of a delta than say a knight or bishop or even a rook will cause the search to play a bishop knight or rook move that gains more over a queen move that gains less. Then in the middle game and especially the endgame you can widen the queen's delta.

Edit: Also discouraging early queen moves will cause the entire search to prune better and thus time to depth will improve.
My engine typically searches to a ply-depth between 10 and 14 in most positions, but I plan to make it go deeper. I don't know if this is deep enough to make queen development penalties redundant, but I think that I've found a pretty neat way of doing it: I have a coefficient called queen_development_penalty = 7 and for the middlegame score (a tapered eval is used, so this effect will be reduced as moves get played), I compute the product, queen_development_penalty * minor_officers_on_backrank and use this as a development penalty if the queen is not on the starting square.
Author of Loki, a C++ work in progress.
Code | Releases | Progress Log |

Ferdy
Posts: 4602
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: Penalizing early queen development

Post by Ferdy » Thu Feb 18, 2021 12:57 am

niel5946 wrote:
Wed Feb 17, 2021 10:35 pm
Hi.

I am in the middle of improving my evaluation function from one which just considered material and piece-square tables. I have just finished writing the evaluation code for all pieces other than the queen. I plan on evaluating the queen on two things: 1) Penalizing it, if it is attacked. And 2) Penalizing it for being developed early.

But my problem is that i can't find a way that seems optimal for nr. 2.
Probably the best time for you to try safe mobility. Whenever a queen can go to a certain square, check if that square is attacked by opponent.

Post Reply