move ordening; how to scale the components?

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

flok

move ordening; how to scale the components?

Post by flok »

Hi,

For movesorting my Move object has an int score to which I sort on.
E.g. hash-hit gets the infinite value there.

Now I have several values to sort on:
* victim score (piece value of a piece that gets captured, max 975)
* attacker score (piece value of attacker, max 975)
* promotion value (975 is highest)
* PSQ_to - PSQ_from (fits in 6 bits)
* history table (max 511)

What would be a good method for combining these values?

I tried:

Code: Select all

psq + &#40;hbt << 6&#41; + (&#40;queen - attacker&#41; << 15&#41; + (&#40;victim + promotion&#41; << 25&#41;
but that's horribly slow.

This works reasonably well:

Code: Select all

psq + &#40;hbt << 8&#41; + (&#40;queen - attacker&#41; << 8&#41; + (&#40;victim + promotion&#41; << 18&#41;
(with an unscaled hbt so it becomes really big after a while)
but I was hoping to find something better.
jdart
Posts: 4366
Joined: Fri Mar 10, 2006 5:23 am
Location: http://www.arasanchess.org

Re: move ordening; how to scale the components?

Post by jdart »

Code: Select all

FORCEINLINE score_t Gain&#40;Move move&#41; &#123;
    return (&#40;TypeOfMove&#40;move&#41; == Promotion&#41; ?
            PieceValue&#40;Capture&#40;move&#41;) + PieceValue&#40;PromoteTo&#40;move&#41;) - PAWN_VALUE 
            &#58; PieceValue&#40;Capture&#40;move&#41;));
&#125;

FORCEINLINE score_t MVV_LVA&#40;Move move&#41; &#123;
    return 8*Gain&#40;move&#41; - PieceValue&#40;PieceMoved&#40;move&#41;);
&#125;
The above is only for captures or promotions. History phase moves are only ever non-captures, non-promotions, so they only have a history score (I do not use PST).