hash.h
Go to the documentation of this file.
1 
11 #ifndef EDAX_HASH_H
12 #define EDAX_HASH_H
13 
14 #include "board.h"
15 #include "settings.h"
16 #include "util.h"
17 #include "stats.h"
18 
19 
20 #include <stdbool.h>
21 #include <stdio.h>
22 
24 typedef struct HashData {
25  unsigned char depth;
26  unsigned char selectivity;
27  unsigned char cost;
28  unsigned char date;
29  signed char lower;
30  signed char upper;
31  unsigned char move[2];
32 } HashData;
33 
35 typedef struct Hash {
36  HASH_COLLISIONS(unsigned long long key;)
39 } Hash;
40 
42 typedef struct HashLock {
43  SpinLock spin;
44 } HashLock;
45 
47 typedef struct HashTable {
48  void *memory;
51  unsigned long long hash_mask;
52  unsigned int lock_mask;
53  int n_hash;
54  int n_lock;
55  unsigned char date;
56 } HashTable;
57 
58 /* declaration */
59 void hash_code_init(void);
60 void hash_move_init(void);
61 void hash_init(HashTable*, const unsigned long long);
62 void hash_cleanup(HashTable*);
63 void hash_clear(HashTable*);
64 void hash_free(HashTable*);
65 void hash_store(HashTable*, const Board*, const unsigned long long, const int, const int, const int, const int, const int, const int, const int);
66 void hash_force(HashTable*, const Board*, const unsigned long long, const int, const int, const int, const int, const int, const int, const int);
67 bool hash_get(HashTable*, const Board*, const unsigned long long, HashData *);
68 void hash_copy(const HashTable*, HashTable*);
69 void hash_print(const HashData*, FILE*);
70 void hash_feed(HashTable*, const Board*, const unsigned long long, const int, const int, const int, const int, const int);
71 void hash_exclude_move(HashTable*, const Board*, const unsigned long long, const int);
72 extern unsigned int writeable_level(HashData *data);
73 
74 extern const HashData HASH_DATA_INIT;
75 extern unsigned long long hash_rank[16][256];
76 extern unsigned long long hash_move[64][60];
77 
78 #endif
79 
void hash_exclude_move(HashTable *, const Board *, const unsigned long long, const int)
HashData data
Definition: hash.h:38
Definition: hash.h:47
unsigned int writeable_level(HashData *data)
make a level from date, cost, depth & selectivity.
Definition: hash-lock-free.c:208
void hash_print(const HashData *, FILE *)
print HashData content.
Definition: hash-lock-free.c:670
Definition: hash.h:35
Hash * hash
Definition: hash.h:49
signed char upper
Definition: hash.h:30
void * memory
Definition: hash.h:48
signed char lower
Definition: hash.h:29
void hash_init(HashTable *, const unsigned long long)
Initialise the hashtable.
Definition: hash.c:86
Definition: board.h:26
Statistics header.
unsigned long long hash_mask
Definition: hash.h:51
unsigned char selectivity
Definition: hash.h:26
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.
Definition: hash.c:583
unsigned long long hash_rank[16][256]
Definition: hash-lock-free.c:41
Board board
Definition: hash.h:37
bool hash_get(HashTable *, const Board *, const unsigned long long, HashData *)
Find an hash table entry according to the evaluated board hash codes.
Definition: hash.c:616
struct HashLock HashLock
Definition: hash.h:42
int n_hash
Definition: hash.h:53
Miscellaneous utilities header.
struct HashData HashData
unsigned int lock_mask
Definition: hash.h:52
void hash_clear(HashTable *)
Clear the hashtable.
Definition: hash-lock-free.c:179
Definition: hash.h:24
unsigned char date
Definition: hash.h:28
unsigned char cost
Definition: hash.h:27
unsigned long long hash_move[64][60]
Definition: hash-lock-free.c:44
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.
Definition: hash.c:544
void hash_free(HashTable *)
Free the hashtable.
Definition: hash-lock-free.c:195
unsigned char depth
Definition: hash.h:25
void hash_copy(const HashTable *, HashTable *)
Copy an hastable to another one.
Definition: hash-lock-free.c:652
SpinLock spin
Definition: hash.h:43
int n_lock
Definition: hash.h:54
unsigned char move[2]
Definition: hash.h:31
HashLock * lock
Definition: hash.h:50
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).
Definition: hash.c:489
void hash_move_init(void)
Initialize global hash move data.
Definition: hash-lock-free.c:70
void hash_cleanup(HashTable *)
Clear the hashtable.
Definition: hash-lock-free.c:159
unsigned char date
Definition: hash.h:55
const HashData HASH_DATA_INIT
Definition: hash-lock-free.c:47
#define HASH_COLLISIONS(x)
Definition: stats.h:25
struct Hash Hash
struct HashTable HashTable
void hash_code_init(void)
Initialize global hash code data.
Definition: hash-lock-free.c:52