Game AI is different from ordinary search.
You are not just finding a path.
You are making a move while another player is trying to block you.
That is why game decision-making needs a different structure.
Core Idea
In game search, every move creates a new state.
But unlike simple pathfinding, the next state is not fully under your control.
Your opponent also chooses.
So the algorithm must ask:
“What is my best move if the opponent also plays well?”
That question is the heart of Minimax.
The Key Structure
A simple game decision flow looks like this:
Current Board → Possible Moves → Opponent Responses → Score Positions → Choose Best Move
Minimax expresses this idea:
MAX player tries to maximize the score
MIN player tries to minimize the score
the final decision assumes both players play optimally
So Game AI is not only about choosing a good move.
It is about choosing a move that survives the opponent’s best response.
Implementation View
At a high level, Minimax works like this:
function…