私は4つの接続を再生するためにnegamaxを使用してきました。私が気づいたのは、アルファ・ベータを追加すると、時には「間違った」結果が出るということです。失われた動きのように、私が探している深みではないと信じています。私がalpha-betaを削除した場合、それは想定されているように再生されます。実際に実行可能なブランチをアルファベータで切り捨てることはできますか(特に深さに制限がある場合)?ここで念のコードは次のとおりです。C++ Negamax alpha-betaの間違ったカットオフ?
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