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
8
votes
1 answer

Why is My Minimax Not Expanding and Making Moves Correctly?

I am implementing minimax in Python 2.7.11 in a basic game of Pacman. Pacman is the maximizing agent, and one or more ghosts (depending on the test layout) is/are the minimizing agent(s). I must implement minimax so that there can be potentially…
Jodo1992
  • 745
  • 2
  • 10
  • 32
8
votes
2 answers

Can a transposition table cause search instability

I'm writing a chess engine and recently added a transposition table. When running a few tests, I found that although the search still returned the same best move, the value of the move (how good it is for the maximizing player) fluctuated. Is this…
chessprogrammer
  • 768
  • 4
  • 15
8
votes
1 answer

How to display Alpha Beta Pruning algorithm result?

Updates Update 1 I tried this (2nd line): I added changing node color as first instruction in alphabeta function. I am getting this result: Green nodes are visited nodes. It looks like, algorithm is going throw nodes correctly, right? But how to…
7
votes
1 answer

What is the difference between Minimax and Negamax?

I'm confused with these two. is Negamax just an optimization for minimax? or is Negamax is another search tree algorithm? If negamax is another search tree algorithm, then which one is better?
James Urian
  • 123
  • 3
  • 7
7
votes
2 answers

How to implement iterative deepening with alpha beta pruning

I'm writing a program to play Dots and Boxes and I want to increase my time efficiency by ordering the moves I consider in alphaBeta based on their heuristic values in a iterative deepening scheme. Essentially, I want to go into the search tree,…
A. Romer
  • 73
  • 1
  • 1
  • 7
7
votes
6 answers

How many threads are okay to use for tic-tac-toe using minimax?

Let's take a 5x5 tic-tac-toe as an example. Let's say it's my AI's turn. Then, I make 25 moves (at each cell basically, of course, if it's a legal move), create a thread for each move (25 threads total (at most)), call a minimax function on…
good_evening
  • 21,085
  • 65
  • 193
  • 298
7
votes
4 answers

Minimax algorithm

I have a simple question regarding the Minimax algorithm: for example for the tic-tac-toe game, how do I determine the utility function's for each player plays? It doesn't do that automatically, does it? I must hard-code the values in the game, it…
devoured elysium
  • 101,373
  • 131
  • 340
  • 557
6
votes
1 answer

Python chess minimax algorithm - How to play with black pieces (Bot has white)

Motivation: I am trying to make a basic AI agent that can play chess against an opponent. The goal is to see how good it can become through the use of machine learning later on and also learn a the fine details in chess that are hidden from us when…
lbragile
  • 7,549
  • 3
  • 27
  • 64
6
votes
1 answer

Minimax algorithm with memoization?

I am trying to implement a connect four AI using the minimax algorithm in javascript. Currently, it is very slow. Other than alpha-beta pruning which I will implement, I was wondering if it is worth it to hash game states to their heuristic…
Jared
  • 578
  • 7
  • 21
6
votes
2 answers

TicTacToe minimax algorithm returns unexpected results in 4x4 games

In my method newminimax499 I have a minimax algorithm that utilizes memoization and alpha beta pruning. The method works normally for 3x3 games, however when I play 4x4 games I get strange, unexpected position choices for the computer. He still…
6
votes
3 answers

Minimax algorithm: Cost/evaluation function?

A school project has me writing a Date game in C++ (example at http://www.cut-the-knot.org/Curriculum/Games/Date.shtml) where the computer player must implement a Minimax algorithm with alpha-beta pruning. Thus far, I understand what the goal is…
Dave
  • 305
  • 1
  • 3
  • 10
6
votes
1 answer

Problems with Alpha Beta for 2048

I'm writing an AI for the game 2048 using Python. It's going a lot slower than I expected. I set the depth limit to just 5 and it still took several seconds to get an answer. At first I thought my implementations of all the functions were crap, but…
6
votes
4 answers

How exactly to use "History Heuristic" in alpha-beta minimax?

I'm making an AI for a chess game. So far, I've successfully implemented the Alpha-Beta Pruning Minimax algorithm, which looks like this (from Wikipedia): (* Initial call *) alphabeta(origin, depth, -∞, +∞, TRUE) function alphabeta(node, depth, α,…
user2492270
  • 2,215
  • 6
  • 40
  • 56
6
votes
4 answers

Make the computer never lose at Tic-Tac-Toe

I am working on a simple game of Tic Tac Toe code for C. I have most of the code finished, but I want the AI to never lose. I have read about the minimax algorithm, but I don't understand it. How do I use this algorithm to enable the computer to…
C_Intermediate_Learner
  • 1,800
  • 3
  • 18
  • 22
6
votes
2 answers

How to adapt my Minimax search tree to deal with no term based game?

I have to do a project where we need to implement mancala board game, and then also implement the AI for it. We have been instructed that we need to modify or change a minimax tree to be able to work with mancala as in the game it is possible for a…
Zapnologica
  • 22,170
  • 44
  • 158
  • 253
1
2
3
60 61