在 node 的成员中加入 cmd 以方便查看结点的命令

This commit is contained in:
CalciteM Team 2019-06-27 02:45:36 +08:00
parent 8ffcc55bb7
commit d1f37c2e6d
2 changed files with 21 additions and 0 deletions

View File

@ -40,6 +40,25 @@ void NineChessAi_ab::addNode(Node *parent, int value, int move)
newNode->root = rootNode;
newNode->stage = chessTemp.context.stage;
newNode->action = chessTemp.context.action;
int c, p;
char cmd[32] = { 0 };
if (move < 0) {
chessTemp.pos2cp(-move, c, p);
sprintf(cmd, "-(%1u,%1u)", c, p);
} else if (move & 0x7f00) {
int c1, p1;
chessTemp.pos2cp(move >> 8, c1, p1);
chessTemp.pos2cp(move & 0x00ff, c, p);
sprintf(cmd, "(%1u,%1u)->(%1u,%1u)", c1, p1, c, p);
} else {
chessTemp.pos2cp(move & 0x007f, c, p);
sprintf(cmd, "(%1u,%1u)", c, p);
}
newNode->cmd = cmd;
parent->children.push_back(newNode);
}

View File

@ -12,6 +12,7 @@
#include <stack>
#include <unordered_map>
#include <mutex>
#include <string>
#include <Qdebug>
using namespace std;
@ -42,6 +43,7 @@ public:
NineChess::GameStage stage;
NineChess::Action action;
int depth;
string cmd;
};
public: