修改 sortChildren 中的 Lambda 函数

This commit is contained in:
CalciteM 2019-07-03 01:18:02 +08:00
parent b7b11eb659
commit 84e937a8f2
1 changed files with 22 additions and 2 deletions

View File

@ -184,9 +184,29 @@ void NineChessAi_ab::sortChildren(Node *node)
#ifdef AB_RANDOM_SORT_CHILDREN
if (chessTemp.whosTurn() == NineChess::PLAYER1) {
node->children.sort([](Node* n1, Node* n2) {return n1->value > n2->value? true : (n1->value == n2->value ? (n1->rand > n2->rand) : false); });
node->children.sort([](Node* n1, Node* n2) {
bool ret = false;
if (n1->value > n2->value) {
ret = true;
} else if (n1->value < n2->value) {
ret = false;
} else if (n1->value == n2->value) {
ret = n1->rand < n2->rand;
}
return ret;
});
} else {
node->children.sort([](Node* n1, Node* n2) { return n1->value < n2->value? true : (n1->value == n2->value ? (n1->rand < n2->rand) : false) ;});
node->children.sort([](Node* n1, Node* n2) {
bool ret = false;
if (n1->value < n2->value) {
ret = true;
} else if (n1->value > n2->value) {
ret = false;
} else if (n1->value == n2->value) {
ret = n1->rand < n2->rand;
}
return ret;
});
}
#else
if (chessTemp.whosTurn() == NineChess::PLAYER1) {