From 6c2ed081d23e7de9a9aeb394a927bd286b640926 Mon Sep 17 00:00:00 2001 From: CalciteM Team Date: Sat, 17 Aug 2019 22:11:08 +0800 Subject: [PATCH] =?UTF-8?q?AI:=20changeDepth=20=E5=87=BD=E6=95=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BD=8D=E7=BD=AE=E5=88=B0=E9=9D=A0=E8=BF=91=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B4=E9=83=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 以便于修改参数。 --- NineChess/src/ninechessai_ab.cpp | 82 ++++++++++++++++---------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/NineChess/src/ninechessai_ab.cpp b/NineChess/src/ninechessai_ab.cpp index 9ef28886..b5fc6520 100644 --- a/NineChess/src/ninechessai_ab.cpp +++ b/NineChess/src/ninechessai_ab.cpp @@ -71,6 +71,47 @@ NineChessAi_ab::~NineChessAi_ab() rootNode = nullptr; } +NineChessAi_ab::depth_t NineChessAi_ab::changeDepth(depth_t originalDepth) +{ + depth_t newDepth = originalDepth; + + if ((chessTemp.context.stage) & (NineChess::GAME_PLACING)) { +#ifdef GAME_PLACING_DYNAMIC_DEPTH +#ifdef DEAL_WITH_HORIZON_EFFECT +#ifdef HASH_MAP_ENABLE + depth_t depthTable[] = { 4, 11, 12, 13, 14, 14, 14, 12, 11, 10, 6, 6, 1 }; +#else // HASH_MAP_ENABLE + depth_t depthTable[] = { 2, 11, 11, 11, 11, 10, 9, 8, 8, 8, 7, 7, 1 }; +#endif // HASH_MAP_ENABLE +#else // DEAL_WITH_HORIZON_EFFECT +#ifdef HASH_MAP_ENABLE +#ifdef RAPID_CHESS + depth_t depthTable[] = { 6, 14, 15, 16, 15, 15, 15, 13, 10, 9, 8, 7, 1 }; +#else + depth_t depthTable[] = { 6, 15, 16, 17, 16, 16, 16, 12, 12, 12, 9, 7, 1 }; +#endif // RAPID_CHESS +#else // HASH_MAP_ENABLE + depth_t depthTable[] = { 2, 13, 13, 13, 12, 11, 10, 9, 9, 8, 8, 7, 1 }; +#endif +#endif // DEAL_WITH_HORIZON_EFFECT + newDepth = depthTable[chessTemp.getPiecesInHandCount_1()]; +#elif defined GAME_PLACING_FIXED_DEPTH + newDepth = GAME_PLACING_FIXED_DEPTH; +#endif // GAME_PLACING_DYNAMIC_DEPTH + } + +#ifdef GAME_MOVING_FIXED_DEPTH + // 走棋阶段将深度调整 + if ((chessTemp.context.stage) & (NineChess::GAME_MOVING)) { + newDepth = GAME_MOVING_FIXED_DEPTH; + } +#endif /* GAME_MOVING_FIXED_DEPTH */ + + qDebug() << "Depth:" << newDepth; + + return newDepth; +} + void NineChessAi_ab::buildRoot() { rootNode = addNode(nullptr, 0, 0, 0, NineChess::NOBODY); @@ -674,47 +715,6 @@ int NineChessAi_ab::evaluate(Node *node) return value; } -NineChessAi_ab::depth_t NineChessAi_ab::changeDepth(depth_t originalDepth) -{ - depth_t newDepth = originalDepth; - - if ((chessTemp.context.stage) & (NineChess::GAME_PLACING)) { -#ifdef GAME_PLACING_DYNAMIC_DEPTH -#ifdef DEAL_WITH_HORIZON_EFFECT -#ifdef HASH_MAP_ENABLE - depth_t depthTable[] = { 4, 11, 12, 13, 14, 14, 14, 12, 11, 10, 6, 6, 1 }; -#else // HASH_MAP_ENABLE - depth_t depthTable[] = { 2, 11, 11, 11, 11, 10, 9, 8, 8, 8, 7, 7, 1 }; -#endif // HASH_MAP_ENABLE -#else // DEAL_WITH_HORIZON_EFFECT -#ifdef HASH_MAP_ENABLE -#ifdef RAPID_CHESS - depth_t depthTable[] = { 6, 14, 15, 16, 15, 15, 15, 13, 10, 9, 8, 7, 1 }; -#else - depth_t depthTable[] = { 6, 15, 16, 17, 16, 16, 16, 12, 12, 12, 9, 7, 1 }; -#endif // RAPID_CHESS -#else // HASH_MAP_ENABLE - depth_t depthTable[] = { 2, 13, 13, 13, 12, 11, 10, 9, 9, 8, 8, 7, 1 }; -#endif -#endif // DEAL_WITH_HORIZON_EFFECT - newDepth = depthTable[chessTemp.getPiecesInHandCount_1()]; -#elif defined GAME_PLACING_FIXED_DEPTH - newDepth = GAME_PLACING_FIXED_DEPTH; -#endif // GAME_PLACING_DYNAMIC_DEPTH - } - -#ifdef GAME_MOVING_FIXED_DEPTH - // 走棋阶段将深度调整 - if ((chessTemp.context.stage) & (NineChess::GAME_MOVING)) { - newDepth = GAME_MOVING_FIXED_DEPTH; - } -#endif /* GAME_MOVING_FIXED_DEPTH */ - - qDebug() << "Depth:" << newDepth; - - return newDepth; -} - int NineChessAi_ab::alphaBetaPruning(depth_t depth) { QTime time1;