position: 去除 Position 类的冗余成员变量 position 而只保留 pos

This commit is contained in:
Calcitem 2020-07-11 22:22:00 +08:00
parent b4f4d80070
commit 6fa2552c17
2 changed files with 6 additions and 8 deletions

View File

@ -56,7 +56,6 @@ vector<Key> moveHistory;
AIAlgorithm::AIAlgorithm() AIAlgorithm::AIAlgorithm()
{ {
position = new Position();
pos = new Position(); pos = new Position();
//movePicker = new MovePicker(); //movePicker = new MovePicker();
} }
@ -177,7 +176,7 @@ void AIAlgorithm::setPosition(Position *p)
//position = p; //position = p;
pos = p; pos = p;
position = pos; // position = pos;
requiredQuit = false; requiredQuit = false;
} }
@ -204,8 +203,8 @@ int AIAlgorithm::search()
#ifdef THREEFOLD_REPETITION #ifdef THREEFOLD_REPETITION
static int nRepetition = 0; static int nRepetition = 0;
if (position->get_phase() == PHASE_MOVING) { if (pos->get_phase() == PHASE_MOVING) {
Key key = position->key(); Key key = pos->key();
if (std::find(moveHistory.begin(), moveHistory.end(), key) != moveHistory.end()) { if (std::find(moveHistory.begin(), moveHistory.end(), key) != moveHistory.end()) {
nRepetition++; nRepetition++;
@ -218,7 +217,7 @@ int AIAlgorithm::search()
} }
} }
if (position->get_phase() == PHASE_PLACING) { if (pos->get_phase() == PHASE_PLACING) {
moveHistory.clear(); moveHistory.clear();
} }
#endif // THREEFOLD_REPETITION #endif // THREEFOLD_REPETITION
@ -403,10 +402,10 @@ Value AIAlgorithm::search(Depth depth, Value alpha, Value beta)
} }
#endif #endif
if (unlikely(position->phase == PHASE_GAMEOVER) || // TODO: Deal with hash if (unlikely(pos->phase == PHASE_GAMEOVER) || // TODO: Deal with hash
depth <= 0 || depth <= 0 ||
unlikely(requiredQuit)) { unlikely(requiredQuit)) {
bestValue = Eval::evaluate(position); bestValue = Eval::evaluate(pos);
// For win quickly // For win quickly
if (bestValue > 0) { if (bestValue > 0) {

View File

@ -227,7 +227,6 @@ public:
private: private:
Position *pos { nullptr }; Position *pos { nullptr };
Position *position { nullptr };
Stack<Position> positionStack; Stack<Position> positionStack;