Author: Uri Blass
Date: 13:17:43 09/06/03
Go up one level in this thread
On September 06, 2003 at 16:01:20, Uri Blass wrote:
>This code was written by me today and it took me more than 25 minutes to think
>about the possible cases and to check that the cases were correct and to correct
>compiler errors(I hope that there are no bugs but OI still did not check it).
>
>I remember that Juel claimed that implementing pawn hash tables took him 25
>minutes so I guess that if something that seems to me part of it takes me more
>time then it is possible that I do something wrong.
>
>You can claim that I use magic numbers but I am not sure if it is more easy for
>me to remember the exact names of contants and looking for them also can take me
>time.
>
>Some explanation about the code
>The code is part of my makemove function
>
>m.bits&16 means that the last move was a pawn move
>hist_dat[hply-1].capture gives the piece that is captured in the move so I need
>to update the hash key in case of pawn move or in case of capture of a pawn
>
>side was already updated in that point so
>if (side==DARK) means if the side that moved was white.
>
>m.to<56 means that the move was not promotion(otherwise I do not need to do
>another xor to update the hash key).
>
>m.bits==21 means that the move was enpassent capture and in that case I need to
>calculate the square of the pawn based on its file.
>
>domovewhitepawndata and domoveblackpawndata are functions that calculate a lot
>of bitboards and it may be better to save the important information in the hash
>tables if I can do it.
>
>if ((m.bits&16)||(hist_dat[hply-1].capture==PAWN))
> {
> //side was changed so it is not the side to move
> if (side==DARK)
> {
>
> if (m.bits&16)
> {
> zobpawn^=zobrist[PAWN][LIGHT][m.from];
> if (m.to<56)
> zobpawn^=zobrist[PAWN][LIGHT][m.to];
> }
> if (hist_dat[hply-1].capture==PAWN)
> zobpawn^=zobrist[PAWN][DARK][m.to];
> if (m.bits==21)
> zobpawn^=zobrist[PAWN][DARK][fil0(m.to)+24];
>
> domovewhitepawndata(m);
> }
> else
> {
> if (m.bits&16)
> {
> zobpawn^=zobrist[PAWN][DARK][m.from];
> if (m.to>=8)
> zobpawn^=zobrist[PAWN][DARK][m.to];
> }
> if (hist_dat[hply-1].capture==PAWN)
> zobpawn^=zobrist[PAWN][LIGHT][m.to];
> if (m.bits==21)
> zobpawn^=zobrist[PAWN][LIGHT][fil0(m.to)+32];
> domoveblackpawndata(m);
> }
> }
Note that I forgot to add in some places
zobpawnkey[hply]=zobpawn;
I could add zobpawnkey to the struct of my history moves and to write
hist_dat[hply].zobpawnkey=zobpawn but trying it with the main hash suggest that
it was slower so I decided not to try it with the pawn hash when I do not see
the advantage of a struct relative to global varaible in convenience.
struct is less convenient because I need to write longer expression
hist_dat[hply].zobpawnkey is longer than zobpawnkey[hply] and I am afraid that
it is also slower.
Uri
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.