나는 네 개의 연결을 재생하기 위해 negamax를 사용 해왔다. 내가 알아 차 렸던 점은, 알파 베타를 추가하면 잃어버린 움직임을 만들 때와 같이 때로는 "잘못된"결과를 얻는다는 것입니다. 나는 그것이 내가 찾고있는 깊이로 만들어야한다고 생각하지 않습니다. 알파 베타를 제거하면 그것이 어떻게되는지를 보여줍니다. 알파 베타가 실제 가능한 지점을자를 수 있습니까? 특히 깊이가 제한되어있을 때 특히 그렇습니다. 여기에 단지 경우 코드는 다음과 같습니다C++ Negamax 알파 베타 컷오프가 잘못 되었습니까?
int negamax(const GameState& state, int depth, int alpha, int beta, int color)
{
//depth end reached? or we actually hit a win/lose condition?
if (depth == 0 || state.points != 0)
{
return color*state.points;
}
//get successors and optimize the ordering/trim maybe too
std::vector<GameState> childStates;
state.generate_successors(childStates);
state.order_successors(childStates);
//no possible moves - then it's a terminal state
if (childStates.empty())
{
return color*state.points;
}
int bestValue = -extremePoints;
int v;
for (GameState& child : childStates)
{
v = -negamax(child, depth - 1, -beta, -alpha, -color);
bestValue = std::max(bestValue, v);
alpha = std::max(alpha, v);
if (alpha >= beta)
break;
}
return bestValue;
}
고맙습니다. 제한된 깊이와 알파 베타에 대해 더 이상 의심 할 여지가 없습니다. 결국 그것은 구현 오류로 밝혀졌다 (나는 그것을 올바르게 멀티 쓰레딩하는 것을 망쳤다). – lightxbulb