本文整理汇总了C++中Stopwatch::exceeded方法的典型用法代码示例。如果您正苦于以下问题:C++ Stopwatch::exceeded方法的具体用法?C++ Stopwatch::exceeded怎么用?C++ Stopwatch::exceeded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stopwatch
的用法示例。
在下文中一共展示了Stopwatch::exceeded方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: moves
//.........这里部分代码省略.........
const int zerothPrune = 33;
int plies = 2;
if (currentPosition().bag().size() <= QUACKLE_PARAMETERS->rackSize() * 2)
plies = -1;
const int initialCandidates = m_additionalInitialCandidates + nmoves;
currentPosition().kibitz(initialCandidates);
m_simulator.setIncludedMoves(m_simulator.currentPosition().moves());
m_simulator.pruneTo(zerothPrune, initialCandidates);
m_simulator.makeSureConsideredMovesAreIncluded();
m_simulator.setIgnoreOppos(false);
MoveList staticMoves = m_simulator.moves(/* prune */ true, /* sort by equity */ false);
m_simulator.moveConsideredMovesToBeginning(staticMoves);
//UVcout << "Bogo static moves: " << staticMoves << endl;
//UVcout << "Bogo considered moves: " << m_simulator.consideredMoves() << endl;
MoveList firstMove;
MoveList simmedMoves;
MoveList::const_iterator it = staticMoves.begin();
firstMove.push_back(*it);
signalFractionDone(0);
m_simulator.setIncludedMoves(firstMove);
m_simulator.simulate(plies, minIterations());
Move best = *m_simulator.moves(/* prune */ true, /* sort by win */ true).begin();
simmedMoves.push_back(best);
double bestbp = bogopoints(best);
//UVcout << "firstMove: " << best << endl;
for (++it; it != staticMoves.end(); ++it)
{
signalFractionDone(max(static_cast<float>(simmedMoves.size()) / static_cast<float>(staticMoves.size()), static_cast<float>(stopwatch.elapsed()) / static_cast<float>(m_parameters.secondsPerTurn)));
if (shouldAbort())
goto sort_and_return;
//UVcout << "best move: " << best << " with " << bestbp << " bogopoints." << endl;
MoveList lookFurther;
lookFurther.push_back(*it);
m_simulator.setIncludedMoves(lookFurther);
m_simulator.simulate(plies, minIterations());
Move move = *m_simulator.moves(/* prune */ true, /* sort by win */ true).begin();
double movebp = bogopoints(move);
//UVcout << "we just simmed " << move << "; bogopoints: " << movebp << endl;
if (movebp + 1.96 * 35.0 / sqrt((double)minIterations()) > bestbp)
{
m_simulator.simulate(plies, maxIterations() - minIterations());
Move move2 = *m_simulator.moves(true, true).begin();
movebp = bogopoints(move2);
//UVcout << "sim it some more: " << move2 << " bogopoints: " << movebp << endl;
simmedMoves.push_back(move2);
if (move2.win > best.win)
{
best = move2;
bestbp = movebp;
}
}
else
{
simmedMoves.push_back(move);
}
if (stopwatch.exceeded(m_parameters.secondsPerTurn))
{
//UVcout << "Bogowinplayer stopwatch exceeded its limit " << m_parameters.secondsPerTurn << ". Returning early." << endl;
goto sort_and_return;
}
}
//UVcout << "We had extra time! whoopee!" << endl;
sort_and_return:
MoveList::sort(simmedMoves, MoveList::Win);
MoveList ret;
MoveList::const_iterator simmedEnd = simmedMoves.end();
int i = 0;
for (MoveList::const_iterator simmedIt = simmedMoves.begin();
(simmedIt != simmedEnd); ++i, ++simmedIt)
{
if (i < nmoves || m_simulator.isConsideredMove(*simmedIt))
ret.push_back(*simmedIt);
}
//UVcout << "bogo returning moves:\n" << ret << endl;
return ret;
}