java—如何获得negamax算法所基于的预测移动序列?

sycxhyv7  于 2021-07-06  发布在  Java
关注(0)|答案(0)|浏览(107)

我的象棋算法是基于negamax的。相关部分是:

private double deepEvaluateBoard(Board board, int currentDepth, double alpha, double beta, Move initialMove) {
        if (board.isCheckmate() || board.isDraw() || currentDepth <= 0) {
            this.moveHistorys.put(initialMove, board.getMoveHistory()); // this is not working
            return evaluateBoard(board); // evaluateBoard evaluates from the perspective of color whose turn it is.
        } else {
            double totalPositionValue = -1e40;

            List<Move> allPossibleMoves = board.getAllPossibleMoves();
            for (Move move : allPossibleMoves) {
                board.makeMove(move);
                totalPositionValue = max(-deepEvaluateBoard(board, currentDepth - 1, -beta, -alpha, initialMove), value);
                board.unMakeMove(1);

                alpha = max(alpha, totalPositionValue);
                if (alpha >= beta) {
                    break;
                }
            }

            return totalPositionValue;
        }
    }

如果我能够访问negamax算法评估所基于的移动序列(在决策树上找到评估值),这将大大有助于调试。
目前,我正在尝试保存板的移动历史到一个hashmap中,该hashmap是封闭类的一个字段。然而,由于某些原因,它不起作用,因为生成的移动序列不是最优的。
因为对negamax的直觉的培养不是很容易,所以我已经有相当一段时间把我的头撞到墙上了。如果有人能给我指出正确的方向,我将不胜感激!

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题