Promotions in SEE

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

bctboi23
Posts: 20
Joined: Fri Feb 07, 2020 2:48 am
Location: United States
Full name: Tom R

Promotions in SEE

Post by bctboi23 »

I have started writing some code for an implementation of SEE, based on the recursive version on the chessprogramming wiki.
I am having a little difficulty understanding how to incorporate promotion captures into the SEE. Do I just ignore them (seems like a bad idea), or do I do something else?

I think I understand en passant captures in the recursive implementation (I don't have to generate them, because en passant recaptures are impossible)

Any help would be appreciated :D

P.S: here is my code for the recursive implementation, if you need it

Code: Select all

// evaluate the static exchange value of the square
static int SEE(const int sq, const int side, S_BOARD *pos) {

  int SEEValue = 0;
  int piece = pos->pieces[sq];
  int move = leastValuableAttacker(sq, side, pos);

  if (move) {
    MakeMove(pos, move);
    SEEValue = MAX(0, PieceVal[piece] - SEE(sq, side ^ 1, pos));
    TakeMove(pos);
  }

  return SEEValue;
}

// evaluate the static exchange value of a capture move
int SEECapture(int move, S_BOARD *pos) {

  int captureValue = 0;
  int capturedPiece = pos->pieces[TOSQ(move)];

  MakeMove(pos, move);
  captureValue = PieceVal[capturedPiece] - SEE(TOSQ(move), side ^ 1, pos);
  TakeMove(pos);

  return captureValue;
}
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Promotions in SEE

Post by bob »

Actually it is pretty safe to ignore promotions. First, all you can be capturing is a piece, which is always more valuable than the pawn. So it is not much of an issue to ignore the promotion gain. Second, if the opponent recaptures, you are down a pawn, which is still a good answer.

Some try to take it further. Including checking for pins, including absolute pins (on the king). SEE is only an approximation, it is used quite a lot, so speed is pretty important...
User avatar
hgm
Posts: 27700
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Promotions in SEE

Post by hgm »

One problem with promotions in SEE is that it changes the optimal order of the captures. It can pay to save the Pawn capture for last, as it would leave you with a Queen. Also, NxR, PxN would look like a good capture when you did not see that it actually is NxR, PxN=Q.
chrisw
Posts: 4290
Joined: Tue Apr 03, 2012 4:28 pm

Re: Promotions in SEE

Post by chrisw »

hgm wrote: Wed Feb 26, 2020 7:49 pm One problem with promotions in SEE is that it changes the optimal order of the captures. It can pay to save the Pawn capture for last, as it would leave you with a Queen. Also, NxR, PxN would look like a good capture when you did not see that it actually is NxR, PxN=Q.
Yeah, I thought about that one. It probably wouldn’t pay in terms of time to do the testing within the SEE, but one could test if result came back with “not enough” by testing if destination = back rank and if pawn involved, repeat with a secondary SEE that puts pawn takes last.
A SEE as in SF that just tests true/false is always going to return +ve on basis pawn takes piece, of course, so the above only if trying to get an actual exchange value. As Bob says SEE is an approximation anyway, so is all a bit overkill.
abulmo2
Posts: 432
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Promotions in SEE

Post by abulmo2 »

With Amoeba future 3.2 version, I just tried to enhance a little bit its SEE implementation.
- taking into account (queen) promotions add about 6 elo in self play (probably inflated because of SPRT).
- reordering (queen) promotion after rook capture add nothing.
If you consider the following position (from an old post)
[d]rn6/P7/K7/8/8/6k1/1Q6/8 w - - 0 1
Qxb8+ will be considered a bad move without promotion, and a a good one with promotion by SEE.
Richard Delorme
chrisw
Posts: 4290
Joined: Tue Apr 03, 2012 4:28 pm

Re: Promotions in SEE

Post by chrisw »

abulmo2 wrote: Thu Feb 27, 2020 12:10 am With Amoeba future 3.2 version, I just tried to enhance a little bit its SEE implementation.
- taking into account (queen) promotions add about 6 elo in self play (probably inflated because of SPRT).
- reordering (queen) promotion after rook capture add nothing.
If you consider the following position (from an old post)
[d]rn6/P7/K7/8/8/6k1/1Q6/8 w - - 0 1
Qxb8+ will be considered a bad move without promotion, and a a good one with promotion by SEE.
If you were using pinned piece detection, the SEE would not consider pawn takes as the first move.
abulmo2
Posts: 432
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: Promotions in SEE

Post by abulmo2 »

chrisw wrote: Thu Feb 27, 2020 10:33 am
abulmo2 wrote: Thu Feb 27, 2020 12:10 am With Amoeba future 3.2 version, I just tried to enhance a little bit its SEE implementation.
- taking into account (queen) promotions add about 6 elo in self play (probably inflated because of SPRT).
- reordering (queen) promotion after rook capture add nothing.
If you consider the following position (from an old post)
[d]rn6/P7/K7/8/8/6k1/1Q6/8 w - - 0 1
Qxb8+ will be considered a bad move without promotion, and a a good one with promotion by SEE.
If you were using pinned piece detection, the SEE would not consider pawn takes as the first move.
Amoeba uses a legal move generator, so it does not try to compute SEE for illegal pawn move axb8.
Considering all possible moves, the SEE score are the following in Amoeba (development version):
Ka5:0, Kb5:0, Kb6:0, Kb7:0, Qxb8+:3,

The SEE sequence is the following for the Qxb8+:
queen x knight: partial see score = +3
rook x queen: partial see score = -6
pawn x rook: partial see score = -1 and promote to queen: partial see score = +7
Without promotion the final see score = -1, and with promotion = +3 (capturing the queen by the rook is no more interesting). So, when sorting the moves, Qxb8+ can be played first or last.
Richard Delorme