Questions tagged [minimax]

A concept used in artificial intelligence/game theory for two-player games. The idea is to minimize the opponent's gain and maximize yours. Questions using this tag cover problems understanding/implementing the algorithm.

Minimax involves generating a game-tree to consider all the possible outcomes of a game, given its present configuration. The minimax agent then chooses the branch which leads to the agent's maximum gain and, consequentially, to the minimum gain of the opponent (a zero-sum game).

While generating a whole game tree may seem a computationally expensive task, several techniques have been developed to reduce the computation time. One of the most famous techniques is Alpha-Beta Pruning: given a branch in the game tree, stop evaluating that branch ("prune") as soon as you find an outcome in that branch that is worse than a previously-examined branch. Some variations (such as those used in Chess programs) only consider up to a certain number of turns and not always up to end-game.

Another variation of minimax, termed as expectiminimax, introduces "chance" elements in the game such as dice throws.

Finally, note that while minimax is originally intended for two-player games, the technique has been extended to games with more complex set-ups.

Further reading:

910 questions
-1
votes
1 answer

Minimax algorithm in Ruby in Object-Oriented way

I am trying to implement minimax algorithm for a tic tac toe game in an object-oriented way. I was a bit stuck with how to deal with reverting the state for my board object once the algorithm determined the best move. When running the program, I…
-1
votes
1 answer

MiniMax Algorithm with Chess in C# not working properly

I've been trying to implement minimax algorithm in my C# chess engine for a week now and it makes legal moves but not meaningful moves. I cannot find the error, hopefully someone can spot it. I have tried to isolate the problem by testing each…
foRei
  • 9
  • 1
-1
votes
1 answer

AlphaBeta Pruning TicTacToe is not blocking, is it eval problem?

I'm debuging this for days and i don't know what I made wrong in this piece of code for Tic-Tac-Toe game and AI (well I know its not real AI but...) I have choosen for this was Alpha-Beta pruning. Its 7x7 board so it would be too heavy for pure…
-1
votes
1 answer

Returning multiple minimax values [score, x, y] using structs in C

The issue in my code lies in the minimax algorithm, more specifically the return values. My current solution written in C++ is below, using tuples, returning score, x and y positions. I've decided to do something similar in C using struct. The…
-1
votes
2 answers

Anyone fancy a challenge? minimax tic-tac-toe

I am stuck on implementing the minimax algorithm for a tic tac toe game. I keep getting the same error every time (undefined method `<' for nil:NilClass (NoMethodError)) but me and various people I have now asked, can't seem to fix it. My minimax…
testing09
  • 73
  • 7
-1
votes
1 answer

Minimax algorithm in python using tic tac toe

I'm trying to make tic tac toe AI, which plays the game optimally by using minimax algorithm. I got it to work only to notice it does not make optimal moves and putting it against itself results always win for 'X' player (It should result in…
Jon H
  • 33
  • 1
  • 8
-1
votes
1 answer

Minimax function not returning correct results

I have made a tic tac toe discord bot to play tic tac toe with(against) me. The algorithm works pretty good, but it almost never seems to block me or take wins, even when I try to make it. I have tried lots of debugging, and I really don't think…
user11031046
-1
votes
1 answer

Game AI works powerfully on one side and becomes dumb on the other in Tic-Tac-Toe

I am trying to make a Tic-Tac-Toe game in Python using PyGame and the MiniMax algorithm. The AI plays really well when given the first chance (playing as 'X'), but becomes dumb enough to help the user win when not given the first chance (playing as…
-1
votes
1 answer

What's wrong with this tic tac toe python game

I have recently enrolled into cs50 Artificial Intelligence with python online course and the first project is to create a tic tac toe game using the minimax algorithm and I have attempted it. But when I run the runner.py file provided with the zip…
-1
votes
1 answer

minimax tic-tac-toe algorithm wrongly always puts the "X"or "O" in the next available place

I am trying to create a tic-tac-toe game that responds to the player with the minimax algorithm. It is not working. It just puts the "X"or "O" in the next available place. (If 0,0 is is not null then it goes to 0,1 and then 0,2.) I do not understand…
adi
  • 1
  • 1
-1
votes
2 answers

utility functions minimax search

Hi I'm confused how you can determine the utility functions on with a minimax search Explain it with any game that you can use a minimax search with Basically i am asking how do you determine the utility functions Cheers
Ben
  • 1
  • 1
  • 1
-1
votes
2 answers

i want to find maximum, minimum and average but it assigns me something for 0

I try to write in an array of numbers greater than 54. And then output its sum, average, maximum and minimum accordingly. still i tried do - while through but also failed.. ( But I always get 0, how can I fix it? Thank! { int arr_first [10]; …
-1
votes
1 answer

Implementation of minimax algorithm for tic tac toe

I need to make my tic tac toe AI unbeatable . The computer AI 'O' should choose the best move. I start by using a random number to create my first AI for the game but now the problem is to make it unbeatable. I found something call minimax algorithm…
-1
votes
1 answer

The Minimax function returns the same evaluation for all possible moves in TicTacToe

In the main program loop, the for loop goes through each of the empty positions in the TicTacToe board and then applies the minimax function on each position to give the evaluation of that particular move. However, for each particular board…
Hasanat Jahan
  • 73
  • 1
  • 6
-1
votes
2 answers

Tic Tac Toe: Evaluating Heuristic Value of a Node

Pardon me if this question already exists, I've searched a lot but I haven't gotten the answer to the question I want to ask. So, basically, I'm trying to implement a Tic-Tac-Toe AI that uses the Minimax algorithm to make moves. However, one thing I…
Famiu
  • 93
  • 7