Java 为什么我的alpha-beta修剪实现不起作用?

Java 为什么我的alpha-beta修剪实现不起作用?,java,artificial-intelligence,reversi,Java,Artificial Intelligence,Reversi,我用维基百科的伪代码来对付- function alphabeta(node, depth, α, β, Player) if depth = 0 or node is a terminal node return the heuristic value of node if Player = MaxPlayer for each child of node α := max(α, alphabeta(

我用维基百科的伪代码来对付-

function alphabeta(node, depth, α, β, Player)         
    if  depth = 0 or node is a terminal node
        return the heuristic value of node
    if  Player = MaxPlayer
        for each child of node
            α := max(α, alphabeta(child, depth-1, α, β, not(Player) ))     
            if β ≤ α
                break                             (* Beta cut-off *)
        return α
    else
        for each child of node
            β := min(β, alphabeta(child, depth-1, α, β, not(Player) ))     
            if β ≤ α
                break                             (* Alpha cut-off *)
        return β
这是我的java实现-

private int alphabeta(Node newNode, int depth, int alpha, int beta, boolean Player) {
    Integer[] children;
    if(depth == 0 || newNode.allNodesFull()){
        return (newNode.blacknodes() - newNode.whitenodes());
    }
    if(Player == false){
        children = newNode.findMovesBlack();
        Arrays.sort(children);
        for(Integer child: children){
            nodesGenerated ++;
            alpha = Math.max(alpha, alphabeta(new Node(newNode.move(child), true),
                            depth - 1, alpha, beta, !Player));
            if(beta <= alpha)
                break;
        }return alpha;
    }else{
        children = newNode.findMovesWhite();
        Arrays.sort(children);
        for(Integer child: children){
            nodesGenerated ++;
            beta  = Math.min(beta, alphabeta(new Node(newNode.move(child), false), 
                            depth - 1, alpha, beta, !Player));
            if(beta <= alpha)
                break;
        }return beta;
    }
} 
private int-alphabeta(节点newNode、int-depth、int-alpha、int-beta、布尔播放器){
整数[]子代;
if(depth==0 | | newNode.allNodesFull()){
return(newNode.blacknodes()-newNode.whitenodes());
}
如果(Player==false){
children=newNode.findMovesBlack();
数组。排序(子级);
for(整数子级:子级){
nodesGenerated++;
alpha=Math.max(alpha,alphabeta)(新节点(newNode.move,child),true),
深度-1,阿尔法,贝塔,玩家);

如果(beta答案是在beta和alpha值的实现中。我不得不经常弄乱相对于=符号的位置。

我们需要
节点
实现来告诉发生了什么。算法本身看起来很好,但是
allNodesFull()
findMovesBlack()
move()
etc.do?初始调用的参数是什么?我已经添加了我的Node类。我希望您能帮助我,因为初始参数是alphabeta(包含reversi的开始位置的节点,12,100,-100,false)嗯,这是一大堆代码。顺便说一句,你自己试过并调试了吗?只需跳过每一行,检查它是否产生了预期的结果。你可以从错误的位置开始,找出错误,然后反向工作(在调用层次结构中提前停止)直到你找到它开始出错的地方。这么复杂?也许是时候检查一下你的算法了?很抱歉打扰了,但我使用的是维基百科的相同算法,而且也有问题。MinMax运行得很好,但alpha beta一直在犯一些假错误。你能分享你成功的代码吗??