QS

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
cms271828
Posts: 316
Joined: Wed Apr 12, 2006 10:47 pm

QS

Post by cms271828 »

I'm about to put QS back into engine, I'm using the same simple technique HG Muller showed me...

Code: Select all

int search(int depth, int lastTo, int alpha, int beta)
{
    if&#40;depth<=0&#41; staticval=EVAL&#40;);

    if&#40;  !  IN_CHECK&#40;) && I_HAVE_MORE_THAN_TWO_PIECES&#40;) )
    &#123;
        if&#40;staticval >= beta ) return beta;
    &#125;

    ALLMOVES = GENERATE_ALL_MOVES&#40;);

    if&#40;ALLMOVES is empty&#41; return checkmate/stalemate score accordingly

    for each MOVE in ALLMOVES
    &#123;
        if&#40;depth>0  || to==lastTo&#41;
        &#123;
            Make&#40;MOVE&#41;;
            val=-search&#40;depth-1,to,-beta,-alpha&#41;;
            Undo&#40;MOVE&#41;;
        &#125;
        else  val=staticval;

        if&#40;val >= beta&#41; return beta;
        if&#40;val > alpha&#41; alpha=val;
    &#125;

    return alpha;
&#125;
So should I use PROBEHASH() at the beginning of the method (before the if(depth<=0)... ) just as before?

I guess if there is a hash move, then like the moves generated, it will only be played if its destination is the lastTo square.

Thanks
Colin
Tony

Re: QS

Post by Tony »

You might as well go for a "full" qsearch and replace

Code: Select all


if&#40;depth>0  || to==lastTo&#41; 

with

Code: Select all


if&#40;depth>0  || board->pieceOnSquare&#91;t&#93;==AnOppoPiece&#41; 


Leave the rest out for the moment ( so no hash,prune etc ).

You can add them later in a seperate (dedicated) QSearch funtion.

For now, this is more than enough.

Tony
User avatar
cms271828
Posts: 316
Joined: Wed Apr 12, 2006 10:47 pm

Re: QS

Post by cms271828 »

Yeh, I think I get it...

The problem with TO==LastTO, is that if you have a capture sequence on a square, then after the sequence has finished, you could have pieces that were defended, but not now, since the defending piece was part of the capture sequence.
That method is better than nothing, but still flawed.

If I use board->pieceOnSquare[t]==AnOppoPiece, this filters out non-captures, but wouldn't this cause the search tree to explode in some cases, since some capture sequences (over lots of squares instead of one) could go really deep, in theory ???

I only plan to store into hashtable when D>0, but what about probing the hash? Should I do this at every node, or limit it to D>0 or D>=0 ?

Thanks for any advice
Colin
Tony

Re: QS

Post by Tony »

cms271828 wrote:Yeh, I think I get it...

The problem with TO==LastTO, is that if you have a capture sequence on a square, then after the sequence has finished, you could have pieces that were defended, but not now, since the defending piece was part of the capture sequence.
That method is better than nothing, but still flawed.

If I use board->pieceOnSquare[t]==AnOppoPiece, this filters out non-captures, but wouldn't this cause the search tree to explode in some cases, since some capture sequences (over lots of squares instead of one) could go really deep, in theory ???

I only plan to store into hashtable when D>0, but what about probing the hash? Should I do this at every node, or limit it to D>0 or D>=0 ?

Thanks for any advice
There are various opinions about qsearch.

One is that since it is not good anyway so you'd better keep it simple and small and therefor get deeper in normal search.

The other one is that you can make qsearch better by spending more effort where the effort is repayed by a more stable normal search.

Obviously, probing (and storing) is more important when you use last one. (if you use TO==LastTO, it would be the first )

In theory, qsearch can (almost) explode, but since it doesn't happen too often for a regular qsearch, don't bother. ( It might get worse when you add checking moves)

Later, limiting qsearch depth, or using a SEE function can be an option.

Tony
User avatar
cms271828
Posts: 316
Joined: Wed Apr 12, 2006 10:47 pm

Re: QS

Post by cms271828 »

Thanks,

I used the Board[TO]='enemy_piece' condition instead, and played engine against someone, in the middle game, where there was a big struggle in the centre, the Iterative Deepening only got to 4 or 5ply(in 10 seconds), so I guess there were some very big QS trees .
For now, I might just use the TO==LASTTO condition, since it should give better search depths, and could give slightly better play.

I suppose if I play engine against itself, over 10 games, with TO==LASTTO as white for 5 games, and black for 5 games, that might indicate the better player.

I'd still like to know about where to probe the hash, before I used QS, I probed at every node, and stored at non-leaf nodes (D>0).

Is it generally better to probe at every node, or when D>0(above leaves) or D>=0(on or above leaves), or something else?

Thanks :)
Colin