调用以下函数时,我不断收到错误消息。错误是bestboard
在调用 searchTree.m 期间未分配输出参数(可能还有其他参数)。
function [alpha,bestboard] = searchTree(board,depth,alpha,beta,turn)
if(depth<=0)
alpha=calculateHeuristic(board,changeTurn(turn));
bestboard=board;
return
else
child=GenerateChild(board,turn);
a=size(child,3);
if(turn==2)
turn=changeTurn(turn);
for i=1:a
[score,aboard]=searchTree(child(:,:,i),depth-1,alpha,beta,turn);
if(score>alpha)
alpha=score;
bestboard=child(:,:,i);
end
end
return
else
for j=1:a
turn=changeTurn(turn);
[scor,bboard]=searchTree(child(:,:,j),depth-1,alpha,beta,turn);
if(scor<beta)
beta=scor;
bestboard=child(:,:,j);
alpha=beta;
end
end
return
end
end