-
Notifications
You must be signed in to change notification settings - Fork 1
/
hash.cpp
42 lines (32 loc) · 1.01 KB
/
hash.cpp
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
#include "hash.h"
u64 getRandomU64()
{
return (((u64) random()) << 40) ^
(((u64) random()) << 20) ^
((u64) random() );
}
//---------------------------------------------------------------------
// section ThirdRep
//---------------------------------------------------------------------
void ThirdRep::update(u64 key, uint playerIndex)
{
int positionVisited = 0;
bool found;
found = loadItem(key, playerIndex, positionVisited);
assert(!found || positionVisited < 2);
insertItem(key, playerIndex, ++positionVisited);
}
//---------------------------------------------------------------------
bool ThirdRep::isThirdRep(u64 key, uint playerIndex)
{
int positionVisited = 0;
bool found;
found = loadItem(key, playerIndex, positionVisited);
if (!found || positionVisited < 2){
return false;
}
return true;
}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
ThirdRep thirdRep;