MVV/LVA

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

flok

MVV/LVA

Post by flok »

Hi,

Regarding the MVV/LVA sorting.
The chess wiki speaks about the victim and the attacker-type.
So the sorting-function for qsort() does
int a = (victimValueA << 16) | (32767 - attackerValueA);
int b = (victimValueB << 16) | (32767 - attackerValueB);
return b - a;
This works.
The values for each type used are:
const int ChessPiece::evalVal[] = { 100, 325, 325, 500, 975, 10000 };

Now my question is: how do I include promotions in this?
I could for example set the lsb to either 1 or 0 but that does not include the type to which it promoted.
Any suggestions?


regards
PK
Posts: 893
Joined: Mon Jan 15, 2007 11:23 am
Location: Warsza

Re: MVV/LVA

Post by PK »

simple promotion without capture is scored as "I gain a queen (or whatever piece is promoted), but I lose a pawn". Promoting with capture, just add the value of promoted piece to victimValue.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: MVV/LVA

Post by hgm »

I guess it is a bit more subtle than that. If you attack a Rook on the 8th rank that is protected by Knight with a Pawn and a Rook, it would come out much better when you play RxR, NxR, PxN=Q then when you play PxR=Q, NxQ, RxN. The NxR deserves to be captured before the PxR. You would be left with a Queen rather than a Knight. So promoting does not just increase the gain you get on the capture, but also your exposure. Basically you should score it like the attacker is a Queen (or whatever you promote to), not a Pawn.

You should also take into account that a 7th-rank Pawn is worth 2.5-3, not 1. So a non-capture promoting to Queen is like you capture a piece worth 6 with a Queen. That is, it is a HxL capture, and should really not be attempted if the target square is protected. (I.e. you should reduce the victim value to the SEE value of the exchange, like with all HxL captures.)