Is expensive eval required for QS?

Discussion of chess software programming and technical issues.

Moderators: Harvey Williamson, bob, hgm

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
brtzsnr
Posts: 433
Joined: Fri Jan 16, 2015 3:02 pm
Contact:

Is expensive eval required for QS?

Post by brtzsnr » Fri Jul 21, 2017 9:10 am

The goal of QS as I understand is to resolve immediate threats. For Zurichess I don't even test if the position is in check.

In a recent test I noticed that a very expensive eval and a very simple eval many times result in the same sequence of moves in QS.

Has anyone tried something like this:
* Do QS with a very simple eval, e.g. material counting.
* Find the sequence of moves that make the position quiet.
* Reply the moves and reevaluate with the expensive eval.

Not only that a simple eval can be updated incrementally, but prunnings are also much easier to reason with only material counting.

What do you think? Has anyone experimented with this idea?

User avatar
hgm
Posts: 25075
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Is expensive eval required for QS?

Post by hgm » Fri Jul 21, 2017 11:22 am

For capture sequences that gain material compared to the PV score, lazy eval is usually enough to guarantee the stand-pat cutoff. Full evaluation would only be needed when you end very close in score to the PV. But I don't see how you could do without it, in that case. The capture sequence that you selected with the simple eval might not be the one that you selected with the full eval, if there are multiple QS leaves ending close to the PV. And the eval difference could decide on whether this line will become the new PV or not.

E.g. you might have the choice to stand pat or trade your Bishop for a Knight, and the lazy eval might favor keeping the Bishop. But the Knight might have been very detrimental to your King safety, so that the BxN would actually save the day. But you will take the full evaluation with the Knight still there, if you don't redo the entire QS with the full evaluation.

jdart
Posts: 4014
Joined: Fri Mar 10, 2006 4:23 am
Location: http://www.arasanchess.org

Re: Is expensive eval required for QS?

Post by jdart » Fri Jul 21, 2017 1:18 pm

I used to do lazy eval. You can for example do a lazy eval first for the stand-pat test and cut off if it exceeds in value beta + some margin. But there are several problems with this. First, at least for me, some complex eval terms such as king safety can be sizeable in value. Second, I save evals (currently in the hash table, but formerly in a separate eval cache). This is more complex/less efficient if you have full and partial evals.

--Jon

User avatar
hgm
Posts: 25075
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Is expensive eval required for QS?

Post by hgm » Fri Jul 21, 2017 1:35 pm

An alternative is not to just discard the complex terms, but freeze them as soon as you enter QS. This can lead to inconsistencies when you reach the same position through different QS, and get its hashed score, but that is not very harmful (if at all). I once tried to freeze the piece mobilities to their pre-QS values in micro-Max, where they are cheaply obtained as a side effect of move generation in the position itself and its null-move reply ('static mobility'). The mobility bonuses were then made part of the piece values at the start of QS. This was not very successful, but I had never proven that the same mobility term fully applied would be beneficial at fixed nodes, so it could very well have been a mis-tuning of the term to begin with.

PK
Posts: 863
Joined: Mon Jan 15, 2007 10:23 am
Location: Warsza
Contact:

Re: Is expensive eval required for QS?

Post by PK » Sat Jul 22, 2017 5:04 pm

Actually exchanges, especially near-equal exchanges, are the most important decisions in the game. You don't want to make them half-informed.

Just imagine what happens when evaluation depends chiefly on attack prospects, because Your program sacrificed two pawns, and material-only quiescence search exchanges queens. Or if you hold the endgame when you exchange one piece pair, but lose it when you exchange another.

Ras
Posts: 1474
Joined: Tue Aug 30, 2016 6:19 pm
Full name: Rasmus Althoff
Contact:

Re: Is expensive eval required for QS?

Post by Ras » Sun Jul 23, 2017 9:56 pm

brtzsnr wrote:Has anyone experimented with this idea?
QS needs the full eval because you can get positional advantage by trading. Just think of a minor piece trade that leaves the other side with an isolated double pawn on a semi-open file.

However, I maintain a "last valid eval" structure which holds the eval from the move before and gives an orientation what the position is supposed to be.

Now in the middlegame, if the material plus mobility part of the eval shows at least 200 centipawns above or below the last valid eval, then either the opponent has blundered - or much more probable, this is in a branch that will be cut off anyway, so I skip the other positional aspects and return the value as is.

The endgame is quite different because advanced passed pawns can be important, so I do that lazy eval only in the middlegame.

User avatar
Rebel
Posts: 5694
Joined: Thu Aug 18, 2011 10:04 am

Re: Is expensive eval required for QS?

Post by Rebel » Mon Jul 24, 2017 7:06 am

brtzsnr wrote:The goal of QS as I understand is to resolve immediate threats.
Addition to the above:

in order to have an accurate evaluation of the position.

And herein lies the answer to your question.

Henk
Posts: 6560
Joined: Mon May 27, 2013 8:31 am

Re: Is expensive eval required for QS?

Post by Henk » Mon Jul 24, 2017 7:06 am

Lately Skipper does nothing (only counting material) in QS for it hurts speed. But play did not improve.

Everything you add to QS may easily create a speed bottleneck if it is slower than collecting captures.

Lazy eval did not help much too.

Uri Blass
Posts: 8796
Joined: Wed Mar 08, 2006 11:37 pm
Location: Tel-Aviv Israel

Re: Is expensive eval required for QS?

Post by Uri Blass » Mon Jul 24, 2017 9:38 am

Henk wrote:Lately Skipper does nothing (only counting material) in QS for it hurts speed. But play did not improve.

Everything you add to QS may easily create a speed bottleneck if it is slower than collecting captures.

Lazy eval did not help much too.
I think that you care too much about speed.

Skipped is not going to be a top program even if you make it 100 times faster.
It is a mistake even to think about speed at the level of skipper.

Sven
Posts: 3883
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Is expensive eval required for QS?

Post by Sven » Mon Jul 24, 2017 9:47 pm

Henk wrote:Lately Skipper does nothing (only counting material) in QS for it hurts speed. But play did not improve.

Everything you add to QS may easily create a speed bottleneck if it is slower than collecting captures.

Lazy eval did not help much too.
QS is exactly the place where the expensive eval is required. It is where the leaf nodes are, where one of them carries the final score that will be propagated to the root. Otherwise the engine will lack some positional abilities, e.g. by missing positional sacrifices like giving the exchange vs. a pawn plus an unsafe enemy king, or by missing positional trades of bishop vs. knight or vice versa. If you evaluate at full-width leaves only then the engine will play very weak.

Of course you may choose to use a very minimal evaluation everywhere (e.g. material + PST). But do not skip positional evaluation in QS just because it is QS. If BxN PxB is positionally better than standing pat then trading is the PV.

Post Reply