Moderator: Andres Valverde
Peter Fendrich wrote:http://www.seanet.com/~brucemo/topics/pv.htm
/Peter
Wing Lee wrote:Hi,
I'm having some trouble inside my alpha-beta algorithm when i try to save the PV move list. Right now i'm only saving the best move at ply 1 It would be great if anyone could tell me a simple method to save the whole list. Thanks.
int QuickPVS_AB(int side,int alfa,int beta,int depthleft,int realply,int *mainline) {
int *curmainend;
...
curmainend = mainline+2;
*mainline = -1;
*(mainline+1) = -1;
for all moves ...
int t;
t = -QuickPVS ...
if( t > alfa ) {
int *pml,*cml;
*mainline = nzet->zet;
if( nextdepth > 0 ) {
pml = mainline+1;
if( pml != curmainend ) {
cml = curmainend;
while( *cml != -1 ) {
*pml = *cml;
pml++;
cml++;
}
*pml = -1;
curmainend = pml+2;
}
}
else
*(mainline+1) = -1;
alfa = t;
}
}
....
void QuickPrintMainline(int *mainline) {
char prom2piece[8]={" PNBRQK"};
int prom,zet,f,t,i=0; // prints maximum a line of 32 ply
printf("==>");
while( i < 32 ) {
zet = mainline[i];
if( zet == -1 )
break;
zet &= 0x00007fff;
t = zet&63;
f = (zet>>6)&63;
prom = (zet>>12);
printf(" %s%s",M2A[f],M2A[t]);
if( prom )
printf("%c",prom2piece[prom]);
i++;
}
printf("\n");
fflush(stdout);
}
Pradu wrote:Peter Fendrich wrote:http://www.seanet.com/~brucemo/topics/pv.htm
/Peter
I tried hash method of extracting the PV and it works well .
Wing Lee wrote:Hi,
for the method using the hashtable to collect the PV, isn't it possible that one or more of the PV nodes gets replaced by another one further in the search? in this case, we can't retrieve it...
would a possible solution be to include some kind of indicator in the hash entry that would mean "do not delete" ?
Thanks
diepeveen wrote: - storing_mask = depth+searches_performed_in_game
- always overwrite the entry with lowest storing_mask
diepeveen wrote: - 16 bytes per entry
diepeveen wrote: - 4 probes
odds are, as shown,
less than 1 in a million that you will lose more than a few ply from the
mainline.
diepeveen wrote:Diep's overwrite strategy in hashtable:
- 16 bytes per entry
- 4 probes
- storing_mask = depth+searches_performed_in_game
- always overwrite the entry with lowest storing_mask
- diep is also storing in qsearch (it can do because of low nps speed)
Peter Fendrich wrote:What is searches_performed_in_game?
Peter Fendrich wrote:Doesn't that take more space than a simple generation counter?
Pradu wrote:Peter Fendrich wrote:What is searches_performed_in_game?
It is the number of times search is called. In a straight forward game (no takebacks and such) it is the number of times your engine was on move. If pondering is on, it is the number of half moves in the game.
Pradu wrote:Peter Fendrich wrote:Doesn't that take more space than a simple generation counter?
Not quite following...
Peter Fendrich wrote:Ok, I separate my Search from the Root. Root calls Search many times for each game-move!
Peter Fendrich wrote:Still I think that storing remaining_depth and a Generation_Counter needs less compared to a mask composed by remaining_depth and Search_Counter. Search_Counter can be quite high. My Generation_Counter is between 0-7.
/Peter
8 bytes for hash key:
22 bits for the best move:
Here's how I do it in my program:
/*********************Format of a Move*************************
A move is stored in 23 bits:
Bits (6) 0-5 are for the "to square".
Bits (3) 6-8 are for the "capture piece".
Bits (3) 9-11 are for the "moving piece".
Bits (6) 12-17 are for the "from square".
Bits (3) 18-20 are for the "promoting piece".
Bit (1) 21 is for identifying "enpassant" or "castling"
Bit (1) 22 is for identifying "kingside" or "queenside"
*************************************************************/
4 bytes for the hashed score. (Note it can be done with 2 bytes if you are using 2 bytes for the score)
2 bits for the hash value flags (alpha=1, beta=2, exact=0)
This leaves you a byte for the repalement qualifier.
//Do this somewhere in your code before starting a search:
.
.
.
board.qualifier++;
if(board.qualifier&0xFF)
{
adjustHashTableQualifiers();
board.qualifier=2;
}
.
.
.
void adjustHashTableQualifier()
{
/*code that sets your Hash table qualifiers in the following manner
*1)set all qualifiers which are board.qualfier-1 to 1
*2)set the rest of the Hash table qualifiers to 0
*/
}
Pradu wrote:By the way Peter, what is a Generation_Counter? The number of move generations? Sorry if I'm not an experienced enough programmer to understand programmign jargon (I also don't know what a Bean Counter is).
[code]8 bytes for hash key:
22 bits for the best move:
Here's how I do it in my program:
/*********************Format of a Move*************************
A move is stored in 23 bits:
Bits (6) 0-5 are for the "to square".
Bits (3) 6-8 are for the "capture piece".
Bits (3) 9-11 are for the "moving piece".
Bits (6) 12-17 are for the "from square".
Bits (3) 18-20 are for the "promoting piece".
Bit (1) 21 is for identifying "enpassant" or "castling"
Bit (1) 22 is for identifying "kingside" or "queenside"
*************************************************************/
Peter Fendrich wrote: I only store from, to and promotion for the move.
Peter Fendrich wrote:Didn't you forget the depth | move_counter we talked about?
/Peter
Wing Lee wrote:but if i wanted to detect repetitions with hash keys as well, i would need to keep a separate key for the position without the enpassant, castling and side to move, right?
Thanks
Section 9.2 wrote:Positions as in (a) and (b) are considered the same, if the same player has the move, pieces of the same kind and colour occupy the same squares, and the possible moves of all the pieces of both players are the same.
Positions are not the same if a pawn that could have been captured en passant can no longer in this manner be captured or if the right to castle has been changed temporarily or permanently.
Return to Programming and Technical Discussions
Users browsing this forum: No registered users and 25 guests