本文整理汇总了C++中GoBoard::GetHashCodeInclToPlay方法的典型用法代码示例。如果您正苦于以下问题:C++ GoBoard::GetHashCodeInclToPlay方法的具体用法?C++ GoBoard::GetHashCodeInclToPlay怎么用?C++ GoBoard::GetHashCodeInclToPlay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GoBoard
的用法示例。
在下文中一共展示了GoBoard::GetHashCodeInclToPlay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertEntry
/** Insert a new position entry and all its transformations
@param sequence A move sequence that leads to the position
@param moves The moves to play in this position
@param size
@param tempBoard A local temporary work board, reused for efficiency
(does not have to be initialized)
@param line Line number of entry from the file (0 if unknown or entry is
not from a file) */
void GoBook::InsertEntry(const vector<SgPoint>& sequence,
const vector<SgPoint>& moves, int size,
GoBoard& tempBoard, int line)
{
if (moves.size() == 0)
ThrowError("Line contains no moves");
if (tempBoard.Size() != size)
tempBoard.Init(size);
Entry entry;
entry.m_size = size;
entry.m_line = line;
entry.m_sequence = sequence;
entry.m_moves = moves;
m_entries.push_back(entry);
size_t id = m_entries.size() - 1;
vector<Map::iterator> newEntries;
for (int rot = 0; rot < 8; ++rot)
{
GoBoardUtil::UndoAll(tempBoard);
for (vector<SgPoint>::const_iterator it = sequence.begin();
it != sequence.end(); ++it)
{
SgPoint p = SgPointUtil::Rotate(rot, *it, size);
if (! tempBoard.IsLegal(p))
ThrowError("Illegal move in variation");
tempBoard.Play(p);
}
// It is enough to check the moves for legality for one rotation
if (rot == 0)
for (vector<SgPoint>::const_iterator it = moves.begin();
it != moves.end(); ++it)
if (! tempBoard.IsLegal(SgPointUtil::Rotate(rot, *it, size)))
ThrowError("Illegal move in move list");
MapEntry mapEntry;
mapEntry.m_size = size;
mapEntry.m_id = id;
mapEntry.m_rotation = rot;
SgHashCode hashCode = tempBoard.GetHashCodeInclToPlay();
pair<Map::iterator,Map::iterator> e = m_map.equal_range(hashCode);
bool isInNewEntries = false;
for (Map::iterator it = e.first; it != e.second; ++it)
if (it->second.m_size == size)
{
if (! Contains(newEntries, it))
{
ostringstream o;
o << "Entry duplicates line "
<< m_entries[it->second.m_id].m_line;
ThrowError(o.str());
}
isInNewEntries = true;
break;
}
if (! isInNewEntries)
{
Map::iterator newIt =
m_map.insert(Map::value_type(hashCode, mapEntry));
newEntries.push_back(newIt);
}
}
}