Cardoso wrote:Hi everybody
,
suppose I got convinced my engine does better in very complex positions (wich it does not)
and I want my engine to prefer positions with many queens for example.
since the root_ply=1, I do the following in the eval:
//some_weight could be 10 for example (pawn=100, queen=1000),
//WQ and BQ are the queens bitboards of their respective color
Code: Select all
if (ply&1) {
int qc = __popcount(WQ | BQ);
score += qc * some_weight;
} else {
// do nothing (wich might as well go without the "else" statement
// this means the opponent don't evaluate/care this feature
}
is the above code correct ?
Will my engine prefer positions with many queens with the above code?
best regards,
Alvaro
Since you asked me to look, first an assumption... namely that you want the queens to stay on to lead to more complications? If that is the case, you need an asymmetric evaluation term. The ply&1 doesn't seem like the right way.
In your evaluation, you probably want something like this, using pseudo-code:
q_bonus = 0;
if (program_is_playing_white) {
q_bonus = PopCnt(white_queens) * queen_bonus;
} else
q_bonus = -PopCnt(black_queens) * queen_bonus;
Later:
score += q_bonus;
This assumes you compute score from white POV and then at the end you do something like:
return (wtm) ? score : -score;
If I didn't blow the above, it should add a bonus if your program has one or more queens, anywhere that an evaluation is done.
I wouldn't write the code quite as above, but it is easier to read than trying to condense it using a conditional assignment. The "q_bonus" is relative to the side your program is playing. If white, the bonus is + for each white queen, if black, the bonus is - for each black queen (making the bonus for white POV.