Mauritz8 / Vividmind

A UCI-compatible chess engine written from scratch in C++
1 stars 0 forks source link

MVV-LVA #120

Closed Mauritz8 closed 10 months ago

Mauritz8 commented 11 months ago

MVV-LVA (Most Valuable Victim - Least Valuable Aggressor) is a move ordering technique. It ranks captures based on the material difference of the piece that is capturing and the piece that is being captured. So if a pawn captures a bishop it is ranked higher than if a queen captures a bishop. Then you order moves based on that, and there's a few different ways you could go about doing it. Either you could order the moves as follows:

  1. Good capture moves
  2. Non-capture moves
  3. Bad capture moves

Or you could do it like this:

  1. Good capture moves
  2. Bad capture moves
  3. Non-capture moves

In the first option it would start by looking at good captures (where the capturing piece is worth less than or equal to the piece being captured), then by looking at non-capture moves, and only at the end look at bad capture moves (where the capturing piece is worth more than the piece being captured). This is great because if a pawn can capture a queen it is most likely a good move, but if a queen can capture a pawn it is most likely bad (assuming that the pawn is defended).

The first option fails if there is a hanging piece, because then any move that captures it is in all likelihood good. By looking at bad capture moves before non-capture moves, as in option 2, this would be resolved. The drawback is that then it would look at a lot of bad moves in all the positions where pieces are defended.

To me option 1 makes more sense, since in most positions there are a lot of bad captures since most pieces are defended. Despite that it's worth trying out both, and testing them both against each other, and also matching them against the previous version, in order to find out which is actually better.

Mauritz8 commented 10 months ago

This is the result when ordering moves as:

  1. Good capture moves
  2. Non-capture moves
  3. Bad capture moves image
Mauritz8 commented 10 months ago

This is the result when ordering moves as:

  1. Good capture moves
  2. Bad capture moves
  3. Non-capture moves image
Mauritz8 commented 10 months ago

Interestingly enough, ordering moves using the second approach is magnitudes better, which is certainly did not expect. I think it is because in all the variations where you move a piece to a square where it can be taken by a higher value piece, it will score the move that captures the hanging piece as the worst move, which will slow down things significantly.