Game &position -> Game &game
This commit is contained in:
parent
7b03758676
commit
ef6e917f99
|
@ -158,7 +158,7 @@ void MoveList::generateLegalMoves(MillGameAi_ab &ai_ab, Game &dummyGame,
|
|||
}
|
||||
}
|
||||
|
||||
void MoveList::createMoveTable(Game &position)
|
||||
void MoveList::createMoveTable(Game &game)
|
||||
{
|
||||
// Note: 未严格按 direction_t 中枚举的顺序从左到右排列
|
||||
#if 1
|
||||
|
@ -351,7 +351,7 @@ void MoveList::createMoveTable(Game &position)
|
|||
};
|
||||
#endif
|
||||
|
||||
if (position.currentRule.hasObliqueLines) {
|
||||
if (game.currentRule.hasObliqueLines) {
|
||||
memcpy(moveTable, moveTable_obliqueLine, sizeof(moveTable));
|
||||
} else {
|
||||
memcpy(moveTable, moveTable_noObliqueLine, sizeof(moveTable));
|
||||
|
@ -374,14 +374,14 @@ void MoveList::createMoveTable(Game &position)
|
|||
#endif
|
||||
}
|
||||
|
||||
void MoveList::shuffleMovePriorityTable(Game &position)
|
||||
void MoveList::shuffleMovePriorityTable(Game &game)
|
||||
{
|
||||
array<move_t, 4> movePriorityTable0 = { (move_t)17, (move_t)19, (move_t)21, (move_t)23 }; // 中圈四个顶点 (星位)
|
||||
array<move_t, 8> movePriorityTable1 = { (move_t)25, (move_t)27, (move_t)29, (move_t)31, (move_t)9, (move_t)11, (move_t)13, (move_t)15 }; // 外圈和内圈四个顶点
|
||||
array<move_t, 4> movePriorityTable2 = { (move_t)16, (move_t)18, (move_t)20, (move_t)22 }; // 中圈十字架
|
||||
array<move_t, 8> movePriorityTable3 = { (move_t)24, (move_t)26, (move_t)28, (move_t)30, (move_t)8, (move_t)10, (move_t)12, (move_t)14 }; // 外内圈十字架
|
||||
|
||||
if (position.randomMoveEnabled()) {
|
||||
if (game.randomMoveEnabled()) {
|
||||
uint32_t seed = static_cast<uint32_t>(now());
|
||||
|
||||
std::shuffle(movePriorityTable0.begin(), movePriorityTable0.end(), std::default_random_engine(seed));
|
||||
|
|
|
@ -39,10 +39,10 @@ public:
|
|||
move_t bestMove);
|
||||
|
||||
// 生成着法表
|
||||
static void createMoveTable(Game &position);
|
||||
static void createMoveTable(Game &game);
|
||||
|
||||
// 随机打乱着法搜索顺序
|
||||
static void shuffleMovePriorityTable(Game &position);
|
||||
static void shuffleMovePriorityTable(Game &game);
|
||||
|
||||
// 着法表 // TODO: Move to private
|
||||
inline static move_t moveTable[Board::N_LOCATIONS][DIRECTIONS_COUNT] = { {MOVE_NONE} };
|
||||
|
|
|
@ -257,10 +257,10 @@ void MillGameAi_ab::deleteTree(Node *node)
|
|||
#endif
|
||||
}
|
||||
|
||||
void MillGameAi_ab::setPosition(const Game &position)
|
||||
void MillGameAi_ab::setPosition(const Game &game)
|
||||
{
|
||||
// 如果规则改变,重建hashmap
|
||||
if (strcmp(this->position_.currentRule.name, position.currentRule.name) != 0) {
|
||||
if (strcmp(this->position_.currentRule.name, game.currentRule.name) != 0) {
|
||||
#ifdef TRANSPOSITION_TABLE_ENABLE
|
||||
TranspositionTable::clearTranspositionTable();
|
||||
#endif // TRANSPOSITION_TABLE_ENABLE
|
||||
|
@ -274,8 +274,8 @@ void MillGameAi_ab::setPosition(const Game &position)
|
|||
positions.clear();
|
||||
}
|
||||
|
||||
this->position_ = position;
|
||||
dummyGame = position;
|
||||
this->position_ = game;
|
||||
dummyGame = game;
|
||||
positionContext = &(dummyGame.context);
|
||||
requiredQuit = false;
|
||||
deleteTree(rootNode);
|
||||
|
|
|
@ -97,7 +97,7 @@ public:
|
|||
MillGameAi_ab();
|
||||
~MillGameAi_ab();
|
||||
|
||||
void setPosition(const Game &position);
|
||||
void setPosition(const Game &game);
|
||||
|
||||
void quit()
|
||||
{
|
||||
|
|
|
@ -61,11 +61,11 @@ AiThread::~AiThread()
|
|||
wait();
|
||||
}
|
||||
|
||||
void AiThread::setAi(const Game &position)
|
||||
void AiThread::setAi(const Game &game)
|
||||
{
|
||||
mutex.lock();
|
||||
|
||||
this->position_ = &position;
|
||||
this->position_ = &game;
|
||||
ai_ab.setPosition(*(this->position_));
|
||||
|
||||
#ifdef TRANSPOSITION_TABLE_ENABLE
|
||||
|
@ -78,11 +78,11 @@ void AiThread::setAi(const Game &position)
|
|||
mutex.unlock();
|
||||
}
|
||||
|
||||
void AiThread::setAi(const Game &position, depth_t depth, int time)
|
||||
void AiThread::setAi(const Game &game, depth_t depth, int time)
|
||||
{
|
||||
mutex.lock();
|
||||
this->position_ = &position;
|
||||
ai_ab.setPosition(position);
|
||||
this->position_ = &game;
|
||||
ai_ab.setPosition(game);
|
||||
aiDepth = depth;
|
||||
aiTime = time;
|
||||
mutex.unlock();
|
||||
|
|
|
@ -55,8 +55,8 @@ protected:
|
|||
|
||||
public:
|
||||
// AI设置
|
||||
void setAi(const Game &position);
|
||||
void setAi(const Game &position, depth_t depth, int time);
|
||||
void setAi(const Game &game);
|
||||
void setAi(const Game &game, depth_t depth, int time);
|
||||
|
||||
Server *getServer()
|
||||
{
|
||||
|
|
|
@ -48,33 +48,33 @@ Game::Game()
|
|||
|
||||
Game::~Game() = default;
|
||||
|
||||
Game::Game(const Game &position)
|
||||
Game::Game(const Game &game)
|
||||
{
|
||||
*this = position;
|
||||
*this = game;
|
||||
}
|
||||
|
||||
Game &Game::operator= (const Game &position)
|
||||
Game &Game::operator= (const Game &game)
|
||||
{
|
||||
if (this == &position)
|
||||
if (this == &game)
|
||||
return *this;
|
||||
|
||||
currentRule = position.currentRule;
|
||||
context = position.context;
|
||||
currentStep = position.currentStep;
|
||||
moveStep = position.moveStep;
|
||||
isRandomMove = position.isRandomMove;
|
||||
giveUpIfMostLose_ = position.giveUpIfMostLose_;
|
||||
currentRule = game.currentRule;
|
||||
context = game.context;
|
||||
currentStep = game.currentStep;
|
||||
moveStep = game.moveStep;
|
||||
isRandomMove = game.isRandomMove;
|
||||
giveUpIfMostLose_ = game.giveUpIfMostLose_;
|
||||
boardLocations = context.board.locations;
|
||||
currentLocation = position.currentLocation;
|
||||
winner = position.winner;
|
||||
startTime = position.startTime;
|
||||
currentTime = position.currentTime;
|
||||
elapsedSeconds[1] = position.elapsedSeconds[1];
|
||||
elapsedSeconds[2] = position.elapsedSeconds[2];
|
||||
move_ = position.move_;
|
||||
memcpy(cmdline, position.cmdline, sizeof(cmdline));
|
||||
cmdlist = position.cmdlist;
|
||||
tips = position.tips;
|
||||
currentLocation = game.currentLocation;
|
||||
winner = game.winner;
|
||||
startTime = game.startTime;
|
||||
currentTime = game.currentTime;
|
||||
elapsedSeconds[1] = game.elapsedSeconds[1];
|
||||
elapsedSeconds[2] = game.elapsedSeconds[2];
|
||||
move_ = game.move_;
|
||||
memcpy(cmdline, game.cmdline, sizeof(cmdline));
|
||||
cmdlist = game.cmdlist;
|
||||
tips = game.tips;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue