bool nsCSSCompressedDataBlock::TryReplaceValue(nsCSSProperty aProperty, nsCSSExpandedDataBlock& aFromBlock, bool *aChanged) { nsCSSValue* newValue = aFromBlock.PropertyAt(aProperty); NS_ABORT_IF_FALSE(newValue && newValue->GetUnit() != eCSSUnit_Null, "cannot replace with empty value"); const nsCSSValue* oldValue = ValueFor(aProperty); if (!oldValue) { *aChanged = false; return false; } *aChanged = MoveValue(newValue, const_cast<nsCSSValue*>(oldValue)); aFromBlock.ClearPropertyBit(aProperty); return true; }
void GoUctFeatureKnowledge:: ComputeMinAndMaxValues(const std::vector<SgUctMoveInfo>& moves, float& smallest, float& largest) const { // We cannot just take the min and max over the whole eval array // since it contains illegal moves with value 0, which may be smaller // (or larger) than the true min/max. smallest = std::numeric_limits<float>::max(); largest = -std::numeric_limits<float>::max(); for (std::vector<SgUctMoveInfo>::const_iterator it = moves.begin(); it != moves.end(); ++it) { const SgPoint move = it->m_move; const float moveValue = MoveValue(move); smallest = std::min(smallest, moveValue); largest = std::max(largest, moveValue); } }
void GoUctFeatureKnowledge:: SetPriorsTopN(std::vector<SgUctMoveInfo>& moves) { const int N = std::min(m_param.m_topN, static_cast<int>(moves.size())); std::vector<EvalPair> sorted; for (std::vector<SgUctMoveInfo>::iterator it = moves.begin(); it != moves.end(); ++it) { const SgPoint move = it->m_move; sorted.push_back(std::make_pair(move, MoveValue(move))); } std::sort(sorted.begin(), sorted.end(), CompareValue); for (int i=0; i < N; ++i) { Add(sorted[i].first, 1.0, m_param.m_priorKnowledgeWeight); //SgDebug() << "Good move: " << SgWritePoint(sorted[i].first) //<< " Eval = " << sorted[i].second << '\n'; } }