depth: 调整摆棋深度并加入走棋阶段动态调整深度

* 摆棋阶段倒数第4着深度改回17, 为了避免走棋没多久就被闷杀;
* 行棋阶段当双方棋子数量较多时增加搜索深度;
* 行棋阶段如果双方子力相差悬殊则降低深度;
* VC 当使用 Debug 时将深度降低4层.

修改对自对弈的着法无影响, 耗时增加 1/3.
This commit is contained in:
CalciteM Team 2019-09-15 23:42:48 +08:00
parent 3e47a5963b
commit a85c707e2a
1 changed files with 52 additions and 6 deletions

View File

@ -55,21 +55,67 @@ AIAlgorithm::~AIAlgorithm()
depth_t AIAlgorithm::changeDepth(depth_t origDepth)
{
depth_t newDepth = origDepth;
depth_t d = origDepth;
const depth_t placingDepthTable[] = { 6, 14, 15, 16, 16, 16, 16, 14, 12, 12, 9, 7, 1 };
#ifdef _DEBUG
// 当 VC 下编译为 Debug 时
depth_t reduce = 4;
#else
depth_t reduce = 0;
#endif
const depth_t placingDepthTable[] = {
6, 14, 15, 16, /* 0 ~ 3 */
17, 16, 16, 14, /* 4 ~ 7 */
12, 12, 9, 7, 1 /* 8 ~ 12 */
};
const depth_t movingDepthTable[] = {
1, 1, 1, 1, /* 0 ~ 3 */
1, 1, 11, 11, /* 4 ~ 7 */
11, 11, 11, 11, /* 8 ~ 11 */
11, 11, 11, 11, /* 12 ~ 15 */
11, 11, 11, 11, /* 16 ~ 19 */
12, 12, 13, 14, /* 20 ~ 23 */
};
const depth_t movingDiffDepthTable[] = {
0, 0, 11, /* 0 ~ 2 */
10, 9, 8, /* 3 ~ 5 */
7, 6, 5, 4, 3, 2, 1 /* 6 ~ 12 */
};
if ((tempGame.position.phase) & (PHASE_PLACING)) {
newDepth = placingDepthTable[tempGame.getPiecesInHandCount(1)];
d = placingDepthTable[tempGame.getPiecesInHandCount(1)];
}
if ((tempGame.position.phase) & (PHASE_MOVING)) {
newDepth = 11;
int p1 = tempGame.getPiecesOnBoardCount(1);
int p2 = tempGame.getPiecesOnBoardCount(2);
int pieces = p1 + p2;
int diff = p1 - p2;
if (diff < 0) {
diff = -diff;
}
d = movingDiffDepthTable[diff];
if (d == 0) {
d = movingDepthTable[pieces];
}
}
loggerDebug("Depth: %d\n", newDepth);
// Debug 下调低深度
if (d > reduce)
{
d -= reduce;
}
return newDepth;
loggerDebug("Depth: %d\n", d);
return d;
}
void AIAlgorithm::buildRoot()