Skip to content

Commit

Permalink
Extra Backward penalty for backward pawns if on rank 4/5/6.
Browse files Browse the repository at this point in the history
Bench 3358030
  • Loading branch information
xoto10 committed Jul 15, 2019
1 parent 7090d25 commit 33b0718
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/pawns.cpp
Expand Up @@ -69,6 +69,8 @@ namespace {

constexpr Color Them = (Us == WHITE ? BLACK : WHITE);
constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH);
constexpr Bitboard Adv = (Us == WHITE ? Rank4BB | Rank5BB | Rank6BB
: Rank5BB | Rank4BB | Rank3BB );

Bitboard b, neighbours, stoppers, doubled, support, phalanx;
Bitboard lever, leverPush;
Expand Down Expand Up @@ -138,7 +140,7 @@ namespace {
score -= Isolated + WeakUnopposed * int(!opposed);

else if (backward)
score -= Backward + WeakUnopposed * int(!opposed);
score -= Backward + Backward * bool(SquareBB[s] & Adv) + WeakUnopposed * int(!opposed);

if (doubled && !support)
score -= Doubled;
Expand Down

4 comments on commit 33b0718

@Rocky640
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

White d6 e7 Black d7
a pawn on 6th rank an only be backward if it supports a passer.... do we really want to penalize it more ?

on the contrary, in SF9, the backward penalty was not given for ranks above 4, but eventually this was simplified away

Another side note
Backward + Backward * bool(SquareBB[s] & Adv)
could be written
Backward + Backward * bool(Adv & s)
or better:
Backward * (1 +bool(Adv & s))

Good luck

@xoto10
Copy link
Owner

@xoto10 xoto10 commented on 33b0718 Jul 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, i was doubtful about including 6th rank, but opted to start with that included. I think it could be a phalanx formation on 6th rank?

I did think of the * (1 + ...) style but chose this, one reason being that the 2nd Backward term might change to use WeakUnopposed. I should have remembered that bitboard & s works, but didn't, my bad. Your last 2 look similar to me, + and * vs * and +, not sure there's any difference there other than style.

Cheers for the comments :-)

@Rocky640
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we score the pawn using the following order
we never give a backward bonus to a phalanx pawn.

if (support | phalanx)
...
else if (!neighbour)
...
else if (backward)
...

@xoto10
Copy link
Owner

@xoto10 xoto10 commented on 33b0718 Jul 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-) D'oh! True. I'd spotted that for isolated but missed that the same logic applied for phalanx. Sure enough my updated version has no change in bench. Think I need some sleep :-)

Please sign in to comment.