New version of alfil without Tables Hash, but better alpha-beta search.
I?m trying to insert Tables Hash with Zobrist keys. My keys now are good but i have problems with the Probe and Store in alpha-beta search.
If someone can help me, thanks.
Moderator: Andres Valverde
//====================================================================
//HashStore() and HashProbe() save and retrieve information from
//the hash table
//====================================================================
void HashStore(int ply, int depth, int type, int threat, int val, int move) {
//index slot
hash_entry *ph;
ph = hash_table + (key_1 & hash_mask);
//adjust for mate
if (val > DEAD) val += ply;
else if (val < -DEAD) val -= ply;
if (ph->key1 != key_1) {
//slot 1 is empty or occupied by a different position
if ((ph->data & old_entry)||(depth >= hget_depth(ph->data))) {
//new data looks better. get move from slot 2 if we have none
//and then move existing occupant (if any) to slot 2
if (!move && (ph + 1)->key1 == key_1) move = hget_move((ph+1)->data);
(ph+1)->key1 = ph->key1;
(ph+1)->data = ph->data;
} else {
//existing data in slot 1 looks better. leave existing occupant
//alone and put new data in slot 2
ph++;
}
} else {
//this is our slot. save existing move if we have no new move
if (!move) move = hget_move(ph->data);
}
if (depth < 0) depth = 0; //don't try to store negative depth!
ph->key1 = key_1;
ph->data = hset_type(type) | hset_threat(threat) | hset_val(val) |
hset_depth(depth) | hset_move(move);
}
int HashProbe(int ply, int &depth, int &type, int &threat, int &val, int &move) {
hash_entry *ph;
ph = hash_table + (key_1 & hash_mask);
if (ph->key1 == key_1) {
move = hget_move(ph->data);
type = hget_type(ph->data);
threat = hget_threat(ph->data);
val = hget_val(ph->data);
if (val > DEAD) val -= ply;
else if (val < -DEAD) val += ply;
depth = hget_depth(ph->data);
ph->data &= ~old_entry;
return TRUE;
}
ph++;
if (ph->key1 == key_1) {
move = hget_move(ph->data);
type = hget_type(ph->data);
threat = hget_threat(ph->data);
val = hget_val(ph->data);
if (val > DEAD) val -= ply;
else if (val < -DEAD) val += ply;
depth = hget_depth(ph->data);
ph->data &= ~old_entry;
return TRUE;
}
return FALSE;
}
esacosta wrote:Many thanks to Dan Honeycutt:
My keys are good, I store and probe good, but some times on equal depth the value is diferent because alpha and beta are diferent, what could I do?.
Dan Honeycutt wrote:
(2) When you store and probe you MUST get back exactly what you put in. This is simple in concept but errors can easily creep in.
(3) If you use the hash to cut your logic to handle the bounds, remaining depth and so on must be correct.
Return to Winboard and related Topics
Users browsing this forum: No registered users and 34 guests