Skip to content

Instantly share code, notes, and snippets.

@Hydrotoast
Created November 1, 2012 18:09
Show Gist options
  • Save Hydrotoast/3995461 to your computer and use it in GitHub Desktop.
Save Hydrotoast/3995461 to your computer and use it in GitHub Desktop.
General Approach for Adversarial Search
int AI::IterativeDeepening(const State& state, int alpha, int beta, int depth) {
if (cutoff(state, depth))
return eval(state);
int result = 0;
for (Move* move : moves) {
State newState = state.clone();
result = max(result, newState.makeMove(state));
}
return result;
}
bool AI::cutoff(const State& state, int depth) {
return state->isEndGame() || depth == 0;
}
// TODO: Implement this
int AI::eval(const State& state) {
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment