I have a new idea for backwards pawns.
I compiled it with MS Visual C++ 2008 (without optimizations).
Unfortunatelly, I had to stop a test (P IV 3GHz):
// Test for backward pawn
//
// If the pawn is passed, isolated, or member of a pawn chain
// it cannot be backward. If can capture an enemy pawn or if
// there are friendly pawns behind on neighboring files it cannot
// be backward either.
if ( (passed | isolated | chain)
|| (ourPawns & attack_span_mask(opposite_color(Us), s))
|| (pos.attacks_from<PAWN>(s, Us) & theirPawns))
backward = false;
else
{
// We now know that there are no friendly pawns beside or behind this
// pawn on neighboring files. We now check whether the pawn is
// backward by looking in the forward direction on the neighboring
// files, and seeing whether we meet a friendly or an enemy pawn first.
b = this_and_neighboring_files_bb(f) & rank_bb(Us == WHITE ? r+1 : r-1);
// Note that we are sure to find something because pawn is not passed
// nor isolated, so loop is potentially infinite, but it isn't.
while (!(b & (ourPawns | theirPawns)))
Us == WHITE ? b <<= 8 : b >>= 8;
if (b & file_bb(f) & theirPawns)
backward = !(neighboring_files_bb(f) & theirPawns);
// The friendly pawn needs to be at least two ranks closer than the enemy
// pawn in order to help the potentially backward pawn advance.
else backward = (b | (Us == WHITE ? b << 8 : b >> 8)) & theirPawns;
}
lech wrote:
Is there a sense (setting - comp, cute, C++, score) to continue this test.
If I have understood correctly you extend definition of backward pawns also to pawns that have an enemy pawn in front and don't have enemy pawns on neighboring files. Is it correct ?
Could you please post a chess diagram, a position with an example of a backward pawn according to your new definition that is _not_ considered a backward pawn by default SF ?
P.S: I think it is interesting and I would suggest to continue the test, also cutechess command line seems fine.
lech wrote:
Is there a sense (setting - comp, cute, C++, score) to continue this test.
If I have understood correctly you extend definition of backward pawns also to pawns that have an enemy pawn in front and don't have enemy pawns on neighboring files. Is it correct ?
Could you please post a chess diagram, a position with an example of a backward pawn according to your new definition that is _not_ considered a backward pawn by default SF ?
P.S: I think it is interesting and I would suggest to continue the test, also cutechess command line seems fine.
In original SF there is possible a position:
[d] 8/6p1/8/5pPp/8/8/5P1P/8 b - -
After 1…g6 two pawns f2 and h2 become backward (??). My code is a patch (correction) for the SF’s code.
In my opinion, a single opposed enemy pawn can do a pawn backward.
I have some doubts looking trough the result of matches (cutechess-cli). There are too long strings of wins for one side. I think that engines don’t tire and have a healthy psyche.
I think, By the way, it would be good to correct that
if (isolated)
{
value -= IsolatedPawnPenalty[f];
if (!(theirPawns & file_bb(f)))
value -= IsolatedPawnPenalty[f] / 2;
}
if (doubled)
value -= DoubledPawnPenalty[f];
if (backward)
{
value -= BackwardPawnPenalty[f];
if (!(theirPawns & file_bb(f)))
value -= BackwardPawnPenalty[f] / 2;
if (isolated)
{
value -= IsolatedPawnPenalty[f];
if (!opposed)
value -= IsolatedPawnPenalty[f] / 2;
}
if (doubled)
value -= DoubledPawnPenalty[f];
if (backward)
{
value -= BackwardPawnPenalty[f];
if (!opposed)
value -= BackwardPawnPenalty[f] / 2;
lech wrote:
In original SF there is possible a position:
[d] 8/6p1/8/5pPp/8/8/5P1P/8 b - -
After 1…g6 two pawns f2 and h2 become backward (??). My code is a patch (correction) for the SF’s code.
In my opinion, a single opposed enemy pawn can do a pawn backward.
I have no enough chess knowledge to understand if pawns f2 and h2 are backward (for you they are) or are not, in the latter case your code should be changed in
// Test for backward pawn
//
backward = false;
// If the pawn is passed, isolated, or member of a pawn chain
// it cannot be backward. If can capture an enemy pawn or if
// there are friendly pawns behind on neighboring files it cannot
// be backward either.
if ( !(passed | isolated | chain)
&& !(ourPawns & attack_span_mask(opposite_color(Us), s))
&& !(pos.attacks_from<PAWN>(s, Us) & theirPawns))
{
// We now know that there are no friendly pawns beside or behind this
// pawn on neighboring files. We now check whether the pawn is
// backward by looking in the forward direction on the neighboring
// files, and seeing whether we meet a friendly or an enemy pawn first.
// We want to look also on our file because, if we are opposed, we
// want to see if we cannot advance due to the opposed pawn.
b = this_and_neighboring_files_bb(f) & rank_bb(Us == WHITE ? r+1 : r-1);
// Note that we are sure to find something because pawn is not passed
// nor isolated, so loop is potentially infinite, but it isn't.
while (!(b & (ourPawns | theirPawns)))
Us == WHITE ? b <<= 8 : b >>= 8;
// If pawn advancement is not blocked by an opposing one then this is
// potentially backward. The last check is to verify friendly pawn is
// at least two ranks closer than the enemy pawn in order to help
// the potentially backward pawn advance.
if (b & file_bb(f) & theirPawns == EmptyBoardBB)
backward = (b | (Us == WHITE ? b << 8 : b >> 8)) & theirPawns;
}
lech wrote:
I think, By the way, it would be good to correct that
if (isolated)
{
value -= IsolatedPawnPenalty[f];
if (!(theirPawns & file_bb(f)))
value -= IsolatedPawnPenalty[f] / 2;
}
if (doubled)
value -= DoubledPawnPenalty[f];
if (backward)
{
value -= BackwardPawnPenalty[f];
if (!(theirPawns & file_bb(f)))
value -= BackwardPawnPenalty[f] / 2;
if (isolated)
{
value -= IsolatedPawnPenalty[f];
if (!opposed)
value -= IsolatedPawnPenalty[f] / 2;
}
if (doubled)
value -= DoubledPawnPenalty[f];
if (backward)
{
value -= BackwardPawnPenalty[f];
if (!opposed)
value -= BackwardPawnPenalty[f] / 2;
Thanks, yes it would be correct
Last edited by mcostalba on Sat Jul 17, 2010 6:09 pm, edited 1 time in total.
mcostalba wrote:
If I have understood correctly you extend definition of backward pawns also to pawns that have an enemy pawn in front and don't have enemy pawns on neighboring files. Is it correct ?
If you don't agree with this, it is possible to change the code:
Us == WHITE ? b <<= 8 : b >>= 8;
if (b & file_bb(f) & theirPawns)
backward = false;
// The friendly pawn needs to be at least two ranks closer than the enemy
// pawn in order to help the potentially backward pawn advance.
else backward = (b | (Us == WHITE ? b << 8 : b >> 8)) & theirPawns;
After 200 games the result is Sfx vs Sf: +72 -59 =69.
Note that the pawn g6 (after 1...g6) in the mentioned above possition is not backward by the original code.
lech wrote:
Is there a sense (setting - comp, cute, C++, score) to continue this test.
If I have understood correctly you extend definition of backward pawns also to pawns that have an enemy pawn in front and don't have enemy pawns on neighboring files. Is it correct ?
Could you please post a chess diagram, a position with an example of a backward pawn according to your new definition that is _not_ considered a backward pawn by default SF ?
P.S: I think it is interesting and I would suggest to continue the test, also cutechess command line seems fine.
In original SF there is possible a position:
[d] 8/6p1/8/5pPp/8/8/5P1P/8 b - -
After 1…g6 two pawns f2 and h2 become backward (??). My code is a patch (correction) for the SF’s code.
They are not backward pawns.
Miguel
In my opinion, a single opposed enemy pawn can do a pawn backward.
I have some doubts looking trough the result of matches (cutechess-cli). There are too long strings of wins for one side. I think that engines don’t tire and have a healthy psyche.
I think, By the way, it would be good to correct that
if (isolated)
{
value -= IsolatedPawnPenalty[f];
if (!(theirPawns & file_bb(f)))
value -= IsolatedPawnPenalty[f] / 2;
}
if (doubled)
value -= DoubledPawnPenalty[f];
if (backward)
{
value -= BackwardPawnPenalty[f];
if (!(theirPawns & file_bb(f)))
value -= BackwardPawnPenalty[f] / 2;
if (isolated)
{
value -= IsolatedPawnPenalty[f];
if (!opposed)
value -= IsolatedPawnPenalty[f] / 2;
}
if (doubled)
value -= DoubledPawnPenalty[f];
if (backward)
{
value -= BackwardPawnPenalty[f];
if (!opposed)
value -= BackwardPawnPenalty[f] / 2;
// Test for backward pawn
//
backward = false;
// If the pawn is passed, isolated, or member of a pawn chain
// it cannot be backward. If can capture an enemy pawn or if
// there are friendly pawns behind on neighboring files it cannot
// be backward either.
if ( !(passed | isolated | chain)
&& !(ourPawns & attack_span_mask(opposite_color(Us), s))
&& !(pos.attacks_from<PAWN>(s, Us) & theirPawns))
{
// We now know that there are no friendly pawns beside or behind this
// pawn on neighboring files. We now check whether the pawn is
// backward by looking in the forward direction on the neighboring
// files, and seeing whether we meet a friendly or an enemy pawn first.
// We want to look also on our file because, if we are opposed, we
// want to see if we cannot advance due to the opposed pawn.
b = this_and_neighboring_files_bb(f) & rank_bb(Us == WHITE ? r+1 : r-1);
// Note that we are sure to find something because pawn is not passed
// nor isolated, so loop is potentially infinite, but it isn't.
while (!(b & (ourPawns | theirPawns)))
Us == WHITE ? b <<= 8 : b >>= 8;
// If pawn advancement is not blocked by an opposing one then this is
// potentially backward. The last check is to verify friendly pawn is
// at least two ranks closer than the enemy pawn in order to help
// the potentially backward pawn advance.
if (b & file_bb(f) & theirPawns == EmptyBoardBB)
backward = (b | (Us == WHITE ? b << 8 : b >> 8)) & theirPawns;
}
if not "if (b & file_bb(f) & theirPawns == EmptyBoardBB)" backward don't have a value (??) Sorry i see.
Last edited by lech on Sat Jul 17, 2010 6:14 pm, edited 1 time in total.