Page 3 of 3

Re: Static exchange evaluation with promotion

Posted: Mon Jul 26, 2021 7:20 pm
by Desperado
gflohr wrote: Fri Jul 23, 2021 10:58 pm Hi!

Trying to understand chess engine programming just for fun ...

... I have used test positions from https://github.com/jdart1/arasan-chess/ ... c/unit.cpp for testing my implementation of a static exchange evaluation function. I have problems understanding this position with white moving Rxc8:

[d]2r5/1P4pk/p2p1b1p/5b1n/BB3p2/2R2p2/P1P2P2/4RK2 w - - 0 1

My implementation returns a bishop's value but the test from Arasan expects a rook's value gain. Unless I terribly missed something here, my explanation is that Arasan "thinks" that re-hitting the rook with Bxc8 is a bad capture, presumably because it would result in a huge material gain for white by re-hitting with the pawn and promoting it to a queen.

My SEE implementation is based on the well-known code from https://www.chessprogramming.org/SEE_-_ ... _Algorithm. Even if I take the material gain by the promotion into account, I still end up with one bishop gain, essentially because the last hit is always the "speculative store" that gets ignored altogether, so that it doesn't matter what else the final pawn hit may win.

So what would be the correct static exchange evaluation for Rxc8 in this position with taking promotions into account?
Hi.

The sequence is like that, if the white rook move (Rc8) is the move in question: Rc8 (+500) Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100
when the material values are like 900,500,300,300,100 / Q,R,B,N,P

If the squence is within the SEE logic, Rc8 is not the next move but because of lva ordering, the pawn capture would be the first one.
Then the sequence would be like: Pc8 (+500 + 900 - 100) Bc8 ( -900 ) Rc8 (+300) = 700

You should also consider for the general case, that when the promotion is the initial move, a negative SEE value will never be less than -100,
so the SEE score is not the promoted score but the pawn value.

Re: Static exchange evaluation with promotion

Posted: Mon Jul 26, 2021 10:50 pm
by Harald
The sequence is like that, if the white rook move (Rc8) is the move in question: Rc8 (+500) Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100
when the material values are like 900,500,300,300,100 / Q,R,B,N,P
In this case the value is: Rc8 (+500) = 500 because in ... Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100 Bc8 is a bad black move, even in SEE.
White must not assume that black plays the silly Bc8. A SEE algorithm must solve these combinations and shortcuts correctly.
And Rc8, any other move, Pb8 is not part of SEE on c8.
If the squence is within the SEE logic, Rc8 is not the next move but because of lva ordering, the pawn capture would be the first one.
Then the sequence would be like: Pc8 (+500 + 900 - 100) Bc8 ( -900 ) Rc8 (+300) = 700
In this case Bc8 is good for black. Not playing Bc8 would result in +1300 for white. White can really gain only +700 cp.

Re: Static exchange evaluation with promotion

Posted: Tue Jul 27, 2021 1:08 am
by Desperado
Harald wrote: Mon Jul 26, 2021 10:50 pm
The sequence is like that, if the white rook move (Rc8) is the move in question: Rc8 (+500) Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100
when the material values are like 900,500,300,300,100 / Q,R,B,N,P
In this case the value is: Rc8 (+500) = 500 because in ... Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100 Bc8 is a bad black move, even in SEE.
White must not assume that black plays the silly Bc8. A SEE algorithm must solve these combinations and shortcuts correctly.
And Rc8, any other move, Pb8 is not part of SEE on c8.
If the squence is within the SEE logic, Rc8 is not the next move but because of lva ordering, the pawn capture would be the first one.
Then the sequence would be like: Pc8 (+500 + 900 - 100) Bc8 ( -900 ) Rc8 (+300) = 700
In this case Bc8 is good for black. Not playing Bc8 would result in +1300 for white. White can really gain only +700 cp.

Re: Static exchange evaluation with promotion

Posted: Tue Jul 27, 2021 1:09 am
by Desperado
Desperado wrote: Tue Jul 27, 2021 1:08 am
Harald wrote: Mon Jul 26, 2021 10:50 pm
The sequence is like that, if the white rook move (Rc8) is the move in question: Rc8 (+500) Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100
when the material values are like 900,500,300,300,100 / Q,R,B,N,P
In this case the value is: Rc8 (+500) = 500 because in ... Bc8 (-500) Pc8 (+300 + 900 - 100) = 1100 Bc8 is a bad black move, even in SEE.
White must not assume that black plays the silly Bc8. A SEE algorithm must solve these combinations and shortcuts correctly.
And Rc8, any other move, Pb8 is not part of SEE on c8.
If the squence is within the SEE logic, Rc8 is not the next move but because of lva ordering, the pawn capture would be the first one.
Then the sequence would be like: Pc8 (+500 + 900 - 100) Bc8 ( -900 ) Rc8 (+300) = 700
In this case Bc8 is good for black. Not playing Bc8 would result in +1300 for white. White can really gain only +700 cp.
Hello Harald.

I was not talking of the final gains, but about the values of the sequence that are generated.
The sequence that is generated before the negamax algorithm will do its job.

So the first sequence is still [500][-500][+300+900-100]. Then the negamax starts with 1100 ... ends with 500.

The second sequence is [500+900-100][-900][300]. Then the negamax starts with 700 ... ends with 700

Both sequences would be generated in SEE for sure because of the lva-mvv capture. (silly or not).
The special point is, that the same sequence on a non promotion square would result in BxR even in the first sequence.

Finally i only wanted to point out that RxR will only be checked if it is the initial move, that is tested.
Otherwise it would be a wrong solution because the pawn capture (promotion) must be done before (lva order).