Classes | Typedefs | Functions | Variables
hash.h File Reference
#include "board.h"
#include "settings.h"
#include "util.h"
#include "stats.h"
#include <stdbool.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  HashData
 
struct  Hash
 
struct  HashLock
 
struct  HashTable
 

Typedefs

typedef struct HashData HashData
 
typedef struct Hash Hash
 
typedef struct HashLock HashLock
 
typedef struct HashTable HashTable
 

Functions

void hash_code_init (void)
 Initialize global hash code data. More...
 
void hash_move_init (void)
 Initialize global hash move data. More...
 
void hash_init (HashTable *, const unsigned long long)
 Initialise the hashtable. More...
 
void hash_cleanup (HashTable *)
 Clear the hashtable. More...
 
void hash_clear (HashTable *)
 Clear the hashtable. More...
 
void hash_free (HashTable *)
 Free the hashtable. More...
 
void hash_store (HashTable *, const Board *, const unsigned long long, const int, const int, const int, const int, const int, const int, const int)
 Store an hashtable item. More...
 
void hash_force (HashTable *, const Board *, const unsigned long long, const int, const int, const int, const int, const int, const int, const int)
 Store an hashtable item. More...
 
bool hash_get (HashTable *, const Board *, const unsigned long long, HashData *)
 Find an hash table entry according to the evaluated board hash codes. More...
 
void hash_copy (const HashTable *, HashTable *)
 Copy an hastable to another one. More...
 
void hash_print (const HashData *, FILE *)
 print HashData content. More...
 
void hash_feed (HashTable *, const Board *, const unsigned long long, const int, const int, const int, const int, const int)
 feed hash table (from Cassio). More...
 
void hash_exclude_move (HashTable *, const Board *, const unsigned long long, const int)
 
unsigned int writeable_level (HashData *data)
 make a level from date, cost, depth & selectivity. More...
 

Variables

const HashData HASH_DATA_INIT
 
unsigned long long hash_rank [16][256]
 
unsigned long long hash_move [64][60]
 

Detailed Description

Hash table's header.

Date
1998 - 2017
Author
Richard Delorme
Version
4.4

Typedef Documentation

◆ Hash

typedef struct Hash Hash

Hash : item stored in the hash table

◆ HashData

typedef struct HashData HashData

HashData : data stored in the hash table

◆ HashLock

typedef struct HashLock HashLock

HashLock : lock for table entries

◆ HashTable

typedef struct HashTable HashTable

HashTable: position storage

Function Documentation

◆ hash_cleanup()

void hash_cleanup ( HashTable hash_table)

Clear the hashtable.

Set all hash table entries to zero.

Parameters
hash_tableHash table to clear.

◆ hash_clear()

void hash_clear ( HashTable hash_table)

Clear the hashtable.

Change the date of the hash table.

Parameters
hash_tableHash table to clear.

◆ hash_code_init()

void hash_code_init ( void  )

Initialize global hash code data.

◆ hash_copy()

void hash_copy ( const HashTable src,
HashTable dest 
)

Copy an hastable to another one.

Parameters
srcSource hash table to copy.
destDestination hash table.

◆ hash_exclude_move()

void hash_exclude_move ( HashTable ,
const Board ,
const unsigned long  long,
const int   
)

◆ hash_feed()

void hash_feed ( HashTable hash_table,
const Board board,
const unsigned long long  hash_code,
const int  depth,
const int  selectivity,
const int  lower,
const int  upper,
const int  move 
)

feed hash table (from Cassio).

Parameters
hash_tableHash Table.
hash_codeHash code.
depthSearch depth.
selectivitySelectivity level.
lowerAlpha bound.
upperBeta bound.
movebest move.

◆ hash_force()

void hash_force ( HashTable hash_table,
const Board board,
const unsigned long long  hash_code,
const int  depth,
const int  selectivity,
const int  cost,
const int  alpha,
const int  beta,
const int  score,
const int  move 
)

Store an hashtable item.

Does the same as hash_store() except it always store the current search state

Parameters
hash_tableHash table to update.
hash_codeHash code of an othello board.
alphaAlpha bound when calling the alphabeta function.
depthSearch depth.
selectivitySearch selectivity.
costSearch cost (i.e. log2(node count)).
betaBeta bound when calling the alphabeta function.
scoreBest score found.
moveBest move found.

◆ hash_free()

void hash_free ( HashTable hash_table)

Free the hashtable.

Free the memory allocated by the hash table entries

Parameters
hash_tablehash_table to free.

◆ hash_get()

bool hash_get ( HashTable hash_table,
const Board board,
const unsigned long long  hash_code,
HashData data 
)

Find an hash table entry according to the evaluated board hash codes.

Parameters
hash_tableHash table.
hash_codeHash code of an othello board.
dataOutput hash data.
Returns
True the board was found, false otherwise.

Erase an hash table entry.

Parameters
hash_tableHash table.
hash_codeHash code of an othello board.
moveMove to exclude.

Copy an hastable to another one.

Parameters
srcSource hash table to copy.
destDestination hash table.

print HashData content.

Parameters
dataHash Data
fOutput stream

◆ hash_init()

void hash_init ( HashTable hash_table,
const unsigned long long  size 
)

Initialise the hashtable.

Allocate the hash table entries and initialise the hash masks.

Parameters
hash_tableHash table to setup.
sizeRequested size for the hash table in number of entries.

◆ hash_move_init()

void hash_move_init ( void  )

Initialize global hash move data.

◆ hash_print()

void hash_print ( const HashData data,
FILE *  f 
)

print HashData content.

Parameters
dataHash Data
fOutput stream

◆ hash_store()

void hash_store ( HashTable hash_table,
const Board board,
const unsigned long long  hash_code,
const int  depth,
const int  selectivity,
const int  cost,
const int  alpha,
const int  beta,
const int  score,
const int  move 
)

Store an hashtable item.

Find an hash table entry according to the evaluated board hash codes. Then update the entry if it already exists otherwise create a new one. Collisions are managed in such a way that better existing entries are always preserved and the new evaluated data is always added. Lower and upper score bounds are then updated/set from the alpha, beta and score values according to the following alphabeta property (where alpha < beta): -if (score >= beta) score is a lower bound of the real score -if (score <= alpha) score is an upper bound of the real score -if (alpha < score && score < beta) score equals the real score So: -if (score < beta) update the upper bound of the hash entry -if (score > alpha) update the lower bound of the hash entry The best move is also stored, but only if score >= alpha. In case the entry already exists with better data, nothing is stored.

Parameters
hash_tableHash table to update.
hash_codeHash code of an othello board.
alphaAlpha bound when calling the alphabeta function.
depthSearch depth.
selectivitySearch selectivity.
costSearch cost (i.e. log2(node count)).
betaBeta bound when calling the alphabeta function.
scoreBest score found.
moveBest move found.

◆ writeable_level()

unsigned int writeable_level ( HashData data)
inline

make a level from date, cost, depth & selectivity.

Parameters
dataHash data.
Returns
A level.

Variable Documentation

◆ HASH_DATA_INIT

const HashData HASH_DATA_INIT

HashData init value

◆ hash_move

unsigned long long hash_move[64][60]

hashing global data

◆ hash_rank

unsigned long long hash_rank[16][256]

hashing global data