move ordening; how to scale the components?

Discussion of chess software programming and technical issues.

Moderator: Ras

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 + (hbt << 6) + ((queen - attacker) << 15) + ((victim + promotion) << 25)
but that's horribly slow.

This works reasonably well:

Code: Select all

psq + (hbt << 8) + ((queen - attacker) << 8) + ((victim + promotion) << 18)
(with an unscaled hbt so it becomes really big after a while)
but I was hoping to find something better.
jdart
Posts: 4429
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(Move move) {
    return ((TypeOfMove(move) == Promotion) ?
            PieceValue(Capture(move)) + PieceValue(PromoteTo(move)) - PAWN_VALUE 
            : PieceValue(Capture(move)));
}

FORCEINLINE score_t MVV_LVA(Move move) {
    return 8*Gain(move) - PieceValue(PieceMoved(move));
}
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).