Mobility Evaluation ?

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 10:54 pm

Mobility Evaluation ?

Post by MahmoudUthman » Wed Oct 12, 2016 9:38 pm

Right now my Evaluation considers material , PST , passed & isolated pawns, and basic mobility (Mob Score=5*#Legal Moves)
1-Is counting completely safe mobility better than just counting moves to squares not occupied by my(king or pawns ) and not attacked by enemy's (king or pawns) , or is it not worth it "Generally"?
2-I'm using Adam's and Pawel's PST , could someone give good weights(count ,(mid , end)game) for mobility to go along with those ?
3-How much improvement should I expect by switching to whatever the best method is from the two mention above in #1 ?

*by the way why does stock Fish do this :

Code: Select all

// Find attacked squares, including x-ray attacks for bishops and rooks
        b = Pt == BISHOP ? attacks_bb<BISHOP>&#40;s, pos.pieces&#40;) ^ pos.pieces&#40;Us, QUEEN&#41;)
          &#58; Pt ==   ROOK ? attacks_bb<  ROOK>&#40;s, pos.pieces&#40;) ^ pos.pieces&#40;Us, ROOK, QUEEN&#41;)
                         &#58; pos.attacks_from<Pt>&#40;s&#41;;
for Bishops and rooks only ?

kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 3:48 am

Re: Mobility Evaluation ?

Post by kbhearn » Thu Oct 13, 2016 12:21 am

1) They both have meaning (along with some other forms of mobility)
- safe mobility is good for penalising bad pieces (a piece with very low safe mobility can be given a significantly negative mobility score)
- general mobility reflects that even the squares a piece can't move to it has some influence over (i.e. it could trade for a piece that lands there)
- forward mobility can be used as an indicator for the attack potential of a piece in the middlegame
- any of the above may benefit from non-linearity - the first bit of mobility an extra move is a lot more important than the difference between 10 and 11 mobility for a piece.

2 & 3 depends a lot on the general state of your engine

The stockfish code you linked treats squares in front of a queen in a bishop-queen battery or rook or queen in a rook-queen/rook-rook battery as part of its mobility (as it's adding influence to those squares even though it's not attacking them directly). As for why bishops and rooks only, that means queens are omitted (knights/pawns/kings don't xray) and presumably is a result of testing - queen mobility is in general a less weighted term anyways.

AndrewGrant
Posts: 467
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: Mobility Evaluation ?

Post by AndrewGrant » Thu Oct 13, 2016 2:05 am

queen mobility is in general a less weighted term anyways.
I'm not sure whether or not I agree with you.
Stockfish, however, does not agree, as far as I can tell.

Code: Select all

  // MobilityBonus&#91;PieceType&#93;&#91;attacked&#93; contains bonuses for middle and end
  // game, indexed by piece type and number of attacked squares in the MobilityArea.
  const Score MobilityBonus&#91;&#93;&#91;32&#93; = &#123;
    &#123;&#125;, &#123;&#125;,
    &#123; S&#40;-75,-76&#41;, S&#40;-56,-54&#41;, S&#40; -9,-26&#41;, S&#40; -2,-10&#41;, S&#40;  6,  5&#41;, S&#40; 15, 11&#41;, // Knights
      S&#40; 22, 26&#41;, S&#40; 30, 28&#41;, S&#40; 36, 29&#41; &#125;,
    &#123; S&#40;-48,-58&#41;, S&#40;-21,-19&#41;, S&#40; 16, -2&#41;, S&#40; 26, 12&#41;, S&#40; 37, 22&#41;, S&#40; 51, 42&#41;, // Bishops
      S&#40; 54, 54&#41;, S&#40; 63, 58&#41;, S&#40; 65, 63&#41;, S&#40; 71, 70&#41;, S&#40; 79, 74&#41;, S&#40; 81, 86&#41;,
      S&#40; 92, 90&#41;, S&#40; 97, 94&#41; &#125;,
    &#123; S&#40;-56,-78&#41;, S&#40;-25,-18&#41;, S&#40;-11, 26&#41;, S&#40; -5, 55&#41;, S&#40; -4, 70&#41;, S&#40; -1, 81&#41;, // Rooks
      S&#40;  8,109&#41;, S&#40; 14,120&#41;, S&#40; 21,128&#41;, S&#40; 23,143&#41;, S&#40; 31,154&#41;, S&#40; 32,160&#41;,
      S&#40; 43,165&#41;, S&#40; 49,168&#41;, S&#40; 59,169&#41; &#125;,
    &#123; S&#40;-40,-35&#41;, S&#40;-25,-12&#41;, S&#40;  2,  7&#41;, S&#40;  4, 19&#41;, S&#40; 14, 37&#41;, S&#40; 24, 55&#41;, // Queens
      S&#40; 25, 62&#41;, S&#40; 40, 76&#41;, S&#40; 43, 79&#41;, S&#40; 47, 87&#41;, S&#40; 54, 94&#41;, S&#40; 56,102&#41;,
      S&#40; 60,111&#41;, S&#40; 70,116&#41;, S&#40; 72,118&#41;, S&#40; 73,122&#41;, S&#40; 75,128&#41;, S&#40; 77,130&#41;,
      S&#40; 85,133&#41;, S&#40; 94,136&#41;, S&#40; 99,140&#41;, S&#40;108,157&#41;, S&#40;112,158&#41;, S&#40;113,161&#41;,
      S&#40;118,174&#41;, S&#40;119,177&#41;, S&#40;123,191&#41;, S&#40;128,199&#41; &#125;
&#125;;

Ferdy
Posts: 4042
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: Mobility Evaluation ?

Post by Ferdy » Thu Oct 13, 2016 4:03 am

MahmoudUthman wrote:Right now my Evaluation considers material , PST , passed & isolated pawns, and basic mobility (Mob Score=5*#Legal Moves)
1-Is counting completely safe mobility better than just counting moves to squares not occupied by my(king or pawns ) and not attacked by enemy's (king or pawns) , or is it not worth it "Generally"?
Could you describe what do you mean by "counting completely safe mobility"?

AndrewGrant
Posts: 467
Joined: Tue Apr 19, 2016 4:08 am
Location: U.S.A
Full name: Andrew Grant
Contact:

Re: Mobility Evaluation ?

Post by AndrewGrant » Thu Oct 13, 2016 5:31 am

I think he means moves in which no enemy piece may capture you. As opposed to not caring at all about possible attacks, or caring only about pawn attacks.

kbhearn
Posts: 411
Joined: Thu Dec 30, 2010 3:48 am

Re: Mobility Evaluation ?

Post by kbhearn » Thu Oct 13, 2016 8:01 am

stockfish appears to use safe mobility for the queen vs general mobility for the rest of the pieces which might allow the higher weights. high weights for safe mobility would be less prone to looking to throw the queen into the middle of a busy position where it could be chased.

Code: Select all

if &#40;Pt == QUEEN&#41;
            b &= ~(  ei.attackedBy&#91;Them&#93;&#91;KNIGHT&#93;
                   | ei.attackedBy&#91;Them&#93;&#91;BISHOP&#93;
                   | ei.attackedBy&#91;Them&#93;&#91;ROOK&#93;);
edit: almost safe mobility in general actually - missed the passed in mobilityarea which is calculated in main evaluate and eliminates squares attacked by pawns from the mobility map.

MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 10:54 pm

Re: Mobility Evaluation ?

Post by MahmoudUthman » Thu Oct 13, 2016 11:02 pm

Ferdy wrote:
MahmoudUthman wrote:Right now my Evaluation considers material , PST , passed & isolated pawns, and basic mobility (Mob Score=5*#Legal Moves)
1-Is counting completely safe mobility better than just counting moves to squares not occupied by my(king or pawns ) and not attacked by enemy's (king or pawns) , or is it not worth it "Generally"?
Could you describe what do you mean by "counting completely safe mobility"?
Exactly what Andrew Grant said.
kbhearn wrote:1) They both have meaning (along with some other forms of mobility)
- any of the above may benefit from non-linearity - the first bit of mobility an extra move is a lot more important than the difference between 10 and 11 mobility for a piece.
what about taking this further using different weights for moves according to their destination being inside our or the enemy's half of the board ?

Ferdy
Posts: 4042
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: Mobility Evaluation ?

Post by Ferdy » Fri Oct 14, 2016 12:53 am

MahmoudUthman wrote:
Ferdy wrote:
MahmoudUthman wrote:Right now my Evaluation considers material , PST , passed & isolated pawns, and basic mobility (Mob Score=5*#Legal Moves)
1-Is counting completely safe mobility better than just counting moves to squares not occupied by my(king or pawns ) and not attacked by enemy's (king or pawns) , or is it not worth it "Generally"?
Could you describe what do you mean by "counting completely safe mobility"?
Exactly what Andrew Grant said.
In my experience calculating everything is no better. Perhaps one reason for this is that mobility is not a single one feature to win a game. But if you can calculate this with less cost, you might be able to use this info to evaluate some features in the position, like attack and defense, piece threats, and of course king-safety. I think it is also an issue of where to apply these info.
In variants such as shogi, and crazyhouse - games that involve dropping of pieces, this attack info is very important that you would want to find out the SSE - square static evaluation of every square especially squares near the kings.

MahmoudUthman
Posts: 234
Joined: Sat Jan 17, 2015 10:54 pm

Re: Mobility Evaluation ?

Post by MahmoudUthman » Sun Oct 16, 2016 12:00 am

two more questions :
1-should I ignore king and pawns "all types : push , capture , promote ,en-passant" moves while calculating mobility ?
2-When one side is in check should I calculate mobility as usual and apply the usual weights or should I use different weights for the checked side or set mobility to zero.

*one more thing should I apply a penalty for being in check and a reward for checking ? and if though compared to a centipawn how large or small should this penalty be ?

Ferdy
Posts: 4042
Joined: Sun Aug 10, 2008 1:15 pm
Location: Philippines

Re: Mobility Evaluation ?

Post by Ferdy » Mon Oct 17, 2016 12:53 am

MahmoudUthman wrote:two more questions :
1-should I ignore king and pawns "all types : push , capture , promote ,en-passant" moves while calculating mobility ?
I calculate mobility in evaluation function. Where did you calculate your mobility?
*one more thing should I apply a penalty for being in check and a reward for checking ? and if though compared to a centipawn how large or small should this penalty be ?
If your qsearch would return with side in check you can add a small penalty, start at -5 cp. You can always tune this as you introduce some evaluation, reduction/pruning changes later.

Post Reply