The Minimax algorithm we used is a recursive AI algorithm for choosing the next move based on the position of the game pieces. The algorithm’s position evaluation determines how good each possible move is and attempts to minimize the possible maximum (worst-case) outcome. As the search depth increases, the better the AI’s decision becomes at the cost of computational time.
The evaluation function that the Minimax algorithm uses is a simple heuristic function. It search the current game state for all combinations of four pieces in a row. Then the evaluation functions search those combinations for four in a rows, three in a rows, and two in a rows and assign weights to them according to those matches being the AI's or human's. This function makes the AI play defensively. If we wanted the AI to play more aggressive we would change the weights of each type of number of pieces in a row.