-
Notifications
You must be signed in to change notification settings - Fork 4
/
hash.h
148 lines (99 loc) · 2.98 KB
/
hash.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
File: hash.h
Created: June 29, 1997
Modified: October 25, 2005
Author: Gunnar Andersson (gunnar@radagast.se)
Toshihiko Okuhara
Contents: Routines manipulating the hash table
*/
#ifndef HASH_H
#define HASH_H
#include "constant.h"
#include "macros.h"
#ifdef __cplusplus
extern "C" {
#endif
#define LOWER_BOUND 1
#define UPPER_BOUND 2
#define EXACT_VALUE 4
#define MIDGAME_SCORE 8
#define ENDGAME_SCORE 16
#define SELECTIVE 32
#define ENDGAME_MODE TRUE
#define MIDGAME_MODE FALSE
#define NO_HASH_MOVE 0
/* The structure returned when a hash probe resulted in a hit.
DRAFT is the depth of the subtree beneath the node and FLAGS
contains a flag mask (see the flag bits above). */
typedef struct {
unsigned int key1, key2;
int eval;
int move[4];
short draft;
short selectivity;
short flags;
} HashEntry;
/* The number of entries in the hash table. Always a power of 2. */
extern int hash_size;
/* The 64-bit hash key. */
extern unsigned int hash1;
extern unsigned int hash2;
/* The 64-bit hash masks for a piece of a certain color in a
certain position. */
extern unsigned int hash_value1[3][128];
extern unsigned int hash_value2[3][128];
/* 64-bit hash masks used when a disc is played on the board;
the relation
hash_put_value?[][] == hash_value?[][] ^ hash_flip_color?
is guaranteed to hold. */
extern unsigned int hash_put_value1[3][128];
extern unsigned int hash_put_value2[3][128];
/* XORs of hash_value* - used for disk flipping. */
extern unsigned int hash_flip1[128];
extern unsigned int hash_flip2[128];
/* 64-bit hash mask for the two different sides to move. */
extern unsigned int hash_color1[3];
extern unsigned int hash_color2[3];
/* The XOR of the hash_color*, used for disk flipping. */
extern unsigned int hash_flip_color1;
extern unsigned int hash_flip_color2;
/* Stored 64-bit hash mask which hold the hash codes at different nodes
in the search tree. */
extern unsigned int hash_stored1[MAX_SEARCH_DEPTH];
extern unsigned int hash_stored2[MAX_SEARCH_DEPTH];
void
init_hash( int in_hash_bits );
void
resize_hash( int new_hash_bits );
void
setup_hash( int clear );
void
clear_hash_drafts( void );
void
free_hash( void );
void
determine_hash_values( int side_to_move,
const int *board );
void
set_hash_transformation( unsigned int trans1,
unsigned int trans2 );
void
add_hash( int reverse_mode,
int score,
int best,
int flags,
int draft,
int selectivity );
void
add_hash_extended( int reverse_mode,
int score,
int *best,
int flags,
int draft,
int selectivity );
void REGPARM(2)
find_hash( HashEntry *entry, int reverse_mode );
#ifdef __cplusplus
}
#endif
#endif /* HASH_H */