position_ -> game_ (1)
This commit is contained in:
parent
3b5686414e
commit
596e672f2f
|
@ -260,7 +260,7 @@ void MillGameAi_ab::deleteTree(Node *node)
|
||||||
void MillGameAi_ab::setGame(const Game &game)
|
void MillGameAi_ab::setGame(const Game &game)
|
||||||
{
|
{
|
||||||
// 如果规则改变,重建hashmap
|
// 如果规则改变,重建hashmap
|
||||||
if (strcmp(this->position_.currentRule.name, game.currentRule.name) != 0) {
|
if (strcmp(this->game_.currentRule.name, game.currentRule.name) != 0) {
|
||||||
#ifdef TRANSPOSITION_TABLE_ENABLE
|
#ifdef TRANSPOSITION_TABLE_ENABLE
|
||||||
TranspositionTable::clearTranspositionTable();
|
TranspositionTable::clearTranspositionTable();
|
||||||
#endif // TRANSPOSITION_TABLE_ENABLE
|
#endif // TRANSPOSITION_TABLE_ENABLE
|
||||||
|
@ -274,7 +274,7 @@ void MillGameAi_ab::setGame(const Game &game)
|
||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->position_ = game;
|
this->game_ = game;
|
||||||
dummyGame = game;
|
dummyGame = game;
|
||||||
positionContext = &(dummyGame.context);
|
positionContext = &(dummyGame.context);
|
||||||
requiredQuit = false;
|
requiredQuit = false;
|
||||||
|
@ -325,8 +325,8 @@ int MillGameAi_ab::alphaBetaPruning(depth_t depth)
|
||||||
#ifdef THREEFOLD_REPETITION
|
#ifdef THREEFOLD_REPETITION
|
||||||
static int nRepetition = 0;
|
static int nRepetition = 0;
|
||||||
|
|
||||||
if (position_.getPhase() == PHASE_MOVING) {
|
if (game_.getPhase() == PHASE_MOVING) {
|
||||||
hash_t hash = position_.getHash();
|
hash_t hash = game_.getHash();
|
||||||
|
|
||||||
if (std::find(history.begin(), history.end(), hash) != history.end()) {
|
if (std::find(history.begin(), history.end(), hash) != history.end()) {
|
||||||
nRepetition++;
|
nRepetition++;
|
||||||
|
@ -339,13 +339,13 @@ int MillGameAi_ab::alphaBetaPruning(depth_t depth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position_.getPhase() == PHASE_PLACING) {
|
if (game_.getPhase() == PHASE_PLACING) {
|
||||||
history.clear();
|
history.clear();
|
||||||
}
|
}
|
||||||
#endif // THREEFOLD_REPETITION
|
#endif // THREEFOLD_REPETITION
|
||||||
|
|
||||||
// 随机打乱着法顺序
|
// 随机打乱着法顺序
|
||||||
MoveList::shuffleMovePriorityTable(position_);
|
MoveList::shuffleMovePriorityTable(game_);
|
||||||
|
|
||||||
#ifdef IDS_SUPPORT
|
#ifdef IDS_SUPPORT
|
||||||
// 深化迭代
|
// 深化迭代
|
||||||
|
@ -664,10 +664,10 @@ const char* MillGameAi_ab::bestMove()
|
||||||
|
|
||||||
// 检查是否必败
|
// 检查是否必败
|
||||||
|
|
||||||
if (position_.getGiveUpIfMostLose() == true) {
|
if (game_.getGiveUpIfMostLose() == true) {
|
||||||
bool isMostLose = true; // 是否必败
|
bool isMostLose = true; // 是否必败
|
||||||
|
|
||||||
player_t whosTurn = position_.context.turn;
|
player_t whosTurn = game_.context.turn;
|
||||||
|
|
||||||
for (auto child : rootNode->children) {
|
for (auto child : rootNode->children) {
|
||||||
if ((whosTurn == PLAYER_1 && child->value > -VALUE_WIN) ||
|
if ((whosTurn == PLAYER_1 && child->value > -VALUE_WIN) ||
|
||||||
|
@ -679,7 +679,7 @@ const char* MillGameAi_ab::bestMove()
|
||||||
|
|
||||||
// 自动认输
|
// 自动认输
|
||||||
if (isMostLose) {
|
if (isMostLose) {
|
||||||
sprintf(cmdline, "Player%d give up!", position_.context.turnId);
|
sprintf(cmdline, "Player%d give up!", game_.context.turnId);
|
||||||
return cmdline;
|
return cmdline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// 原始模型
|
// 原始模型
|
||||||
Game position_;
|
Game game_;
|
||||||
|
|
||||||
// 演算用的模型
|
// 演算用的模型
|
||||||
Game dummyGame;
|
Game dummyGame;
|
||||||
|
|
Loading…
Reference in New Issue