本文整理汇总了C++中MoveList::sort方法的典型用法代码示例。如果您正苦于以下问题:C++ MoveList::sort方法的具体用法?C++ MoveList::sort怎么用?C++ MoveList::sort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveList
的用法示例。
在下文中一共展示了MoveList::sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mainLoop
int Search::mainLoop( MoveList<RootEntry>& rootMoves, std::atomic<bool>& abortCondition) {
int targetCutoff = rootMoves.size;
for (int depth = 0; depth <= Depth::MAX_DEPTH; depth++) {
// reset rootMove values
for (int i = 0; i < rootMoves.size; i++) {
rootMoves.entries[i]->value = -Value::INFINITE;
}
int alpha = -Value::INFINITE;
int beta = Value::INFINITE;
for (int i = 0; i < rootMoves.size; i++) {
int move = rootMoves.entries[i]->move;
position.makeMove(move);
int value = -search(depth, -beta, -alpha, 1, abortCondition);
//protocol.sendBestMove(move, Move::NOMOVE);
position.undoMove(move);
// If aborted we must not update the value.
stopConditions();
if (abort || abortCondition) {
break;
}
rootMoves.entries[i]->value = value;
rootMoves.entries[i]->pondermove = bestResponse;
if (value > alpha) {
alpha = value;
}
}
if (abort || abortCondition) {
break;
}
rootMoves.sort();
/*
for (int i = 0; i < rootMoves.size; i++) {
auto rootMoveEntry = rootMoves.entries[i];
std::cout << "move: " << MartonChess::fromMove(rootMoveEntry->move) << "score: " << rootMoveEntry->value << std::endl;
}
*/
targetCutoff = 0;
int targetCutoffValue =
(int) (rootMoves.entries[rootMoves.size - 1]->value
+ (rootMoves.entries[0]->value - rootMoves.entries[rootMoves.size - 1]->value)
* cutoffRatio);
while (rootMoves.entries[targetCutoff]->value >= targetCutoffValue) {
targetCutoff++;
if (targetCutoff >= rootMoves.size)
break;
}
}
return targetCutoff;
}
示例2: readGame
//.........这里部分代码省略.........
<< " <tr>\n"
<< " <td colspan=2 align=left><font face=Arial size=1>"
<< cntmove << ". "
<< Piece::getChar(piece1) << Piece::getChar(piece2)
<< "</font></td>\n"
<< " </tr>\n"
<< " <tr>\n"
<< " <td align=right><font face=Arial size=1> </font></td>\n"
<< " <td align=right><font face=Arial size=1>vx</font></td>\n";
for (int i=level; i>=preview; i--)
wHtml << " <td align=right><font face=Arial size=1> Level "
<< i << "</font></td>\n";
wHtml << " </tr>\n";
while (length-- > 0)
{
int v = rGameFile.readByte(); // # V
int x = rGameFile.readShort(); // # X
int y = rGameFile.readShort(); // # Y
Move *move = moveList->getMove();
moveList->add(v, x, y);
for (int i=preview; i<=level; i++) // Equity (e.g):
{
double equity = rGameFile.readFloat(); // L2, L3, L4
move->setEquity(i, equity);
}
}
moveList->sort();
int movecnt = 0;
Move *move = moveList->getFirstMove();
int first[MAX_LEVELS+1];
float bestEquity[MAX_LEVELS+1];
if (move != 0)
{
for (int i=preview; i<=level; i++)
{
first[i] = 1;
bestEquity[i] = (float)moveList->getBestEquity(i);
}
}
// 2. Equity list list
while (move != 0)
{
movecnt++;
if (movecnt > height/2)
break;
int v = move->getV();
int x = move->getX();
int y = move->getY();
wHtml << " <tr>\n"
<< " <td align=right><font face=Arial size=1>"
<< movecnt << ".</font></td>\n"
<< " <td align=right><font face=Arial size=1>"