Help me to test an idea for Stockfish (I don't know programm

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
mohzus
Posts: 106
Joined: Tue Sep 24, 2013 2:54 am

Help me to test an idea for Stockfish (I don't know programm

Post by mohzus »

Hi,
I do not know programming (cannot distinguish between c and c++, don't even know how to do an hello world program) and I would like to test an idea for Stockfish and eventually test it in fishtest framework.
The idea is simple: give a small penalty for bishops in the early game for their starting positions.

Something like:
if game_phase=PHASE_MIDGAME then (assignate penalty of 10 or 15 cp for bishops on c1 and f1 for white side and penalty of 10 or 15 cp for bishops on c8 and f8 for black side).


In order to set this up, I would like to know what file(s) I must/could modify. I am thinking about evaluate.cpp, though I am not sure. Any pointers will be welcomed :)
User avatar
mohzus
Posts: 106
Joined: Tue Sep 24, 2013 2:54 am

Re: Help me to test an idea for Stockfish (I don't know prog

Post by mohzus »

Hmm. If I understand well my idea could be very simple to test. Modify the file psqtab.h, line 54 up to 63 contains

Code: Select all

 { // Bishop
     S(-40,-59), S(-40,-42), S(-35,-35), S(-30,-26), S(-30,-26), S(-35,-35), S(-40,-42), S(-40,-59),
     S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
     S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
     S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
     S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
     S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
     S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
     S(-17,-59), S(-17,-42), S(-13,-35), S( -8,-26), S( -8,-26), S(-13,-35), S(-17,-42), S(-17,-59)
    },
And I would have to modify only 4 values there. One of them would be S(-13,-35) to S(-23,-35), the first entry seems to be the score assigned for middle game and the second entry, end game.
But how do I implant the fact that I want a penalty only on c1 and f1 for white and only on c8 and f8 for black?

Edit: Nevermind, score are according to white's side and it's symmetric for black side. Now I need to know where is the 1st row and where is the 8th row. :)


Edit 2: I think I get it. Would the following accomplish what I want?:

Code: Select all

{ // Bishop
   S(-40,-59), S(-40,-42), S(-35,-35), S(-30,-26), S(-30,-26), S(-35,-35), S(-40,-42), S(-40,-59),
   S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
   S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
   S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
   S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
   S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
   S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
   S(-17,-59), S(-17,-42), S(-21,-35), S( -8,-26), S( -8,-26), S(-21,-35), S(-17,-42), S(-17,-59)
  },
I changed the values S(-13,-35) to S(-21,-35) (8cp penalty for bishops on their starting squares in middle game phase).
Does this look correct?
Joerg Oster
Posts: 937
Joined: Fri Mar 10, 2006 4:29 pm
Location: Germany

Re: Help me to test an idea for Stockfish (I don't know prog

Post by Joerg Oster »

mohzus wrote:Hmm. If I understand well my idea could be very simple to test. Modify the file psqtab.h, line 54 up to 63 contains

Code: Select all

 { // Bishop
     S(-40,-59), S(-40,-42), S(-35,-35), S(-30,-26), S(-30,-26), S(-35,-35), S(-40,-42), S(-40,-59),
     S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
     S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
     S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
     S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
     S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
     S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
     S(-17,-59), S(-17,-42), S(-13,-35), S( -8,-26), S( -8,-26), S(-13,-35), S(-17,-42), S(-17,-59)
    },
And I would have to modify only 4 values there. One of them would be S(-13,-35) to S(-23,-35), the first entry seems to be the score assigned for middle game and the second entry, end game.
But how do I implant the fact that I want a penalty only on c1 and f1 for white and only on c8 and f8 for black?

Edit: Nevermind, score are according to white's side and it's symmetric for black side. Now I need to know where is the 1st row and where is the 8th row. :)


Edit 2: I think I get it. Would the following accomplish what I want?:

Code: Select all

{ // Bishop
   S(-40,-59), S(-40,-42), S(-35,-35), S(-30,-26), S(-30,-26), S(-35,-35), S(-40,-42), S(-40,-59),
   S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
   S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
   S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
   S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26),
   S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35),
   S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42),
   S(-17,-59), S(-17,-42), S(-21,-35), S( -8,-26), S( -8,-26), S(-21,-35), S(-17,-42), S(-17,-59)
  },
I changed the values S(-13,-35) to S(-21,-35) (8cp penalty for bishops on their starting squares in middle game phase).
Does this look correct?
Hi Robert,

unfortunately, not.
You must read those tables from top to bottom. So the first row represents Rank 1, the second Rank 2, and so on.
And the columns go from File A to H, 1st column is File A.
As you can see, c1 and f1 already have a penalty.
Jörg Oster
User avatar
mohzus
Posts: 106
Joined: Tue Sep 24, 2013 2:54 am

Re: Help me to test an idea for Stockfish (I don't know prog

Post by mohzus »

Thank you Joerg. I will do some testing on a position with the correct modifications. If I understood well, it would be:

Code: Select all

 { // Bishop 
     S(-40,-59), S(-40,-42), S(-43,-35), S(-30,-26), S(-30,-26), S(-43,-35), S(-40,-42), S(-40,-59), 
     S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42), 
     S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35), 
     S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26), 
     S( -8,-26), S(  0,-11), S(  4, -4), S( 17,  4), S( 17,  4), S(  4, -4), S(  0,-11), S( -8,-26), 
     S(-13,-35), S( -4,-18), S(  8,-11), S(  4, -4), S(  4, -4), S(  8,-11), S( -4,-18), S(-13,-35), 
     S(-17,-42), S(  0,-26), S( -4,-18), S(  0,-11), S(  0,-11), S( -4,-18), S(  0,-26), S(-17,-42), 
     S(-17,-59), S(-17,-42), S(-13,-35), S( -8,-26), S( -8,-26), S(-13,-35), S(-17,-42), S(-17,-59) 
    },
if I wanted to add a penalty of 8cp. I will do some testings and fix the penalty according to the results.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Help me to test an idea for Stockfish (I don't know prog

Post by Lyudmil Tsvetkov »

Hi Robert.
Now that you have started modifying this table, if you would accept to test if possible a pseudoidea of mine: it seems to me that white bishops on d1 and e1 in the middlegame deserve much bigger penalty than just 8cps. I would probably double it. Actually, I think bishops retreating on d1 and e1 are much worse located than c1 and f1. There they take some other pieces' places. And Stockfish sometimes likes to retreat on e8 with its black bishop when it should not do so under any circumstances.

So maybe -25cps penalty for white bishops on d1/e1, black on d8/e8 for the middlegame could be meaningful.

Sorry to jump into your thread like a bum, but I could not resist seeing those nice tables.
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Help me to test an idea for Stockfish (I don't know prog

Post by Lyudmil Tsvetkov »

Btw., who needs endgame psqt?

My impression is that endgames in general are so simple for modern top engines, that they would do quite well even without endgame psqt. But still not without midgame psqt. Has anyone tried to measure the impact of psqt in the middlegame and endgame? I would think that for the middlegame the impact would be available, but probably negligeable for the endgame.
User avatar
michiguel
Posts: 6401
Joined: Thu Mar 09, 2006 8:30 pm
Location: Chicago, Illinois, USA

Re: Help me to test an idea for Stockfish (I don't know prog

Post by michiguel »

Lyudmil Tsvetkov wrote:Btw., who needs endgame psqt?

My impression is that endgames in general are so simple for modern top engines, that they would do quite well even without endgame psqt. But still not without midgame psqt. Has anyone tried to measure the impact of psqt in the middlegame and endgame? I would think that for the middlegame the impact would be available, but probably negligeable for the endgame.
"Endgame" values have nothing to do with the "end game" per se, but they are a way to determine a straight line that links all the different degrees of material content. An identical (and possibly theoretically better for tuning!) way to do all this would be to have an "initial" value and a "slope" (score change per unit of material change).

In addition, PST values are worthless per se, what matters is the relative value among the squares. Putting all together, and to be more precise, what matters is the relative slope between the squares. It is not entirely correct to think in absolute terms of endgame or middlegame. In fact, this scheme of having two values and interpolate them was set to ignore broken transitions and make them smooth.

Miguel
Lyudmil Tsvetkov
Posts: 6052
Joined: Tue Jun 12, 2012 12:41 pm

Re: Help me to test an idea for Stockfish (I don't know prog

Post by Lyudmil Tsvetkov »

michiguel wrote:
Lyudmil Tsvetkov wrote:Btw., who needs endgame psqt?

My impression is that endgames in general are so simple for modern top engines, that they would do quite well even without endgame psqt. But still not without midgame psqt. Has anyone tried to measure the impact of psqt in the middlegame and endgame? I would think that for the middlegame the impact would be available, but probably negligeable for the endgame.
"Endgame" values have nothing to do with the "end game" per se, but they are a way to determine a straight line that links all the different degrees of material content. An identical (and possibly theoretically better for tuning!) way to do all this would be to have an "initial" value and a "slope" (score change per unit of material change).

In addition, PST values are worthless per se, what matters is the relative value among the squares. Putting all together, and to be more precise, what matters is the relative slope between the squares. It is not entirely correct to think in absolute terms of endgame or middlegame. In fact, this scheme of having two values and interpolate them was set to ignore broken transitions and make them smooth.

Miguel
You have a point here, but do not you have terms that apply only for the middlegame, or only for the endgame? Those should also make transitions less smooth, theoretically.

Let us take a term like a bishop pin, for example. Difficult to believ you can do well without it in the middlegame, but it is totally useless in the endgame. Actually, if you score bishop pin in the endgame, it is quite probable that the transition will be less smooth, as a bishop pin has meaning only in positions with many pieces and complications, but meaningless in the endgame.

Same with psqt, if endgame psqt only does damage, why not leave psqt just for the middlegame? When you have a position with just 5 or 6 pieces at most, psqt will hardly help, but maybe I am wrong and that is why I asked if someone has tested the performance of psqt separately for the middlegame and endgame.

One thing I know for sure: I have never seen a top engine go wrong in a simple pawn endgame, and never means never; I might have seen couple of examples when a top engine will misplay simple one or 2 piece endings, but this is extremely rare. On the other hand, engines still make many mistakes in the middlegame. Conclusion: engines play much better the endgame than the middlegame, so why not experiment to put different eval and search weight on the two stages? Especially what concerns eval, I might define a much bigger range of parameters that would apply only in the middlegame, or the endgame.
User avatar
hgm
Posts: 27789
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Help me to test an idea for Stockfish (I don't know prog

Post by hgm »

Engines play end-games well because they can search very deep there, so that evaluation errors are masked. But end-game evaluation is still important, because it dictates what the engine will do in the late middle game, when the leaves just reach into the end-game.

So you should not judge the quality and importance of the end-game evaluation by how well the engines play in the end-game, but by how well they end up in the best end-game that was reachable.
Last edited by hgm on Sat Jan 04, 2014 12:01 am, edited 1 time in total.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Help me to test an idea for Stockfish (I don't know prog

Post by syzygy »

Lyudmil Tsvetkov wrote:You have a point here, but do not you have terms that apply only for the middlegame, or only for the endgame? Those should also make transitions less smooth, theoretically.

Let us take a term like a bishop pin, for example. Difficult to believ you can do well without it in the middlegame, but it is totally useless in the endgame.
Miguel's point is this: if a particular term is worth say 100 in a "pure middlegame" position and 0 in a "pure endgame" position, then what SF's scheme does is exactly that. In addition, if the position being evaluated is somewhere between a "pure middlegame" and a "pure endgame" position, then the bonus being awarded is somewhere between 100 and 0 (linearly interpolated).