My Project
checkDuplicate.cc
Go to the documentation of this file.
3#include <boost/format.hpp>
4#include <iostream>
5
6std::pair<osl::HashKey,osl::PathEncoding> osl::record::
7CheckDuplicate::getLastState(const std::vector<Move>& moves)
8{
9 NumEffectState state;
10 PathEncoding path(BLACK);
11
12 for (Move move: moves) {
13 state.makeMove(move);
14 path.pushMove(move);
15 assert(state.isConsistent(true));
16 }
17 return std::make_pair(HashKey(state), path);
18}
19
21CheckDuplicate::regist(const std::vector<Move>& moves)
22{
23 const std::pair<HashKey, PathEncoding> pair = getLastState(moves);
24 return regist(pair.first, pair.second);
25}
26
29 const PathEncoding& moves)
30{
31 ++regist_counter;
32
33 std::vector<PathEncoding>& rs = keys[key];
34 if (rs.empty())
35 {
36 // not found. i.e. a new key
37 rs.push_back(moves);
38 return NO_DUPLICATE;
39 }
40 else
41 {
42 if (std::find(rs.begin(), rs.end(), moves)
43 == rs.end())
44 {
45 // new moves
46 ++duplicated_hash_counter;
47 rs.push_back(moves);
48 return HASH_DUPLICATE;
49 }
50 else
51 {
52 // hit
53 ++duplicated_moves_counter;
54 return MOVES_DUPLICATE;
55 }
56 }
57}
58
60CheckDuplicate::print(std::ostream& out) const
61{
62 out << boost::format("Trials %d, Unique %d, Duplicates Hash %d, Duplicated moves %d\n")
63 % regist_counter
64 % keys.size()
65 % duplicated_hash_counter
66 % duplicated_moves_counter;
67}
68
69// ;;; Local Variables:
70// ;;; mode:c++
71// ;;; c-basic-offset:2
72// ;;; End:
圧縮していない moveの表現 .
利きを持つ局面
void makeMove(Move move)
bool isConsistent(bool showError=true) const
void pushMove(Move m)
DUPLICATE_RESULT
Result type of checking duplicates.
static std::pair< HashKey, PathEncoding > getLastState(const std::vector< Move > &moves)
DUPLICATE_RESULT regist(const std::vector< Move > &moves)
Insert a key if the key is new.
void print(std::ostream &out) const
Output the result.
@ BLACK
Definition basic_type.h:9