diff --git a/include/config.h b/include/config.h index 9e5b337e..65a08e82 100644 --- a/include/config.h +++ b/include/config.h @@ -56,9 +56,6 @@ //#define MILL_FIRST -#define CONST_MOVE_TABLE -#define CONST_MILL_TABLE - //#define DEAL_WITH_HORIZON_EFFECT #define IDS_SUPPORT diff --git a/millgame.vcxproj b/millgame.vcxproj index 928598b1..168c5597 100644 --- a/millgame.vcxproj +++ b/millgame.vcxproj @@ -467,7 +467,6 @@ - @@ -689,11 +688,6 @@ true - - - - - diff --git a/millgame.vcxproj.filters b/millgame.vcxproj.filters index e0ad3b67..b5fbb44f 100644 --- a/millgame.vcxproj.filters +++ b/millgame.vcxproj.filters @@ -37,9 +37,6 @@ {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - {d3810898-e5d4-49ce-92da-beddffba0697} - {16c52ca8-0391-4ad2-919c-4a865ad87e98} @@ -229,9 +226,6 @@ Resource Files - - Text Files - Header Files @@ -242,17 +236,6 @@ base - - - Text Files - - - Text Files - - - Text Files - - ui diff --git a/src/ai/evaluate.cpp b/src/ai/evaluate.cpp index eac7d8a8..caf9d31f 100644 --- a/src/ai/evaluate.cpp +++ b/src/ai/evaluate.cpp @@ -1,4 +1,25 @@ -#include "evaluate.h" +/***************************************************************************** + * Copyright (C) 2018-2019 MillGame authors + * + * Authors: liuweilhy + * Calcitem + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include "evaluate.h" value_t Evaluation::getValue(MillGame &gameTemp, GameContext *gameContext, MillGameAi_ab::Node *node) { diff --git a/src/ai/evaluate.h b/src/ai/evaluate.h index e120503d..eeb9a130 100644 --- a/src/ai/evaluate.h +++ b/src/ai/evaluate.h @@ -1,3 +1,24 @@ +/***************************************************************************** + * Copyright (C) 2018-2019 MillGame authors + * + * Authors: liuweilhy + * Calcitem + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + #ifndef EVALUATE_H #define EVALUATE_H @@ -15,7 +36,7 @@ public: static value_t getValue(MillGame &gameTemp, GameContext *gameContext, MillGameAi_ab::Node *node); - // + // 评估子力 #ifdef EVALUATE_ENABLE #ifdef EVALUATE_MATERIAL diff --git a/src/ai/movegen.cpp b/src/ai/movegen.cpp index 726ba680..d1174d90 100644 --- a/src/ai/movegen.cpp +++ b/src/ai/movegen.cpp @@ -1,4 +1,25 @@ -#include +/***************************************************************************** + * Copyright (C) 2018-2019 MillGame authors + * + * Authors: liuweilhy + * Calcitem + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include #include "movegen.h" @@ -145,7 +166,6 @@ void MoveList::generateLegalMoves(MillGameAi_ab &ai_ab, MillGame &gameTemp, void MoveList::createMoveTable(MillGame &game) { -#ifdef CONST_MOVE_TABLE #if 1 const int moveTable_obliqueLine[Board::N_POINTS][N_MOVE_DIRECTIONS] = { /* 0 */ {0, 0, 0, 0}, @@ -342,46 +362,9 @@ void MoveList::createMoveTable(MillGame &game) memcpy(moveTable, moveTable_noObliqueLine, sizeof(moveTable)); } -#else /* CONST_MOVE_TABLE */ - - for (int r = 1; r <= N_RINGS; r++) { - for (int s = 0; s < N_SEATS; s++) { - int p = r * N_SEATS + s; - - // 顺时针走一步的位置 - moveTable[p][MOVE_DIRECTION_CLOCKWISE] = r * N_SEATS + (s + 1) % N_SEATS; - - // 逆时针走一步的位置 - moveTable[p][MOVE_DIRECTION_ANTICLOCKWISE] = r * N_SEATS + (s + N_SEATS - 1) % N_SEATS; - - // 如果是 0、2、4、6位(偶数位)或是有斜线 - if (!(s & 1) || this->currentRule.hasObliqueLines) { - if (r > 1) { - // 向内走一步的位置 - moveTable[p][MOVE_DIRECTION_INWARD] = (r - 1) * N_SEATS + s; - } - - if (r < N_RINGS) { - // 向外走一步的位置 - moveTable[p][MOVE_DIRECTION_OUTWARD] = (r + 1) * N_SEATS + s; - } - } -#if 0 - // 对于无斜线情况下的1、3、5、7位(奇数位),则都设为棋盘外点(默认'\x00') - else { - // 向内走一步的位置设为随便棋盘外一点 - moveTable[i * SEAT + j][2] = '\x00'; - // 向外走一步的位置设为随便棋盘外一点 - moveTable[i * SEAT + j][3] = '\x00'; - } -#endif - } - } -#endif /* CONST_MOVE_TABLE */ - -#if 0 +#ifdef DEBUG_MODE int sum = 0; - for (int i = 0; i < N_POINTS; i++) { + for (int i = 0; i < Board::N_POINTS; i++) { loggerDebug("/* %d */ {", i); for (int j = 0; j < N_MOVE_DIRECTIONS; j++) { if (j == N_MOVE_DIRECTIONS - 1) @@ -392,7 +375,7 @@ void MoveList::createMoveTable(MillGame &game) } loggerDebug("},\n"); } - loggerDebug("sum = %d\n"); + loggerDebug("sum = %d\n", sum); #endif } diff --git a/src/ai/movegen.h b/src/ai/movegen.h index 3ed603e9..9dcdf129 100644 --- a/src/ai/movegen.h +++ b/src/ai/movegen.h @@ -1,4 +1,25 @@ -#ifndef MOVEGEN_H +/***************************************************************************** + * Copyright (C) 2018-2019 MillGame authors + * + * Authors: liuweilhy + * Calcitem + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef MOVEGEN_H #define MOVEGEN_H #include "config.h" diff --git a/src/game/board.cpp b/src/game/board.cpp index 24f1bb9d..055602a1 100644 --- a/src/game/board.cpp +++ b/src/game/board.cpp @@ -67,7 +67,6 @@ Board &Board::operator= (const Board &other) void Board::createMillTable(const Rule ¤tRule) { -#ifdef CONST_MILL_TABLE const int millTable_noObliqueLine[Board::N_POINTS][Board::N_DIRECTIONS][2] = { /* 0 */ {{0, 0}, {0, 0}, {0, 0}}, /* 1 */ {{0, 0}, {0, 0}, {0, 0}}, @@ -167,103 +166,30 @@ void Board::createMillTable(const Rule ¤tRule) } else { memcpy(millTable, millTable_noObliqueLine, sizeof(millTable)); } -#else /* CONST_MILL_TABLE */ - for (int i = 0; i < N_SEATS; i++) { - // 内外方向的“成三” - // 如果是0、2、4、6位(偶数位)或是有斜线 - if (!(i & 1) || this->currentRule.hasObliqueLines) { - millTable[1 * N_SEATS + i][0][0] = 2 * N_SEATS + i; - millTable[1 * N_SEATS + i][0][1] = 3 * N_SEATS + i; - millTable[2 * N_SEATS + i][0][0] = 1 * N_SEATS + i; - millTable[2 * N_SEATS + i][0][1] = 3 * N_SEATS + i; - - millTable[3 * N_SEATS + i][0][0] = 1 * N_SEATS + i; - millTable[3 * N_SEATS + i][0][1] = 2 * N_SEATS + i; - } - // 对于无斜线情况下的1、3、5、7位(奇数位) - else { - // 置空该组“成三” - millTable[1 * N_SEATS + i][0][0] = 0; - millTable[1 * N_SEATS + i][0][1] = 0; - - millTable[2 * N_SEATS + i][0][0] = 0; - millTable[2 * N_SEATS + i][0][1] = 0; - - millTable[3 * N_SEATS + i][0][0] = 0; - millTable[3 * N_SEATS + i][0][1] = 0; - } - - // 当前圈上的“成三” - // 如果是0、2、4、6位 - if (!(i & 1)) { - millTable[1 * N_SEATS + i][1][0] = 1 * N_SEATS + (i + 1) % N_SEATS; - millTable[1 * N_SEATS + i][1][1] = 1 * N_SEATS + (i + N_SEATS - 1) % N_SEATS; - - millTable[2 * N_SEATS + i][1][0] = 2 * N_SEATS + (i + 1) % N_SEATS; - millTable[2 * N_SEATS + i][1][1] = 2 * N_SEATS + (i + N_SEATS - 1) % N_SEATS; - - millTable[3 * N_SEATS + i][1][0] = 3 * N_SEATS + (i + 1) % N_SEATS; - millTable[3 * N_SEATS + i][1][1] = 3 * N_SEATS + (i + N_SEATS - 1) % N_SEATS; - // 置空另一组“成三” - millTable[1 * N_SEATS + i][2][0] = 0; - millTable[1 * N_SEATS + i][2][1] = 0; - - millTable[2 * N_SEATS + i][2][0] = 0; - millTable[2 * N_SEATS + i][2][1] = 0; - - millTable[3 * N_SEATS + i][2][0] = 0; - millTable[3 * N_SEATS + i][2][1] = 0; - } - // 对于1、3、5、7位(奇数位) - else { - // 当前圈上逆时针的“成三” - millTable[1 * N_SEATS + i][1][0] = 1 * N_SEATS + (i + N_SEATS - 2) % N_SEATS; - millTable[1 * N_SEATS + i][1][1] = 1 * N_SEATS + (i + N_SEATS - 1) % N_SEATS; - - millTable[2 * N_SEATS + i][1][0] = 2 * N_SEATS + (i + N_SEATS - 2) % N_SEATS; - millTable[2 * N_SEATS + i][1][1] = 2 * N_SEATS + (i + N_SEATS - 1) % N_SEATS; - - millTable[3 * N_SEATS + i][1][0] = 3 * N_SEATS + (i + N_SEATS - 2) % N_SEATS; - millTable[3 * N_SEATS + i][1][1] = 3 * N_SEATS + (i + N_SEATS - 1) % N_SEATS; - - // 当前圈上顺时针的“成三” - millTable[1 * N_SEATS + i][2][0] = 1 * N_SEATS + (i + 1) % N_SEATS; - millTable[1 * N_SEATS + i][2][1] = 1 * N_SEATS + (i + 2) % N_SEATS; - - millTable[2 * N_SEATS + i][2][0] = 2 * N_SEATS + (i + 1) % N_SEATS; - millTable[2 * N_SEATS + i][2][1] = 2 * N_SEATS + (i + 2) % N_SEATS; - - millTable[3 * N_SEATS + i][2][0] = 3 * N_SEATS + (i + 1) % N_SEATS; - millTable[3 * N_SEATS + i][2][1] = 3 * N_SEATS + (i + 2) % N_SEATS; - } - } -#endif /* CONST_MILL_TABLE */ - -#if 0 +#ifdef DEBUG_MODE for (int i = 0; i < N_POINTS; i++) { - printf("/* %d */ {", i); + loggerDebug("/* %d */ {", i); for (int j = 0; j < N_DIRECTIONS; j++) { - printf("{"); + loggerDebug("{"); for (int k = 0; k < 2; k++) { if (k == 0) { - printf("%d, ", millTable[i][j][k]); + loggerDebug("%d, ", millTable[i][j][k]); } else { - printf("%d", millTable[i][j][k]); + loggerDebug("%d", millTable[i][j][k]); } } if (j == 2) - printf("}"); + loggerDebug("}"); else - printf("}, "); + loggerDebug("}, "); } - printf("},\n"); + loggerDebug("},\n"); } - printf("======== millTable End =========\n"); - -#endif + loggerDebug("======== millTable End =========\n"); +#endif /* DEBUG_MODE */ } void Board::pos2rs(const int pos, int &r, int &s)