On StockFish 1.7.1

Discussion of chess software programming and technical issues.

Moderator: Ras

Look

On StockFish 1.7.1

Post by Look »

Here are some quick ideas after a brief look at source of SF 1.7.1 and watching its games. Even if they somehow exist in code, they obviously need more work. Well maybe they are full of nonsense; So be cautious... But I think giving these ideas just after release of Rybka 4 is not that bad anyway :).

- End-games (both sides having several pawns):
pawn endgames: consider outside passed pawns search and eval.
rook end games: active rook and outside passed pawn in search and eval.
Consider adding OPP for other end-games as well. Maybe when each side has one same piece, think about others too.

- King safety: change kingzone. It should contain two zones. zone 1: squares adjacent to king, zone2: squares which contain and are adjacent to zone1 . So if K is on g8 zone1 is f8 f7g7 h7 h8, zone2: e8 e7 e6 f6 g6 h6. Change related stuff accordingly. Intuitively zone1 attacks score higher than zone2. Then combine for final score.
In general I assume king safety has potential for a lot of improvements.

- Smooth eval: in addition to other tests, use initial test on (huge) set of positions with no deep tactics.Search for a few plies and compare produced eval to pre-computed reference evals. Modify untuned parameter values accordingly using genetic algorithm or other techniques and produce several candidates. Afterwards test them in actual matches. Use this for every new eval term as well. Just note that you may tune key parameter values say max value of an array; use a suitable function (linear, logarithmic,...) for dependent values. Hopefully this would reduce some useless computations. In any event the eval is expected to change smoothly when engine plays.

- Run-time data: data gathered from search and eval placed to allocated memory tables for run-time consumption. For example consider a knight on c3. In cases that it moves (you may keep a record of its moves in the search tree) it goes to e4 in 70% of cases, to a4 in 20% and to e2 on 10%. Suppose we have a parameter Knight_Mobility_Value_In_RunTime set to 10 centi pawns. In next iteration of search it is given values as 7cp for e4, 2cp for a4, 1cp for e2 for the knight in its run-time eval table. The values are to be recomputed after each iteration.
In short I suppose this run-time data area has a lot of room for improvements with many different ideas.
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: On StockFish 1.7.1

Post by zamar »

All ideas you have posted are very interesting and I believe there is some potential in each of time.

The practical drawback is that implementing and fine tuning each of them will require work of tens or hundreds of hours.

Here comes the nice side of GPL. Anyone (including you) who has some extra time is allowed to test these ideas and release the improvements.
Joona Kiiski
Look

Re: On StockFish 1.7.1

Post by Look »

All ideas you have posted are very interesting and I believe there is some potential in each of time.

The practical drawback is that implementing and fine tuning each of them will require work of tens or hundreds of hours.

Here comes the nice side of GPL. Anyone (including you) who has some extra time is allowed to test these ideas and release the improvements.
Thanks. I guess the first two actually need a few days of work by professionals if they figure it out somehow.The third and fourth, actually need some framework established which then could help to improve on those ideas and many new ones.

By the way I have tried to improve on outposts in evaluate.cpp. But since I could not get actual SF 1.7.1 compiled on my machine, I hacked it to do so. Then I tried the following. I guess its a bit of improvement based on 500 10sec games against initial hacked version. So if someone change the evaluate.cpp according to these and produce a standard compile and test it base on what you prefer (its 1000 1min games I assume) we may get a better view.

Instead of KnightOutpostBonus and BishopOutpostBonus defenitions place these:

Code: Select all

const Score PawnOutpostBonus[64] = {
  //  A         B        C         D         E         F         G         H
    S(0,0),  S(0,0),   S(0,0),   S(0,0),   S(0,0),   S(0,0),   S(0,0),   S(0,0), // 1
    S(0,3),  S(0,3),   S(0,5),   S(0,5),   S(0,5),   S(0,5),   S(0,3),   S(0,3), // 2
    S(3,5),  S(5,7),   S(5,7),   S(7,10),  S(7,10),  S(5,7),   S(5,7),   S(3,5), // 3
    S(5,7),  S(7,10),  S(10,15), S(15,20), S(15,20), S(10,15), S(7,10),  S(5,7), // 4
    S(6,10), S(10,18), S(14,20), S(18,30), S(18,30), S(14,20), S(10,18), S(6,10), // 5
    S(7,25), S(14,30), S(18,40), S(23,50), S(23,50), S(18,40), S(14,30), S(7,25), // 6
    S(10,50),S(20,60), S(25,70), S(30,80), S(30,80), S(25,70), S(20,60), S(10,50), // 7
    S(0,0),  S(0,0),   S(0,0),   S(0,0),   S(0,0),   S(0,0),   S(0,0),   S(0,0), // 8
  };
  const Score KnightOutpostBonus[64] = {
  //  A        B       C       D          E          F          G       H
    S(0,0), S(0,0), S(0,0),  S(0,0),   S(0,0),    S(0,0),   S(0,0), S(0,0), // 1
    S(0,0), S(3,5), S(3,5),  S(3,5),   S(3,5),   S(3,5),     S(3,5), S(0,0), // 2
    S(0,0), S(3,5), S(5,10),  S(10,15), S(10,15), S(5,10),   S(3,5), S(0,0), // 3
    S(0,0), S(7,10), S(10,15), S(20,30), S(20,30), S(10,15), S(7,10), S(0,0), // 4
    S(0,0), S(7,10), S(10,15), S(20,30), S(20,30), S(10,15), S(7,10), S(0,0), // 5
    S(0,0), S(3,5), S(5,10),  S(10,15), S(10,15),   S(5,10), S(3,5), S(0,0), // 6
    S(0,0), S(3,5), S(3,5),   S(3,5),   S(3,5),    S(3,5),   S(3,5), S(0,0), // 7
    S(0,0), S(0,0), S(0,0),   S(0,0),   S(0,0),    S(0,0),   S(0,0), S(0,0), // 8
  };

  const Score BishopOutpostBonus[64] = {
  //  A        B       C       D         E         F       G       H
    S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),   S(0,0),  S(0,0), S(0,0), // 1
    S(0,0), S(3,5), S(3,5),  S(3,5),  S(3,5),   S(3,5),  S(3,5), S(0,0), // 2
    S(0,0), S(3,5), S(5,7),  S(7,15), S(7,15),  S(5,7),  S(3,5), S(0,0), // 3
    S(0,0), S(3,5), S(7,15), S(10,25),S(10,25), S(7,15), S(3,5), S(0,0), // 4
    S(0,0), S(3,5), S(7,15), S(10,25),S(10,25), S(7,15), S(3,5), S(0,0), // 5
    S(0,0), S(3,5), S(5,7),  S(7,15), S(7,15),  S(5,7),  S(3,5), S(0,0), // 6
    S(0,0), S(3,5), S(3,5),  S(3,5),  S(3,5),   S(3,5),  S(3,5), S(0,0), // 7
    S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),   S(0,0),  S(0,0), S(0,0), // 8
  };

const Score RookOutpostBonus[64] = { // mmm added
  //  A        B       C       D       E       F       G       H
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 1
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 2
    S(0,0), S(0,0), S(0,5), S(0,10), S(0,10), S(0,5),  S(0,0), S(0,0), // 3
    S(0,0), S(0,0), S(0,10),S(0,20), S(0,20), S(0,10), S(0,0), S(0,0), // 4
    S(0,0), S(0,0), S(0,10),S(0,20), S(0,20), S(0,10), S(0,0), S(0,0), // 5
    S(0,0), S(0,0), S(0,5), S(0,10), S(0,10), S(0,5),  S(0,0), S(0,0), // 6
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 7
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 8
  };
  
  const Score QueenOutpostBonus[64] = {// mmm added
  //  A        B       C       D       E       F       G       H
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 1
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 2
    S(0,0), S(0,0), S(0,5), S(0,10), S(0,10), S(0,5),  S(0,0), S(0,0), // 3
    S(0,0), S(0,0), S(0,10),S(0,20), S(0,20), S(0,10), S(0,0), S(0,0), // 4
    S(0,0), S(0,0), S(0,10),S(0,20), S(0,20), S(0,10), S(0,0), S(0,0), // 5
    S(0,0), S(0,0), S(0,5), S(0,10), S(0,10), S(0,5),  S(0,0), S(0,0), // 6
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 7
    S(0,0), S(0,0), S(0,0), S(0,0),  S(0,0),  S(0,0),  S(0,0), S(0,0), // 8
  };
Note that values are experimental, there could be better sets. Then change evaluate_outposts with this:

Code: Select all

 void evaluate_outposts(const Position& pos, EvalInfo& ei, Square s) {

    const Color Them = (Us == WHITE ? BLACK : WHITE);


    //Value bonus;
    Score bonus=make_score(0,0);
    if (Piece == PAWN)
       bonus = PawnOutpostBonus[relative_square(Us, s)];
    else if (Piece == KNIGHT)
       bonus = KnightOutpostBonus[relative_square(Us, s)];
    else if (Piece == BISHOP)
         bonus = BishopOutpostBonus[relative_square(Us, s)];
    else if (Piece == ROOK)
         bonus = RookOutpostBonus[relative_square(Us, s)];
    else if (Piece == QUEEN)
         bonus = QueenOutpostBonus[relative_square(Us, s)];

// TODO add and test the pawn support
    // Increase bonus if supported by pawn
    /*if ((bonus!=make_score(0,0)) && bit_is_set(ei.attackedBy[Us][PAWN], s))
    {
            bonus += bonus / 2;
    }*/

    ei.value += Sign[Us] * bonus;
  }
Anyone going to compile and test this vs SF 1.7.1 ?
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: On StockFish 1.7.1

Post by zamar »

Look wrote: Anyone going to compile and test this vs SF 1.7.1 ?
In open-source world, it's usually the responsibility of the one who expresses an idea, also convince the others about it. So why not to test it yourself? Post result here, if they are positive, I'm happy to confirm the result and merge the change.
Joona Kiiski
Look

Re: On StockFish 1.7.1

Post by Look »

I played 500 more games at 10sec per side. Here is the combined result:

Program Elo + - Games Score Av.Op. Draws

1 Sf (1.7.1) 1.1.64 : 2706 17 17 1000 51.6 % 2694 41.3 %
2 Sf (1.7.1) first compile : 2694 17 17 1000 48.4 % 2706 41.3 %

I suppose that would be an improvement, though needs independent testing. By the way does your team has a volunteer tester or something like that ?
zamar
Posts: 613
Joined: Sun Jan 18, 2009 7:03 am

Re: On StockFish 1.7.1

Post by zamar »

Look wrote:I played 500 more games at 10sec per side. Here is the combined result:

Program Elo + - Games Score Av.Op. Draws

1 Sf (1.7.1) 1.1.64 : 2706 17 17 1000 51.6 % 2694 41.3 %
2 Sf (1.7.1) first compile : 2694 17 17 1000 48.4 % 2706 41.3 %

I suppose that would be an improvement, though needs independent testing.
We usually use 1min/game and at least 1000 games. But if you use 10sec/game time, you could do at least 3000 games.

If you do this test and still get the positive result, then I promise to try to confirm your result :)
By the way does your team has a volunteer tester or something like that ?
No, it's just us and our quads.
Joona Kiiski