Engine Brining out Queen Early

Discussion of chess software programming and technical issues.

Moderator: Ras

msarchet
Posts: 13
Joined: Tue Sep 21, 2021 4:07 am
Full name: Michael Sarchet

Engine Brining out Queen Early

Post by msarchet »

I've been testing my engine against itself to evaluate changes in the eval function.

I'm not currently using an opening book, which might prevent the behavior that I am seeing. What I'm trying to figure out though is continually my engine brings out it's queen early if the middle of the board is open and it has a path. It does this mostly when there is a capture that the queen can make in the middle of the board. I'm doing AlphaBetaMinMax with Quiesence search and some minor pruning.

Outside of an opening book, what are some methods in the eval function I can make use of to develop piece material before moving higher value pieces. Or is this more of the nature of just how an engine will play in lieu of an opening book?

If it's helpful my eval function is here. https://github.com/msarchet/panzer/blob ... c/eval.cpp
Panzer (still very in progress) - C++ bitboard engine https://github.com/msarchet/panzer
R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Engine Brining out Queen Early

Post by R. Tomasi »

msarchet wrote: Wed Sep 29, 2021 9:07 pm I've been testing my engine against itself to evaluate changes in the eval function.

I'm not currently using an opening book, which might prevent the behavior that I am seeing. What I'm trying to figure out though is continually my engine brings out it's queen early if the middle of the board is open and it has a path. It does this mostly when there is a capture that the queen can make in the middle of the board. I'm doing AlphaBetaMinMax with Quiesence search and some minor pruning.

Outside of an opening book, what are some methods in the eval function I can make use of to develop piece material before moving higher value pieces. Or is this more of the nature of just how an engine will play in lieu of an opening book?

If it's helpful my eval function is here. https://github.com/msarchet/panzer/blob ... c/eval.cpp
I'm using a very simple eval function currently in my engine: only mobility+control. The mobility term of the eval will advocate bringing the queen out early, since the queen has many moves when in the open. The control term however mitigates that, since it's hard to actually control squares using a queen: attacking the square that is controlled by a queen with lower pieces will gain control over that square. So the control term will deem it better to develop the lower pieces. YMMV, of course.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Engine Brining out Queen Early

Post by dangi12012 »

R. Tomasi wrote: Wed Sep 29, 2021 9:13 pm I'm using a very simple eval function currently in my engine: only mobility+control. The mobility term of the eval will advocate bringing the queen out early, since the queen has many moves when in the open. The control term however mitigates that, since it's hard to actually control squares using a queen: attacking the square that is controlled by a queen with lower pieces will gain control over that square. So the control term will deem it better to develop the lower pieces. YMMV, of course.
Dont listen to R.Tomasi. He gave bad advice on literally the last 25 posts if you look at his history.
For good ELO you dont want hardcoded policies. The half modern aprroach (2010s) is to have float policy values like queenmobility that you get the optimal value for by iteratively mutating.

So you can do a sort of genetic programming where you have some float eval parameters in you engine change a little bit - and self playing and see if the engine ELO improves. That way you can find a local optimum for all the float parameters in your engine. That applies to every policy value that is hardcoded and can really bring your engine to the next level.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Engine Brining out Queen Early

Post by R. Tomasi »

dangi12012 wrote: Thu Sep 30, 2021 1:25 pm Dont listen to R.Tomasi. He gave bad advice on literally the last 25 posts if you look at his history.
I'm not the one posting demonstrably wrong code and then claiming it's faster :lol:
dangi12012 wrote: Thu Sep 30, 2021 1:25 pm For good ELO you dont want hardcoded policies. The half modern aprroach (2010s) is to have float policy values like queenmobility that you get the optimal value for by iteratively mutating.

So you can do a sort of genetic programming where you have some float eval parameters in you engine change a little bit - and self playing and see if the engine ELO improves. That way you can find a local optimum for all the float parameters in your engine. That applies to every policy value that is hardcoded and can really bring your engine to the next level.
Once you have an actual engine, you might have some credibility... (and btw: where did I say anything about hardcoding parameters?)
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Engine Brining out Queen Early

Post by dangi12012 »

Forum moderators - i feel harassed. R. Tomasi feels the need to comment under any and all post i make. Wherever I make them with ridiculous claims. Since he has no git repo nor any engine and joined the forum 3 Weeks ago - also give exclusively bad advice its proven he is a forum troll.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
R. Tomasi
Posts: 307
Joined: Wed Sep 01, 2021 4:08 pm
Location: Germany
Full name: Roland Tomasi

Re: Engine Brining out Queen Early

Post by R. Tomasi »

dangi12012 wrote: Thu Sep 30, 2021 1:47 pm Where is your engine?
https://github.com/rtomasi75/pygmalion
dangi12012 wrote: Thu Sep 30, 2021 1:47 pm Where is your movegen?
https://github.com/rtomasi75/pygmalion/ ... -mechanics
https://github.com/rtomasi75/pygmalion/ ... n-dynamics
https://github.com/rtomasi75/pygmalion/ ... -mechanics
https://github.com/rtomasi75/pygmalion/ ... s-dynamics
dangi12012 wrote: Thu Sep 30, 2021 1:47 pm Forum moderators - i feel harassed. R. Tomasi feels the need to comment under any and all post i make. Wherever I make them with ridiculous claims. Since he has no git repo nor any engine and joined the forum 3 Weeks ago - also give exclusively bad advice its proven he is a forum troll.
See links above.

And for the record: it is you who came to this thread just to harass me.

Edit: Ahh... I see you removed your post. Trying to rewrite history, aren't we?
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Engine Brining out Queen Early

Post by dangi12012 »

Im not interested in discussion with Tomasi - as for the OP msarchet and my advice for him:

You have this code a lot: bitboard queens = c == WHITE ? board.GetWhiteQueens() : board.GetBlackQueens();
If you move WHITE to a template parameter - and have a constexpr function like this:

Code: Select all

template<bool IsWhite>
static constexpr map Queens(const Board& brd)
{
	if constexpr (IsWhite) return brd.WQueen;
	return brd.BQueen;
}
You will see a much faster eval() - especially for the pawns which shift amount depends on the color.
As for the queen problem: You can do it like stockfish for King mobility- have a term that increases with the move count (stockfish will bring king towards middle somewhere after move 25 - at least it was that way for SF8 when I read the sourcecode)

So the answer is: Adding soft negative moveterm to the queenmove (-0.5?) that depends on the movecount and approaches zero on move 12.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Mergi
Posts: 127
Joined: Sat Aug 21, 2021 9:55 pm
Full name: Jen

Re: Engine Brining out Queen Early

Post by Mergi »

You have mid and end game tables but they are both exactly the same, and they both prefer queen in the middle of the board. Why don't you try changing that? I'm confused ... what exactly is the issue here? Bringing out queen early is what you coded into your queen PST.

https://github.com/msarchet/panzer/blob ... res.h#L173
msarchet
Posts: 13
Joined: Tue Sep 21, 2021 4:07 am
Full name: Michael Sarchet

Re: Engine Brining out Queen Early

Post by msarchet »

dangi12012 wrote: Thu Sep 30, 2021 2:02 pm You have this code a lot: bitboard queens = c == WHITE ? board.GetWhiteQueens() : board.GetBlackQueens();
If you move WHITE to a template parameter - and have a constexpr function like this:

Code: Select all

template<bool IsWhite>
static constexpr map Queens(const Board& brd)
{
	if constexpr (IsWhite) return brd.WQueen;
	return brd.BQueen;
}
So the answer is: Adding soft negative moveterm to the queenmove (-0.5?) that depends on the movecount and approaches zero on move 12.
:D Still working on upping some of my C++ skills so this is very helpful. There are a lot of things I still need to learn and implement to clean up my code. In terms of my overall eval speed, it's okay. I've been using valgrind to profile and my eval time is quite a bit of my search time (which makes sense?). I'm not super worried about search times right now so this hasn't been my focus. I'm doing fixed depth search for the time being since it lets me better compare a change to my code against the prior version.
Mergi wrote: Thu Sep 30, 2021 6:13 pm You have mid and end game tables but they are both exactly the same, and they both prefer queen in the middle of the board. Why don't you try changing that? I'm confused ... what exactly is the issue here? Bringing out queen early is what you coded into your queen PST.

https://github.com/msarchet/panzer/blob ... res.h#L173
Yeah I've assumed this was part of the case, I made use of the PST from the CPW for starting out (which I think is commented in my code).

I'm still trying to get through all of the eval bits I would like to implement. After that I need to do some work on properly understanding Static Exchange Eval. I've been slowly going through the CPW Eval code and some of the deeper suggestions on the wiki. I recently have been exploring some of the code sample in here as well

Code: Select all

https://hxim.github.io/Stockfish-Evaluation-Guide/
. Which is helpful for me understanding what the heck I am doing.

----

Eval is definitely a very difficult problem, and I'm finding that I probably need to implement it more completely before I start trying to parse why certain things are happening. Really appreciating these suggestions.
Panzer (still very in progress) - C++ bitboard engine https://github.com/msarchet/panzer
jdart
Posts: 4409
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: Engine Brining out Queen Early

Post by jdart »

I just have an eval term that penalizes "queen out" depending on how many minors are on the back rank. So it encourages developing the minors before the queen.