Penalizing early queen development

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

niel5946
Posts: 174
Joined: Thu Nov 26, 2020 10:06 am
Full name: Niels Abildskov

Penalizing early queen development

Post by niel5946 »

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: 300
Joined: Mon Apr 30, 2018 11:51 pm

Re: Penalizing early queen development

Post by Sesse »

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: 868
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Penalizing early queen development

Post by Mike Sherwin »

niel5946 wrote: Wed Feb 17, 2021 11: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: 174
Joined: Thu Nov 26, 2020 10:06 am
Full name: Niels Abildskov

Re: Penalizing early queen development

Post by niel5946 »

Mike Sherwin wrote: Thu Feb 18, 2021 12:08 am
niel5946 wrote: Wed Feb 17, 2021 11: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: 4833
Joined: Sun Aug 10, 2008 3:15 pm
Location: Philippines

Re: Penalizing early queen development

Post by Ferdy »

niel5946 wrote: Wed Feb 17, 2021 11: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.