本文整理汇总了C++中Moves::takeAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Moves::takeAt方法的具体用法?C++ Moves::takeAt怎么用?C++ Moves::takeAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Moves
的用法示例。
在下文中一共展示了Moves::takeAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: expand
int UltimateTicTacToeMontecarloAI::expand(int leafIndex, Nodes& nodes, int const player) const
{
Node& node = nodes[leafIndex];
node.children.reserve(maxChildren);
Moves options = movementOptions(node.board, node.previousMove);
int turn = node.previousMove > 0 ? otherPlayer(node.board.grids.at(node.previousMove)) : player;
int mostPromisingChildIndex = -1;
int mostPromisingChildScore = 0;
while(node.children.size() < maxChildren && !options.empty())
{
Move move = options.takeAt(qrand() % options.size());
int childIndex = nodes.size();
node.children.append(childIndex);
Board newBoard(node.board);
nodes.append( Node {0, 1, playMove(newBoard, move, turn), move, leafIndex, Node::Children()});
int score = scoreBoard(nodes.last().board, player);
if(score > mostPromisingChildScore || mostPromisingChildIndex < 0)
{
mostPromisingChildIndex = childIndex;
mostPromisingChildScore = score;
}
}
return mostPromisingChildIndex;
}