Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: programmers: pawn hash tables

Author: Robert Hyatt

Date: 20:44:41 03/08/03

Go up one level in this thread


On March 08, 2003 at 13:55:20, Uri Blass wrote:

>On March 08, 2003 at 09:47:05, Robert Hyatt wrote:
>
>>On March 08, 2003 at 03:17:19, Uri Blass wrote:
>>
>>>On March 08, 2003 at 01:42:15, Robert Hyatt wrote:
>>>
>>>>On March 08, 2003 at 01:29:46, Joel wrote:
>>>>
>>>>>Hey All,
>>>>>
>>>>>Just wondering what everyone thinks is the best way to implement a pawn hash
>>>>>table?
>>>>>
>>>>>At the moment I am incrementally generating a seperate pair of pawn hash keys,
>>>>>and using them to index a table - very similar to how my transposition table
>>>>>works.
>>>>>
>>>>>Is it possible to do _significantly_ better than this? It seems to be somewhat
>>>>>expensive to do, although having said that my NPS still went up at least 20% in
>>>>>most situations.
>>>>
>>>>That is what everyone since chess 4.x has done.  Two signatures, one for
>>>>all pieces and pawns, one just for pawns.
>>>>
>>>
>>>Not everyone.
>>
>>I should have said "everyone that does pawn hashing does it the way you are
>>doing it..."
>>
>>
>>>There are a lot of programs without pawn hash tables and there are even a lot of
>>>chess programs without hash tables.
>>
>>
>>Not "real" programs I bet.  Hashing provides way too much of an advantage to
>>never do it.
>>
>>
>>
>>>
>>>I remember that I found something like 10% speed reduction in nps from adding
>>>bitboards for passed pawns,isolated pawns and protected passed pawns by pawns
>>>and I earned more than it in speed from other changes.
>>>
>>>I still do not evaluate passed pawns when they are not protected by a pawn and I
>>>think that the question how to evaluate passed pawns relative to the kings and
>>>other things is more important than pawn hash tables(Maybe it is good to give
>>>some small static bonus for passed pawns but I did not like this idea because I
>>>know that there are cases when passed pawns are trapped and these cases are not
>>>rare).
>>>
>>>Another point is to evaluate king relative to pawns and not only passed pawns
>>>because one of the problems of movei in endgames is that it always assumes  that
>>>the best place for the king is the centre and it may be a problem also in case
>>>when there are no passed pawns.
>>
>>I do that and it doesn't interfere with pawn hashing at all.
>>
>>>
>>> >
>>>>
>>>>
>>>>
>>>>>
>>>>>I am not really worried about effeciency as much as some other people here, so I
>>>>>guess I am really asking whether I am missing something major.
>>>>
>>>>Doesn't sound like it.  But you will end up storing more than just a score for
>>>>the position.  IE passed pawn locations, weak pawn locations (or bitmaps that
>>>>feature them).  Etc...
>>>
>>>How many bits do you need to do it?
>>
>>8 bits per feature per side.  Passed pawns are flagged with a "1" on the file
>>they stand on.  Weak pawns the same.  Open files the same.  Etc.  My pawn hash
>>table entry is 19 bytes, you can see what's in there in "chess.h".
>
>Not so easy
>After some find next for the word hash
>I find the following:
>
>typedef struct {
>  BITBOARD key;
>  short    p_score;
>
>  unsigned char allb;

bitmap for each file.  If black has a pawn on that file, then the bit is
a 1.  Doesn't matter if black has N pawns on that single file, it is still
a 1.


>  unsigned char black_defects_k;

This is the "defects" in the pawn structure that assumes that black will
castle on the king-side.

>  unsigned char black_defects_q;

Ditto for the queenside.  (more on this later.)

>  unsigned char passed_b;

bitmap (8 bits) where a 1 means black has a passer on this file.

>  unsigned char candidates_b;

Ditto but black has a candidate passer on this file.


>
>  unsigned char allw;
>  unsigned char white_defects_k;
>  unsigned char white_defects_q;
>  unsigned char passed_w;
>  unsigned char candidates_w;
>


same for white as black above.  The two defect values are stored since I
don't hash the king position into the pawn hash signature.  I calculate the
two defect scores ignoring where the king is located, and then I use it in the
normal king-safety scoring after I have noticed whether the king is on the
king-side, queen-side, or stuck in the center.  This is also used to help me
evaluate the case where I can castle _now_ into a bad pawn structure on the
king-side, or wait a couple of moves and castle later into a better queen-side
pawn structure.




>  unsigned char protected;

0 = no protected passers exist.  1=white has a protected passer,
2 = black has a protected passer, 3=both have protected passers.


>  unsigned char outside;

1=white has outside candidate or passer
2=white has two outside candidates/passers (one on each side of board of
course).
4=black has outside candidate or passer
8=black has two outside candidates/passers
16=white has "split passers" but black does not.
32=black has "split passers" but white does not.

>  unsigned char open_files;

1 = corresponding file has no pawns.


>} PAWN_HASH_ENTRY;
>
>
>I do not understand the meaning of all the varaibles inspite of the fact that
>I can guess part of them(char allb probably give the files of the pawns but I do
>not understand the definition of black_defects_k and not the exact definition of
>candidates_b that I guess to be candidates to be passed pawns)
>
>If someone tries to make a dictionary for crafty varaibles then it may be
>productive.
>
>In that case people can use the dictionary to see things like meaning of
>varaibles or meaning of functions.
>
>I read that modifying cradty is easy
>I wonder how many people who modify crafty tried to understand the exact meaning
>of most of it's varaibles.
>
>I do not like the idea of trying to modify something that I do not understand
>most of it but again I think that some file with explanation what people need
>to know in order to do some modification for Crafty may be productive.
>
>Uri


some of the above is in the comments in evaluate.c, but not all...



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.