refactor: isStarLocation() 转移到 board 模块

This commit is contained in:
CalciteM Team 2019-09-13 17:06:28 +08:00
parent e1b5855f91
commit 95caceeb3e
5 changed files with 13 additions and 9 deletions

View File

@ -90,7 +90,7 @@ void MoveList::generateLegalMoves(MillGameAi_ab &ai_ab, Position &dummyPosition,
ai_ab.addNode(node, VALUE_ZERO, (move_t)location, bestMove, dummyPosition.context.turn);
} else {
// 若为先手,则抢占星位
if (Position::isStarLocation(location)) {
if (Board::isStarLocation(location)) {
ai_ab.addNode(node, VALUE_INFINITE, (move_t)location, bestMove, dummyPosition.context.turn);
}
}

View File

@ -481,6 +481,14 @@ bool Board::getCurrentPiece(player_t &player, int &number, int location)
return true;
}
bool Board::isStarLocation(int location)
{
return (location == 17 ||
location == 19 ||
location == 21 ||
location == 23);
}
void Board::mirror(list <string> &cmdlist, char* cmdline, int32_t move_, struct Rule &currentRule, int location, bool cmdChange /*= true*/)
{
int ch;

View File

@ -55,6 +55,9 @@ public:
// 空棋盘点位,用于判断一个棋子位置是否在棋盘上
static const int onBoard[N_LOCATIONS];
// 判断位置点是否为星位 (星位是经常会先占的位置)
static bool isStarLocation(int location);
// 成三表,表示棋盘上各个位置有成三关系的对应位置表
// 这个表跟规则有关,一旦规则改变需要重新修改
static int millTable[N_LOCATIONS][LINE_TYPES_COUNT][N_RINGS - 1];

View File

@ -87,7 +87,7 @@ int Position::playerToId(enum player_t player)
return 0;
}
player_t Position::getOpponent(player_t player)
player_t Position::getOpponent(enum player_t player)
{
switch (player)
{

View File

@ -33,7 +33,6 @@
using namespace std;
// 棋局结构体,算法相关,包含当前棋盘数据
// 单独分离出来供AI判断局面用生成置换表时使用
class PositionContext
@ -144,12 +143,6 @@ public:
return currentLocation;
}
// 判断位置点是否为星位 (星位是经常会先占的位置)
static bool isStarLocation(int location)
{
return (location == 17 || location == 19 || location == 21 || location == 23);
}
// 获取当前步数
int getStep() const
{