Skip to content

Commit

Permalink
mobility with queen change
Browse files Browse the repository at this point in the history
Score of ncnstockfish vs Mncnstockfish: 1092 - 983 - 3646 [0.510]
Elo difference: 6.62 +/- 5.41

bench 5250923

code by Rocky640
https://github.com/Rocky640/Stockfish/blob/4a0a95d4833fef3bb1c3971e4fde1b9ed5666cad/src/evaluate.cpp
  • Loading branch information
crocogoat committed Oct 9, 2017
1 parent b364897 commit 137d20a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/evaluate.cpp
Expand Up @@ -119,6 +119,8 @@ namespace {
// possibly via x-ray or by one pawn and one piece. Diagonal x-ray through
// pawn or squares attacked by 2 pawns are not explicitly added.
Bitboard attackedBy2[COLOR_NB];

Bitboard attackedBy2NoQ[COLOR_NB];

// kingRing[color] is the zone around the king which is considered
// by the king safety evaluation. This consists of the squares directly
Expand Down Expand Up @@ -299,6 +301,7 @@ namespace {
const Square* pl = pos.squares<Pt>(Us);

Bitboard b, bb;
int mob;
Square s;
Score score = SCORE_ZERO;

Expand All @@ -324,7 +327,8 @@ namespace {
kingAdjacentZoneAttacksCount[Us] += popcount(b & attackedBy[Them][KING]);
}

int mob = popcount(b & mobilityArea[Us]);
mob = (Pt == QUEEN ? popcount(b & mobilityArea[Us] & ~attackedBy2NoQ[Them])
: popcount(b & mobilityArea[Us]));

mobility[Us] += MobilityBonus[Pt - 2][mob];

Expand Down Expand Up @@ -857,6 +861,10 @@ namespace {
score += evaluate_pieces<WHITE, KNIGHT>() - evaluate_pieces<BLACK, KNIGHT>();
score += evaluate_pieces<WHITE, BISHOP>() - evaluate_pieces<BLACK, BISHOP>();
score += evaluate_pieces<WHITE, ROOK >() - evaluate_pieces<BLACK, ROOK >();

attackedBy2NoQ[WHITE] = attackedBy2[WHITE];
attackedBy2NoQ[BLACK] = attackedBy2[BLACK];

score += evaluate_pieces<WHITE, QUEEN >() - evaluate_pieces<BLACK, QUEEN >();

score += mobility[WHITE] - mobility[BLACK];
Expand Down

5 comments on commit 137d20a

@AndyGrant
Copy link

Choose a reason for hiding this comment

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

First test, and it passes! good luck for LTC.

@ElbertoOne
Copy link

@ElbertoOne ElbertoOne commented on 137d20a Oct 10, 2017

Choose a reason for hiding this comment

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

I think for this test to pass LTC you might also need to adjust the MobilityBonus values for the queen.

@crocogoat
Copy link
Owner Author

Choose a reason for hiding this comment

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

I've stopped it since it won't pass for sure. Difference has hovered around ~20 or lower for almost all of the test. Might as well kill it now. Guess stc was beginners luck!

But yeah, it's hard to say. Some of the values are very close or even which makes this less effective. On the other hand maybe the queen doesn't really mind "seeing" more attackers with enough time to calculate.

@Rocky640
Copy link

@Rocky640 Rocky640 commented on 137d20a Oct 10, 2017

Choose a reason for hiding this comment

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

In current master, every square controlled by a pawn is already excluded.

So excluding attackedBy2NoQ will make a difference only for squares defended by at least 2 minors or rooks. Maybe there is not so many such squares in most positions.

For sure, there is not much utility for a queen to attack such squares if the queen is alone.
It is quite unlikely she can move, or defend anything for some time.

But for squares where the queen is not alone to attack, it might be better to keep them.
Something like this

 mob = (Pt == QUEEN ? popcount(b & mobilityArea[Us] & (attackedBy2[Us] | ~attackedBy2NoQ[Them]))
                    : popcount(b & mobilityArea[Us]));

@Rocky640
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.