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
6
votes
3 answers

Return bestMove in minimax algorithm for tictactoe

I have tried to code the minimax algorithm for tic-tac-toe given in Russel Norvig's book on Artificial Intelligence. It had everything except that the way to return the bestMove to the user. I am trying hard to return the bestMove, but cannot decide…
motiur
  • 1,640
  • 9
  • 33
  • 61
6
votes
2 answers

Twist on tic tac toe

i'm writing a tictactoe program but its not your traditional tictactoe First of all the board is 4x4 and the way to win is to get 3 of a kind and 1 of your opponents in a row, column, or diagonal. So the following would be a win for "O" via first…
rage
  • 1,777
  • 5
  • 25
  • 36
6
votes
1 answer

Bug in Minimax Algorithm for Tic Tac Toe

I am currently trying to teach myself the Minimax algorithm and I have tried to implement it in java in tic tac toe. There is a bug in my algorithm however and I can't figure out what's causing it. Below is the complete source code (Sorry for wall…
ScoobyD
  • 63
  • 1
  • 4
6
votes
3 answers

A Simple Chess Minimax

I have problem with my own Chess Engine using minimax algorithm to search for chess moves I use a 5 plies depth search and with only material/bonus/mobility evaluation , but it also make dumb moves and sacrifices valuable pieces even when I give to…
Osama
  • 281
  • 2
  • 3
  • 13
5
votes
3 answers

minimax: what happens if min plays not optimal

the description of the minimax algo says, that both player have to play optimal, so that the algorithm is optimal. Intuitively it is understandable. But colud anyone concretise, or proof what happens if min plays not optimal? thx
Tim
  • 51
  • 1
  • 2
5
votes
1 answer

How to implement a transposition table for connect 4?

I'm making a connect 4 AI in python, and I'm using minimax with iterative deepening and alpha beta pruning for this. For greater depths it's still quite slow, so I wanted to implement a transposition table. After reading up on it I think i get the…
5
votes
3 answers

Minimax algorithm for Tictactoe in Python

I recently enrolled to CS50 AI python course and one the projects to do is to implement a minimax algorithm for a tictactoe game. I looked for help and searched stackoverflow but I didn't find an answer that could help me. The graphic part of it is…
Albert
  • 63
  • 1
  • 4
5
votes
1 answer

How to improve performance using Transposition Table in Game Playing?

I have implemented iterative deepening with alpha-beta pruning in my game and I also added a Transposition Table to store already evaluated boards. Right now, I am doing the following: When running iterative deepening, at depth = 0 it evaluates and…
5
votes
1 answer

Attempting to use continuation passing style to avoid stack overflow with minimax algorithm

Summary of my objective: Figure out how to use continuation-passing style to avoid a stack overflow when using an algorithm I believe cannot be made tail-recursive. Alternatively, find a way to make the function tail-recursive. Details: I am new to…
5
votes
3 answers

Binary Search Doesn't work in this case?

https://leetcode.com/problems/guess-number-higher-or-lower-ii/#/description. We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I'll tell you…
wrek
  • 1,061
  • 5
  • 14
  • 26
5
votes
2 answers

Minimax algorithm for Tic Tac Toe

I'm trying to implement minimax algorithm by Jason Fox (http://neverstopbuilding.com/minimax), but it isn't working, the computer is just making moves randomly. Here is the Game class I wrote (I had to create a cloneGrid function because arrays were…
Talha Lodhi
  • 83
  • 1
  • 1
  • 7
5
votes
3 answers

What is wrong with my minimax algorithm for tictactoe

I'm building a tic tac toe game for a fun learning experience. I have constructed a minimax algorithm to return the optimal move for the computer, but somehow I am going wrong and get wierd output like this TIC TAC TOE V1.0 --- --- --- Enter row,…
shane
  • 1,742
  • 2
  • 19
  • 36
5
votes
2 answers

minimax depth first search game tree

I want to build a game tree for nine men's morris game. I want to apply minimax algorithm on the tree for doing node evaluations. Minimax uses DFS to evaluate nodes. So should I build the tree first upto a given depth and then apply minimax or can…
Arvind
  • 187
  • 1
  • 3
  • 11
5
votes
2 answers

How do we determine the time and space complexity of minmax?

I am having some trouble determining space and time complexities. For example, if I have a tree that has a branching factor b and will have at most a depth d, how can I calculate the time and space complexities? I know they are O(b^d) and O(bd), but…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
5
votes
1 answer

Mastermind minimax algorithm

I am trying to implement in python Donald Knuth's algorithm for codebreaking mastermind in not more than 5 moves. I have checked my code several times, and it seems to follow the algorithm, as its stated…
Mike
  • 195
  • 2
  • 10
1 2
3
60 61