alphabeta(Pos,Alpha,Beta,GoodPos,Val) :- moves(Pos,PosList), !, /*user-provided*/ boundedbest(PosList,Alpha,Beta,GoodPos,Val). alphabeta(Pos,_,_,_,Val) :- staticval(Pos,Val). /*user-provided*/ boundedbest([Pos | PosList], Alpha, Beta, GoodPos, GoodVal) :- alphabeta(Pos,Alpha, Beta, _, Val), goodenough(PosList, Alpha, Beta, Pos, Val, GoodPos, GoodVal). goodenough([],_,_,Pos,Val,Pos,Val) :- !. goodenough(_, _Alpha, Beta, Pos, Val, Pos, Val) :- min_to_move(Pos), Val>Beta, !. /*Maximizer attained upper bound*/ goodenough(_,Alpha,_Beta,Pos,Val,Pos,Val) :- max_to_move(Pos), ValAlpha, !. /*Maximizer increased the lower bound*/ newbounds(Alpha,Beta, Pos, Val, Alpha, Val) :- max_to_move(Pos), ValVal1, !. betterof(Pos, Val, _Pos1, Val1, Pos,Val) :- max_to_move(Pos), Val