Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: History heurstic

Author: Michel Langeveld

Date: 12:53:29 02/08/04

Go up one level in this thread


On February 08, 2004 at 12:35:47, Volker Böhm wrote:

>On February 08, 2004 at 10:18:21, Michel Langeveld wrote:
>
>>On February 08, 2004 at 08:04:02, Volker Böhm wrote:
>>
>>>Hi,
>>>
>>>I have implemented a combination, I thik.
>>>Question: Piece square tables are static tables build in your chess program?
>>
>>Yes, I use for this "static" tables.
>>Nullmover has 3 kinds: opening, middlegame, endgame for pawn, pawn, bishop,
>>knight, rook, queen, king . 3x7 = 21 lists. I have for black and white each an
>>own list for speed issues. So I have 42 lists at start up.
>
>can you give me an idear how that changes?
>
>In opening you prefere knight and bishop moves before pawn moves before rook and
>queen moves before king moves (casteling is an exception, allways first)?
>
>Where does this change in middlegame?

Here is the knight table:

const scoreType whiteKnightOpening_ScoreInput[8][8]=
{
   {-12, -7, -5, -2, -2, -5, -7,-12},
   { -7, -5, -2,  0,  0, -2, -5, -7},
   { -5, -2,  2,  3,  3,  2, -2, -5},
   { -6,  0,  2,  2,  2,  1,  0, -6},
   { -5, -2,  1,  1,  1,  1, -2, -5},
   { -6, -2,  5, -1, -1,  5, -2, -6},
   { -9, -7, -5,  0,  0, -5, -7, -9},
   {-12, -7, -5, -5, -5, -5, -7,-12}
};

const scoreType whiteKnightMiddleGame_ScoreInput[8][8] =
{
   {-25,-15,-10, -5, -5,-10,-15,-25},
   {-15,-10, -5,  0,  0, -5,-10,-15},
   {-10, -5,  8, 10, 10,  8, -5,-10},
   {-10,  2,  4,  6,  6,  3,  2,-10},
   {-10, -5,  3,  2,  2,  3, -5,-10},
   {-13, -5,  0, -3, -3,  0, -5,-13},
   {-18,-15,-10, -5, -5,-10,-15,-18},
   {-25,-15,-10,-10,-10,-10,-15,-25},
};

const scoreType whiteKnightEndGame_ScoreInput[8][8] =
{
   {-25,-15,-10, -5, -5,-10,-15,-25},
   {-15,-10, -5,  0,  0, -5,-10,-15},
   {-10, -5,  0,  5,  5,  0, -5,-10},
   {-10, -5,  5,  5,  5,  5, -5,-10},
   {-10, -5,  5,  5,  5,  5, -5,-10},
   {-13, -5,  0,  5,  5,  0, -5,-13},
   {-18,-15,-10, -5, -5,-10,-15,-18},
   {-25,-15,-10,-10,-10,-10,-15,-25},
};

Here is the king table:

/////////////////////////////////////////////////////////////////////////////
// King scores
/////////////////////////////////////////////////////////////////////////////

const scoreType whiteKingOpening_ScoreInput[8][8] =
{
   {-30,-30,-30,-30,-30,-30,-30,-30},
   {-27,-27,-27,-27,-27,-27,-27,-27},
   {-24,-24,-27,-30,-30,-27,-24,-24},
   {-21,-21,-24,-27,-27,-24,-21,-21},
   {-18,-18,-21,-24,-24,-21,-18,-18},
   {-15,-15,-18,-21,-21,-18,-15,-15},
   {-12,-12,-12,-12,-12,-12,-12,-12},
   {  8, 10,  8, -5,  0, -5, 10,  8}
};

const scoreType whiteKingMiddleGame_ScoreInput[8][8] =
{
   {-10,-10,-10,-10,-10,-10,-10,-10},
   { -9, -9, -9, -9, -9, -9, -9, -9},
   { -8, -8, -8, -8, -8, -8, -8, -8},
   { -7, -7, -7, -7, -7, -7, -7, -7},
   { -6, -6, -6, -6, -6, -6, -6, -6},
   { -5, -5, -5, -5, -5, -5, -5, -5},
   { -4, -4, -4, -4, -4, -4, -4, -4},
   {  8, 10,  2, -3, -5, -2, 10,  8}
};

const scoreType whiteKingEndGame_ScoreInput[8][8] =
{
   {-15,-10, -6, -2, -2, -6,-10,-15},
   {-10, -3,  3,  5,  5,  3, -3,-10},
   { -6,  3,  7, 10, 10,  7,  3, -6},
   { -2,  5, 10, 20, 20, 10,  5, -2},
   { -2,  5, 10, 20, 20, 10,  5, -2},
   { -6,  3,  7, 10, 10,  7,  3, -6},
   {-10, -3,  3,  5,  5,  3, -3,-10},
   {-15,-10, -6, -2, -2  -6,-10,-15}

};


>In endgame its pawn-moves before king moves before piece moves?
>
>>
>>>If yes I do the following:
>>
>>>Build 9 move lists.
>>
>>What 9 movelists?
>Usually you´ll generate each move to a list of moves. Ususally this list is
>implemented as array of moves.
>
>I have an array of arrays of moves with 9 elements:
>Move MoveLists[9][MAXMOVES]
>When generating moves I add every move to one of the 9 "lists". In list "0" I
>put "good" hit moves, in list "1" "bad" hit moves, in list "2".."8" non-hit
>moves.
>The number 2..8 is selected by static tables.
>
>When iterating through all moves I take the moves from MoveLists[0] first, then
>from MoveLists[1], ...
>
>I sort the moves in the list only if I get to this list.
>
>if (!MoveList[CurrentMoveList].GetNextMove())
>{
>   CurrentMoveList++;
>   MoveList[CurrentMoveList].Sort();
>}

I don't sort moves at all .... I select the best move.
This saves also performance:

I have two version of selectbestmove as follows:

//////////////////////////////////////////////////////////////////////
//Select the best move out of a movelist
//This function can changes the moveordering of moves if there are more
//moves of the same score.... this results in a worse performance compared
//with the other method.
//////////////////////////////////////////////////////////////////////
void selectBestMove_quick_but_change_order(moveListType *ml, int index)
{
   for (int i=index+1; i < ml->number; i++)
   {
      if (ml->moves[i].score > ml->moves[index].score)
      {
         moveWithScoreType tmp_move = ml->moves[index];
         ml->moves[index] = ml->moves[i];
         ml->moves[i] = tmp_move;
      }
   }
}

void selectBestMove(moveListType *ml, int index)
{
   int found_index = index;

   //find the place of the first move who has the highest score
   for (int i=index+1; i < ml->number; i++)
   {
      if (ml->moves[found_index].score < ml->moves[i].score)
      {
         found_index = i;
      }
   }

   //move all moves to the end and bring the found move to the front
   if (found_index != index)
   {
      moveWithScoreType tmp = ml->moves[found_index];
      memmove(&ml->moves[index+1], &ml->moves[index], (found_index - index)  *
sizeof(moveWithScoreType));
      ml->moves[index] = tmp;
   }
}

The last one doesn't change the order of moves. It picks the highest move ...
put it this move forward and put all the moves infront of this move one
backward.

>Thats how i mix static values with values from history-tables.

I understand your idea. Quite an original idea, but I am not sure if it
outperformance selectBestMove(..)

>>>Put every move to one of this lists from the static piece
>>>square table (example pawn moves to 7-th rank gets to the top list).
>>>Sort every move in one bucket by history (from-to).
>>>
>>>Works best for me. Reduces amount of sorting time.
>>>
>>>Greetings Volker



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.