PlanExecutor::YieldPolicy ParsedDelete::yieldPolicy() const { if (_request->isGod()) { return PlanExecutor::YIELD_MANUAL; } if (_request->getYieldPolicy() == PlanExecutor::YIELD_AUTO && isIsolated()) { return PlanExecutor::WRITE_CONFLICT_RETRY_ONLY; // Don't yield locks. } return _request->getYieldPolicy(); }
bool TopPairMuPlusJetsReferenceSelection2011::hasExactlyOneIsolatedLepton(const EventPtr event) const { unsigned int nIsolatedGoodMuons(0); const MuonCollection allMuons(event->Muons()); for (unsigned int index = 0; index < allMuons.size(); ++index) { const MuonPointer muon(allMuons.at(index)); if (isGoodMuon(muon) && isIsolated(muon)) ++nIsolatedGoodMuons; } return nIsolatedGoodMuons == 1; }
void testRateBoard(TBlock*board, const TPos p1 = 0, const TPos p2 = 120){ if (isIsolated(board, p1, p2)) return; #ifdef OPENCV while (true){ imshow("test", toImage(board)); int c = waitKey(10); // if (c == ' ') break; } #endif // OPENCV CHeuristicBase::simpleRateBoard(board, p1, p2, PLAYER_1); }
bool QCDPFRelIsoEPlusJetsSelection::hasExactlyOneIsolatedLepton(const EventPtr event) const { const ElectronCollection allElectrons(event->Electrons()); unsigned int nGoodElectrons(0), nGoodIsolatedElectrons(0); for (unsigned int index = 0; index < allElectrons.size(); ++index) { const ElectronPointer electron(allElectrons.at(index)); if (isGoodElectron(electron)) { ++nGoodElectrons; if (isIsolated(electron)) ++nGoodIsolatedElectrons; } } return nGoodElectrons > 0 && nGoodIsolatedElectrons < 2; }
void testSearchEngine(TBlock*board, const TPos p1 = 0, const TPos p2 = 120){ if (isIsolated(board, p1, p2)) return; pAI->searcher.heuristic.rateBoard = CHeuristicBase::simpleRateBoard; pAI->searcher.heuristic.quickRateBoard = CHeuristicBase::voronoiRateBoard; int ab, abtt, nega; int depth = 6; CMyTimer::getInstance()->reset(); // cout << "\tab :" << (ab = pAI->searcher.alphaBeta(board, p1, p2, PLAYER_1, depth, -MY_INFINITY, +MY_INFINITY)) << endl; CMyTimer::getInstance()->reset(); //cout << "\tabtt:" << (abtt = pAI->searcher.alphaBetaTT(board, p1, p2, PLAYER_1, depth, -MY_INFINITY, +MY_INFINITY)) << endl; CMyTimer::getInstance()->reset(); //cout << "\tnega:" << (nega = pAI->searcher.negaMaxTT(board, p1, p2, PLAYER_1, depth, -MY_INFINITY, +MY_INFINITY)) << endl; CTranspositionTable::getInstance()->printStatic(); cout << endl; #ifdef OPENCV while (true){ // imshow("test", toImage(board)); int c = waitKey(1); // if (c == ' ') break; } #endif // OPENCV // assert(ab == abtt); assert(abtt == nega); if (ab == abtt && ab == nega) { cout << "good\n"; good++; } else { cout << "bad!\n"; // system("pause"); bad++; } }
TMove CMyAI::enemyNewTurn() { assert(inEnemyTurn); TMove result; static CMyTimer *timer = CMyTimer::getInstance(); if (activeIsolatedMode || isIsolated(this->boardData, this->p1, this->p2)){ activeIsolatedMode = true; TPos pos; pos = CC(p_ai->GetEnemyPosition().x, p_ai->GetEnemyPosition().y); result = 0; } else { int before = history.size(); result = searcher.optimalMove(boardData, p1, p2, next, history).first; assert(history.size() == before); } return result; }
const LeptonPointer TopPairMuPlusJetsReferenceSelection2011::signalLepton(const EventPtr event) const { if (!hasExactlyOneIsolatedLepton(event)) { cerr << "An error occurred in SignalSelection in event (no = " << event->eventnumber(); cerr << ", run = " << event->runnumber() << ", lumi = " << event->lumiblock() << "!" << endl; cerr << "File = " << event->file() << endl; cerr << "Access exception: No signal lepton could be found. Event doesn't pass 'hasExactlyOneIsolatedLepton' selection" << endl; throw "Access exception: No signal lepton could be found. Event doesn't pass 'hasExactlyOneIsolatedLepton' selection"; } const MuonCollection allMuons(event->Muons()); MuonCollection goodIsolatedMuons; for (unsigned int index = 0; index < allMuons.size(); ++index) { const MuonPointer muon(allMuons.at(index)); if (isGoodMuon(muon) && isIsolated(muon)) goodIsolatedMuons.push_back(muon); } return goodIsolatedMuons.front(); }
void LineBoxList::dirtyLinesFromChangedChild(LayoutObject* container, LayoutObject* child) { if (!container->parent() || (container->isLayoutBlock() && (container->selfNeedsLayout() || !container->isLayoutBlockFlow()))) return; LayoutInline* inlineContainer = container->isLayoutInline() ? toLayoutInline(container) : 0; InlineBox* firstBox = inlineContainer ? inlineContainer->firstLineBoxIncludingCulling() : firstLineBox(); // If we have no first line box, then just bail early. if (!firstBox) { // For an empty inline, go ahead and propagate the check up to our parent, unless the parent // is already dirty. if (container->isInline() && !container->ancestorLineBoxDirty()) { container->parent()->dirtyLinesFromChangedChild(container); container->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree. } return; } // Try to figure out which line box we belong in. First try to find a previous // line box by examining our siblings. If we didn't find a line box, then use our // parent's first line box. RootInlineBox* box = 0; LayoutObject* curr = 0; ListHashSet<LayoutObject*, 16> potentialLineBreakObjects; potentialLineBreakObjects.add(child); for (curr = child->previousSibling(); curr; curr = curr->previousSibling()) { potentialLineBreakObjects.add(curr); if (curr->isFloatingOrOutOfFlowPositioned()) continue; if (curr->isReplaced()) { InlineBox* wrapper = toLayoutBox(curr)->inlineBoxWrapper(); if (wrapper) box = &wrapper->root(); } else if (curr->isText()) { InlineTextBox* textBox = toLayoutText(curr)->lastTextBox(); if (textBox) box = &textBox->root(); } else if (curr->isLayoutInline()) { InlineBox* lastSiblingBox = toLayoutInline(curr)->lastLineBoxIncludingCulling(); if (lastSiblingBox) box = &lastSiblingBox->root(); } if (box) break; } if (!box) { if (inlineContainer && !inlineContainer->alwaysCreateLineBoxes()) { // https://bugs.webkit.org/show_bug.cgi?id=60778 // We may have just removed a <br> with no line box that was our first child. In this case // we won't find a previous sibling, but firstBox can be pointing to a following sibling. // This isn't good enough, since we won't locate the root line box that encloses the removed // <br>. We have to just over-invalidate a bit and go up to our parent. if (!inlineContainer->ancestorLineBoxDirty()) { inlineContainer->parent()->dirtyLinesFromChangedChild(inlineContainer); inlineContainer->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree. } return; } box = &firstBox->root(); } // If we found a line box, then dirty it. if (box) { RootInlineBox* adjacentBox; box->markDirty(); // dirty the adjacent lines that might be affected // NOTE: we dirty the previous line because RootInlineBox objects cache // the address of the first object on the next line after a BR, which we may be // invalidating here. For more info, see how LayoutBlock::layoutInlineChildren // calls setLineBreakInfo with the result of findNextLineBreak. findNextLineBreak, // despite the name, actually returns the first LayoutObject after the BR. // <rdar://problem/3849947> "Typing after pasting line does not appear until after window resize." adjacentBox = box->prevRootBox(); if (adjacentBox) adjacentBox->markDirty(); adjacentBox = box->nextRootBox(); // If |child| or any of its immediately previous siblings with culled lineboxes is the object after a line-break in |box| or the linebox after it // then that means |child| actually sits on the linebox after |box| (or is its line-break object) and so we need to dirty it as well. if (adjacentBox && (potentialLineBreakObjects.contains(box->lineBreakObj()) || potentialLineBreakObjects.contains(adjacentBox->lineBreakObj()) || child->isBR() || isIsolated(container->style()->unicodeBidi()))) adjacentBox->markDirty(); } }
bool ParsedUpdate::canYield() const { return !_request->isGod() && PlanExecutor::YIELD_AUTO == _request->getYieldPolicy() && !isIsolated(); }
TMove CMyAI::ourNewTurn() { assert(!inEnemyTurn); TMove result; static CMyTimer *timer = CMyTimer::getInstance(); if (activeIsolatedMode || isIsolated(this->boardData, this->p1, this->p2)){ activeIsolatedMode = true; cout << "Isolated mode!" << endl; TPos p1, p2; p1 = CC(p_ai->GetMyPosition().x, p_ai->GetMyPosition().y); p2 = CC(p_ai->GetEnemyPosition().x, p_ai->GetEnemyPosition().y); static CBCO o1, o2; CBC::calculateBCs(this->boardData, &o1, p1); CBC::calculateBCs(this->boardData, &o2, p2); int n1, n2; n1 = o1.findLengthOfLongestPath(EXACT_AREA_BELOW_10); n2 = o2.findLengthOfLongestPath(EXACT_AREA_BELOW_10); if (abs(n1 - n2) < 4) { int _n1 = o1.findLengthOfLongestPath(EXACT); if (_n1 != TIMEOUT_POINTS) { n1 = _n1; int _n2 = o2.findLengthOfLongestPath(EXACT); if (_n2 != TIMEOUT_POINTS) n2 = _n2; } } cout << "\tEstimated length of our path " << n1 << endl; cout << "\tEstimated length of enemy path " << n2 << endl; if (n1 > n2) cout << "\t => It seems that we will f*****g WIN "; else cout << "\t => It seems that we will f*****g LOSE "; if (first == we) cout << "this easy game " << n1 - n2 << endl; else cout << "this hard game " << n1 - n2 << endl; p1 = CC(p_ai->GetMyPosition().x, p_ai->GetMyPosition().y); TMove estimateMove = CHeuristicBase::getFirstMove(boardData, p1, EXACT_AREA_BELOW_25, n1); TMove exactMove = CHeuristicBase::getFirstMove(boardData, p1, EXACT, n1); if (exactMove < 1 || exactMove > 4) result = estimateMove; else result = exactMove; result = estimateMove; } else { static bool followingMode = TRY_FOLLOWING && we != first; if (followingMode){ TPos u = MOVE(we == PLAYER_1 ? p1 : p2, getOpositeDirection(history.back())) != BLOCK_EMPTY; if (GET_BLOCK(boardData, u)) followingMode = false; } if (followingMode) { assert(history.size() % 2 == 1); for (unsigned int i = 0; i < history.size() - 1; i = i + 2){ if (history[i] != getOpositeDirection(history[i + 1])) { followingMode = false; break; } } } else{ followingMode = false; } pair<TMove, int> re = searcher.optimalMove(boardData, p1, p2, next, history); if (we == PLAYER_2) re.second = -re.second; if (!followingMode || re.first == getOpositeDirection(history.back())) { result = re.first; } else { if (re.second >= 0) result = re.first; else { result = getOpositeDirection(history.back()); cout << "\t===FOLLOWING ENEMY===\n"; } } } cout << "We take " << timer->getTimeInMs() << " ms\n"; return result; }
void RenderLineBoxList::dirtyLinesFromChangedChild(RenderBoxModelObject* container, RenderObject* child) { ASSERT(container->isRenderInline() || container->isRenderBlockFlow()); if (!container->parent() || (container->isRenderBlockFlow() && container->selfNeedsLayout())) return; RenderInline* inlineContainer = container->isRenderInline() ? toRenderInline(container) : 0; InlineBox* firstBox = inlineContainer ? inlineContainer->firstLineBoxIncludingCulling() : firstLineBox(); // If we have no first line box, then just bail early. if (!firstBox) { // For an empty inline, go ahead and propagate the check up to our parent, unless the parent // is already dirty. if (container->isInline() && !container->ancestorLineBoxDirty()) { container->parent()->dirtyLinesFromChangedChild(container); container->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree. } return; } // Try to figure out which line box we belong in. First try to find a previous // line box by examining our siblings. If we didn't find a line box, then use our // parent's first line box. RootInlineBox* box = nullptr; RenderObject* current; for (current = child->previousSibling(); current; current = current->previousSibling()) { if (current->isFloatingOrOutOfFlowPositioned()) continue; if (current->isReplaced()) { if (auto wrapper = downcast<RenderBox>(*current).inlineBoxWrapper()) box = &wrapper->root(); } if (is<RenderLineBreak>(*current)) { if (auto wrapper = downcast<RenderLineBreak>(*current).inlineBoxWrapper()) box = &wrapper->root(); } else if (is<RenderText>(*current)) { if (InlineTextBox* textBox = downcast<RenderText>(*current).lastTextBox()) box = &textBox->root(); } else if (is<RenderInline>(*current)) { InlineBox* lastSiblingBox = downcast<RenderInline>(*current).lastLineBoxIncludingCulling(); if (lastSiblingBox) box = &lastSiblingBox->root(); } if (box) break; } if (!box) { if (inlineContainer && !inlineContainer->alwaysCreateLineBoxes()) { // https://bugs.webkit.org/show_bug.cgi?id=60778 // We may have just removed a <br> with no line box that was our first child. In this case // we won't find a previous sibling, but firstBox can be pointing to a following sibling. // This isn't good enough, since we won't locate the root line box that encloses the removed // <br>. We have to just over-invalidate a bit and go up to our parent. if (!inlineContainer->ancestorLineBoxDirty()) { inlineContainer->parent()->dirtyLinesFromChangedChild(inlineContainer); inlineContainer->setAncestorLineBoxDirty(); // Mark the container to avoid dirtying the same lines again across multiple destroy() calls of the same subtree. } return; } box = &firstBox->root(); } // If we found a line box, then dirty it. if (box) { RootInlineBox* adjacentBox; box->markDirty(); // dirty the adjacent lines that might be affected // NOTE: we dirty the previous line because RootInlineBox objects cache // the address of the first object on the next line after a BR, which we may be // invalidating here. For more info, see how RenderBlock::layoutInlineChildren // calls setLineBreakInfo with the result of findNextLineBreak. findNextLineBreak, // despite the name, actually returns the first RenderObject after the BR. // <rdar://problem/3849947> "Typing after pasting line does not appear until after window resize." adjacentBox = box->prevRootBox(); if (adjacentBox) adjacentBox->markDirty(); adjacentBox = box->nextRootBox(); // If |child| has been inserted before the first element in the linebox, but after collapsed leading // space, the search for |child|'s linebox will go past the leading space to the previous linebox and select that // one as |box|. If we hit that situation here, dirty the |box| actually containing the child too. bool insertedAfterLeadingSpace = box->lineBreakObj() == child->previousSibling(); if (adjacentBox && (adjacentBox->lineBreakObj() == child || child->isBR() || (current && current->isBR()) || insertedAfterLeadingSpace || isIsolated(container->style().unicodeBidi()))) adjacentBox->markDirty(); } }