TalkChess.com
Hosted by Your Move Chess & Games

Author Message
Tu Ngoc Trung

Joined: 23 Feb 2012
Posts: 2

Post subject: Re: Stockfish - material balance/imbalance evaluation    Posted: Sun May 27, 2012 2:22 am

Sorry for my very late reply. I've recently found this topic.
I have some questions:
- In following code (current StockFish snapshot in Github), please notice code in bold format.
 Code: namespace {   //...   // Polynomial material balance parameters   const Value RedundantQueenPenalty = Value(320);   const Value RedundantRookPenalty  = Value(554);     const int LinearCoefficients[6] = { 1617, -162, -1172, -190, 105, 26 };

 Code: /*   const int QuadraticCoefficientsSameColor[][8] = {   { 7, 7, 7, 7, 7, 7 }, { 39, 2, 7, 7, 7, 7 }, { 35, 271, -4, 7, 7, 7 },   { 7, 25, 4, 7, 7, 7 }, { -27, -2, 46, 100, 56, 7 }, { 58, 29, 83, 148, -3, -25 } };   const int QuadraticCoefficientsOppositeColor[][8] = {   { 41, 41, 41, 41, 41, 41 }, { 37, 41, 41, 41, 41, 41 }, { 10, 62, 41, 41, 41, 41 },   { 57, 64, 39, 41, 41, 41 }, { 50, 40, 23, -22, 41, 41 }, { 106, 101, 3, 151, 171, 41 } }; */   // Re-formatted:   const int QuadraticCoefficientsSameColor[][8] = {       {   7,   7,  7,   7,  7, 7 },       {  39,   2,  7,   7,  7, 7 },       {  35, 271, -4,   7,  7, 7 },       {   7,  25,  4,   7,  7, 7 },       { -27,  -2, 46, 100, 56, 7 },       {  58,  29, 83, 148, -3, -25 } };   const int QuadraticCoefficientsOppositeColor[][8] = {       { 41,  41, 41,  41,  41, 41 },       { 37,  41, 41,  41,  41, 41 },       { 10,  62, 41,  41,  41, 41 },       { 57,  64, 39,  41,  41, 41 },       { 50,  40, 23, -22,  41, 41 },       { 106, 101, 3, 151, 171, 41 } };

{ 7, 7, 7, 7, 7, 7 },
{ 39, 2, 7, 7, 7, 7 },
{ 35, 271, -4, 7, 7, 7 },
{ 7, 25, 4, 7, 7, 7 },
{ -27, -2, 46, 100, 56, 7 },
{ 58, 29, 83, 148, -3, -25 } };

{ 41, 41, 41, 41, 41, 41 },
{ 37, 41, 41, 41, 41, 41 },
{ 10, 62, 41, 41, 41, 41 },
{ 57, 64, 39, 41, 41, 41 },
{ 50, 40, 23, -22, 41, 41 },
{ 106, 101, 3, 151, 171, 41 } };
 Code: template int MaterialTable::imbalance(const int pieceCount[][8]) {   //...   // Redundancy of major pieces, formula based on Kaufman's paper   // "The Evaluation of Material Imbalances in Chess"   if (pieceCount[Us][ROOK] > 0)       value -=  RedundantRookPenalty * (pieceCount[Us][ROOK] - 1)               + RedundantQueenPenalty * pieceCount[Us][QUEEN];   // Second-degree polynomial material imbalance by Tord Romstad   for (pt1 = NO_PIECE_TYPE; [b]pt1 <= QUEEN[/b]; pt1++)   {       pc = pieceCount[Us][pt1];       if (!pc)           continue;       v = LinearCoefficients[pt1];       for (pt2 = NO_PIECE_TYPE; pt2 <= pt1; pt2++)           v +=  QuadraticCoefficientsSameColor[pt1][pt2] * pieceCount[Us][pt2]               + QuadraticCoefficientsOppositeColor[pt1][pt2] * pieceCount[Them][pt2];       value += pc * v;   }

for (pt2 = NO_PIECE_TYPE; pt2 <= pt1; pt2++)

Questions:
1. What is the meaning of RedundantQueenPenalty, RedundantRookPenalty and why they are used in following code?
 Code: if (pieceCount[Us][ROOK] > 0)       value -=  RedundantRookPenalty * (pieceCount[Us][ROOK] - 1)               + RedundantQueenPenalty * pieceCount[Us][QUEEN];

2. What is the meaning of LinearCoefficients values?
 Code: const int LinearCoefficients[6] = { 1617, -162, -1172, -190, 105, 26 };

3. Why do you use for (pt2 = NO_PIECE_TYPE; pt2 <= pt1; pt2++) ? I think it should be for (pt2 = NO_PIECE_TYPE; pt2 <= QUEEN; pt2++). Because if you keep the current code, program will scan thought the arrays QuadraticCoefficientsXXX as I mentioned in blue bold format. Numbers of loop iterations will be (1+2+3+4+5+6)=21 instead of 6x6=36. And red-italic values of QuadraticCoefficientsXXX arrays will not be calculated.
4. Why do you calculate
Why not calculate
Because the meaning of array name I understand here is Opposite color but not Opponent color.

Thanks & regards,
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
Subject Author Date/Time
Ralph Stoesser Wed May 05, 2010 4:39 pm
Marco Costalba Wed May 05, 2010 4:48 pm
Ralph Stoesser Wed May 05, 2010 5:37 pm
Marco Costalba Wed May 05, 2010 5:47 pm
Jan Brouwer Wed May 05, 2010 5:49 pm
Eelco de Groot Wed May 05, 2010 7:25 pm
Ralph Stoesser Wed May 05, 2010 8:02 pm
Eelco de Groot Wed May 05, 2010 10:10 pm
Milos Stanisavljevic Wed May 05, 2010 10:30 pm
Eelco de Groot Wed May 05, 2010 10:47 pm
Ralph Stoesser Wed May 05, 2010 11:27 pm
Eelco de Groot Thu May 06, 2010 1:23 am
Ralph Stoesser Thu May 06, 2010 9:07 am
Sven Schüle Thu May 06, 2010 9:31 am
Ralph Stoesser Thu May 06, 2010 9:52 am
Sven Schüle Thu May 06, 2010 10:48 am
Ralph Stoesser Thu May 06, 2010 12:08 pm
Tord Romstad Thu May 06, 2010 8:24 pm
Eelco de Groot Thu May 06, 2010 1:19 pm
Ralph Stoesser Fri May 07, 2010 9:34 pm
Marco Costalba Sat May 08, 2010 12:48 pm
Eelco de Groot Sat May 08, 2010 1:47 pm
Marcel van Kervinck Sat May 08, 2010 2:01 pm
Marco Costalba Thu May 06, 2010 11:40 am
Eelco de Groot Wed May 05, 2010 10:42 pm
Joona Kiiski Wed May 05, 2010 7:54 pm
Ralph Stoesser Wed May 05, 2010 8:28 pm
Larry Kaufman Sun May 27, 2012 7:31 pm
Tord Romstad Thu May 06, 2010 8:16 pm
James Coit Thu May 06, 2010 10:13 pm
Vratko Polák Thu May 06, 2010 11:38 pm
Ralph Stoesser Fri May 07, 2010 12:15 am
Marco Costalba Fri May 07, 2010 5:39 am
Ralph Stoesser Fri May 07, 2010 8:09 am
Marco Costalba Fri May 07, 2010 8:25 am
Sven Schüle Fri May 07, 2010 9:48 am
Sven Schüle Fri May 07, 2010 10:31 am
Ralph Stoesser Fri May 07, 2010 10:54 am
Miguel A. Ballicora Fri May 07, 2010 10:31 pm
Ralph Stoesser Sat May 08, 2010 1:33 pm
Marco Costalba Sat May 08, 2010 2:29 pm
Ralph Stoesser Sat May 08, 2010 4:24 pm
Ralph Stoesser Sat May 08, 2010 7:54 pm
Ralph Stoesser Sun May 09, 2010 3:19 pm
Marco Costalba Sun May 09, 2010 4:47 pm
Ralph Stoesser Sun May 09, 2010 7:51 pm
Marco Costalba Sun May 09, 2010 10:47 pm
Ralph Stoesser Sun May 09, 2010 11:22 pm
Marco Costalba Mon May 10, 2010 4:58 am
Sven Schüle Mon May 10, 2010 7:39 am
Ralph Stoesser Mon May 10, 2010 10:22 am
Eelco de Groot Mon May 10, 2010 5:04 pm
Ralph Stoesser Mon May 10, 2010 9:35 pm
Marco Costalba Tue May 11, 2010 11:19 am
Ralph Stoesser Tue May 11, 2010 1:51 pm
Ralph Stoesser Tue May 11, 2010 9:38 pm
Marco Costalba Wed May 12, 2010 5:05 pm
Robert Hyatt Wed May 12, 2010 6:14 pm
Marco Costalba Wed May 12, 2010 6:39 pm
Ralph Stoesser Thu May 13, 2010 12:51 pm
Ralph Stoesser Wed May 12, 2010 8:13 pm
Ralph Stoesser Wed May 12, 2010 9:15 pm
Marco Costalba Wed May 12, 2010 9:34 pm
Ralph Stoesser Wed May 12, 2010 10:02 pm
Eelco de Groot Sat May 08, 2010 4:53 pm
Ralph Stoesser Sat May 08, 2010 7:03 pm
Vincent Diepeveen Wed Jul 28, 2010 6:10 pm
Milos Stanisavljevic Wed Jul 28, 2010 6:24 pm
grzegorzs Thu Aug 05, 2010 5:36 pm
Dann Corbit Wed Jul 28, 2010 6:43 pm
Vincent Diepeveen Wed Jul 28, 2010 7:43 pm
Vincent Diepeveen Wed Jul 28, 2010 7:44 pm
Joona Kiiski Wed Jul 28, 2010 7:55 pm
Vincent Diepeveen Wed Jul 28, 2010 8:30 pm
Milos Stanisavljevic Wed Jul 28, 2010 9:30 pm
Vincent Diepeveen Wed Jul 28, 2010 10:11 pm
Milos Stanisavljevic Wed Jul 28, 2010 10:31 pm
Vincent Diepeveen Wed Jul 28, 2010 10:57 pm
Ben-Hur Carlos Langoni Wed Jul 28, 2010 11:07 pm
Vincent Diepeveen Wed Jul 28, 2010 11:36 pm
Ben Stoker Wed Jul 28, 2010 10:07 pm
Vincent Diepeveen Sun Aug 08, 2010 1:54 pm
Robert Hyatt Wed Jul 28, 2010 8:27 pm
Dann Corbit Wed Jul 28, 2010 9:30 pm
Wylie Garvin Tue Aug 10, 2010 10:00 pm
Re: Stockfish - material balance/imbalance evaluation Tu Ngoc Trung Sun May 27, 2012 2:22 am
Ferdinand Mosca Sun May 27, 2012 10:01 am
Tu Ngoc Trung Mon May 28, 2012 3:19 am
Eelco de Groot Mon May 28, 2012 4:19 am

 Jump to: Select a forum Computer Chess Club Forums----------------Computer Chess Club: General TopicsComputer Chess Club: Tournaments and MatchesComputer Chess Club: Programming and Technical DiscussionsComputer Chess Club: Engine Origins Other Forums----------------Chess Thinkers ForumForum Help and Suggestions
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum