Aiml Min - Max Tictactoe - 4
Aiml Min - Max Tictactoe - 4
Experiment 4
AIM : Implement the problem using the Informed searching technique min-max algorithm .
Analyze the algorithm with respect to Completeness, Optimality, time and space
Complexity
a) Tic Tac Toe
// No winner: return 0
return 0;
}
// Minimax algorithm
int minimax(char board[3][3], int depth, bool isMax) {
int score = evaluate(board);
return bestMove;
}
int main() {
char board[3][3] = {
{'_', '_', '_'},
{'_', '_', '_'},
{'_', '_', '_'}
};
while (isMovesLeft(board)) {
int row, col;
printBoard(board);
printBoard(board);
return 0;
}
OUTPUT: // the code always gives the perfect move whicever move you play resulting in draw or
player losing.
BHARATIYA VIDYA BHAVAN’S
SARDAR PATEL INSTITUTE OF TECHNOLOGY
Bhavan’s Campus, Munshi Nagar, Andheri (West), Mumbai – 400058-India
Analysis: Analyze the algorithm with respect to Completeness, Optimality, time and space
Complexity
BHARATIYA VIDYA BHAVAN’S
SARDAR PATEL INSTITUTE OF TECHNOLOGY
Bhavan’s Campus, Munshi Nagar, Andheri (West), Mumbai – 400058-India
What is Minimax?
Minimax is a artificial intelligence applied in two player games, such as tic-tac-toe,
checkers, chess and go. This games are known as zero-sum games, because in a
mathematical representation: one player wins (+1) and other player loses (-1) or both of
anyone not to win (0).
return best
end
BHARATIYA VIDYA BHAVAN’S
SARDAR PATEL INSTITUTE OF TECHNOLOGY
Bhavan’s Campus, Munshi Nagar, Andheri (West), Mumbai – 400058-India
CONCLUSION: From this experiment I learned about the min-max algo in AIML and implemented it in
the tic- tac-toe game and designed it such that any player playing will draw or lose
against this program.