-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLargeTileFeature.cpp
45 lines (37 loc) · 1014 Bytes
/
LargeTileFeature.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
43
#include "LargeTileFeature.h"
LargeTileFeature::LargeTileFeature(double weight):
TileTuple(weight)
{
score_table_ = new double[1024]; // 32k ~ 2k, 0~3 tiles
memset(score_table_, 0, sizeof(double) * 1024);
}
LargeTileFeature::~LargeTileFeature()
{
delete[] score_table_;
}
board_t LargeTileFeature::get_index(const board_t& game_board) const
{
static int shift_pos[5] = {0, 2, 4, 6, 8};
int index = 0;
int count = 0;
int tile = 0;
for(board_t mask = 0xf;mask != 0;mask <<= 4) {
if((tile = (game_board & mask) >> count) >= 11)
index += 0x1ull << shift_pos[tile - 11];
count += 4;
}
return index;
}
int LargeTileFeature::get_isomorphic_indexes(const board_t& original_index, board_t* isomorphic_indexes) const
{
isomorphic_indexes[0] = original_index;
return 1;
}
void LargeTileFeature::save_tuple(ofstream& fout) const
{
fout.write((char*)score_table_, sizeof(double) * 1024);
}
void LargeTileFeature::load_tuple(ifstream& fin)
{
fin.read((char*)score_table_, sizeof(double) * 1024);
}