Alpha-Beta剪枝算法的伪代码如下:
int AlphaBeta(int Alpha , int Beta , int turn)
{
if(turn==0)
return Eveluation;
if(Is Min Node){
for(each possible move m){
make move m;
score=AlphaBeta(Alpha,Beta,turn-1);
unmake move m;
if(score < Beta){
Beta=score;
if(Alpha>=Beta)
return Alpha;
}
}
return Beta;
}
else{
for(each possible move m){
make move m;
score=AlphaBeta(Alpha,Beta,turn-1);
unmake move m;
if(score>Alpha){
Alpha=score;
if(Alpha>=Beta)
return Beta;
}
}
return Alpha;
}
}