refactor ninechess.cpp/h

This commit is contained in:
CalciteM Team 2019-08-31 11:11:14 +08:00
parent 4e6700100d
commit 1809014e09
2 changed files with 7 additions and 24 deletions

View File

@ -116,7 +116,7 @@ const struct NineChess::Rule NineChess::RULES[N_RULES] = {
};
// 名义上是个数组,实际上相当于一个判断是否在棋盘上的函数
const int NineChess::onBoard[(N_RINGS + 2) * N_SEATS] = {
const int NineChess::onBoard[N_POINTS] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@ -136,9 +136,6 @@ NineChess::NineChess()
board_ = context.board;
#if ((defined HASH_MAP_ENABLE) || (defined BOOK_LEARNING) || (defined THREEFOLD_REPETITION))
//hash_ = &context.hash;
//zobrist_ = &context.zobrist;
// 创建哈希数据
constructHash();
#endif
@ -156,25 +153,11 @@ NineChess::NineChess()
}
NineChess::NineChess(const NineChess &chess)
{
currentRule = chess.currentRule;
context = chess.context;
currentStep = chess.currentStep;
moveStep = chess.moveStep;
board_ = context.board;
currentPos = chess.currentPos;
winner = chess.winner;
startTime = chess.startTime;
currentTime = chess.currentTime;
elapsedSeconds_1 = chess.elapsedSeconds_1;
elapsedSeconds_2 = chess.elapsedSeconds_2;
move_ = chess.move_;
memcpy(cmdline, chess.cmdline, sizeof(cmdline));
cmdlist = chess.cmdlist;
tips = chess.tips;
{
*this = chess;
}
NineChess &NineChess::operator=(const NineChess &chess)
NineChess &NineChess::operator = (const NineChess &chess)
{
if (this == &chess)
return *this;

View File

@ -272,15 +272,15 @@ public:
private:
// 空棋盘点位,用于判断一个棋子位置是否在棋盘上
static const int onBoard[(N_RINGS + 2) * N_SEATS];
static const int onBoard[N_POINTS];
// 着法表每个位置有最多4种走法顺时针、逆时针、向内、向外
// 这个表跟规则有关,一旦规则改变需要重新修改
static int moveTable[(N_RINGS + 2) * N_SEATS][N_MOVE_DIRECTIONS];
static int moveTable[N_POINTS][N_MOVE_DIRECTIONS];
// 成三表,表示棋盘上各个位置有成三关系的对应位置表
// 这个表跟规则有关,一旦规则改变需要重新修改
static int millTable[(N_RINGS + 2) * N_SEATS][3][2];
static int millTable[N_POINTS][N_DIRECTIONS][N_RINGS - 1];
// 生成着法表
void createMoveTable();