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
18
votes
2 answers

Alpha-beta move ordering

I have a basic implementation of alpha-beta pruning but I have no idea how to improve the move ordering. I have read that it can be done with a shallow search, iterative deepening or storing the bestMoves to transition table. Any suggestions how to…
user1306283
18
votes
5 answers

Java Minimax Alpha-Beta Pruning Recursion Return

I am trying to implement minimax with alpha-beta pruning for a checkers game in Java. My minimax algorithm works perfectly. My code runs with the alpha-beta code in place. Unfortunately, when I play 1000 games vs the standard minimax algorithm, the…
sage88
  • 4,104
  • 4
  • 31
  • 41
16
votes
3 answers

Minimax explained for an idiot

I've wasted my entire day trying to use the minimax algorithm to make an unbeatable tictactoe AI. I missed something along the way (brain fried). I'm not looking for code here, just a better explanation of where I went wrong. Here is my current code…
orokusaki
  • 55,146
  • 59
  • 179
  • 257
16
votes
3 answers

Extending minimax algorithm for multiple opponents

The minimax algorithm is well described for two players for games like tic-tac-toe. I need to write an AI for a Tank game. In this game the tanks have to move in a maze that have obstacles in the form of walls. The goal is to collect coin piles. If…
AlphaWolf
  • 319
  • 1
  • 3
  • 12
15
votes
6 answers

What would be a good AI strategy to play Gomoku?

I'm writing a game that's a variant of Gomoku. Basically a tic tac toe on a huge board. Wondering if anyone knows a good AI strategy for the game. My current implementation is very stupid and takes a long time (O(n^3), approx 1-2 second to make a…
Enrico Susatyo
  • 19,372
  • 18
  • 95
  • 156
15
votes
1 answer

Computing a move score in a Minimax Tree of a certain depth

I've implemented a Chess game in C, with the following structs: move - which represents a move from (a,b) to (c,d) on a char board[8][8] (Chess board) moves - which is a linked list of moves with head and tail. Variables: playing_color is 'W' or…
Evgeny
  • 415
  • 4
  • 17
13
votes
5 answers

Alpha-beta pruning for Minimax

I have spent a whole day trying to implement minimax without really understanding it. Now, , I think I understand how minimax works, but not alpha-beta pruning. This is my understanding of minimax: Generate a list of all possible moves, up until…
11
votes
2 answers

Chess: Bug in Alpha-Beta

I am implementing a chess engine, and I have written a fairly complex alpha-beta search routine with quiescence search and transposition tables. However, I am observing a strange bug. The evaluation function is using piece-square tables, like this…
11
votes
1 answer

Implementing custom comparison with CustomComparison and CustomEquality in F# tuple

I'm here to ask a specific topic - I really found few info about this on the web. I'm implementing a F# version of Minimax algorithm. The problem I'm having now is that I want to compare Leaf of my tree (data structure below). Searching the erros…
Pedro Dusso
  • 2,100
  • 9
  • 34
  • 64
11
votes
2 answers

Using minimax search for card games with imperfect information

I want to use minimax search (with alpha-beta pruning), or rather negamax search, to make a computer program play a card game. The card game actually consists of 4 players. So in order to be able to use minimax etc., I simplify the game to "me"…
caw
  • 30,999
  • 61
  • 181
  • 291
10
votes
2 answers

Algorithm for the game of Chomp

I am writing a program for the game of Chomp. You can read the description of the game on Wikipedia, however I'll describe it briefly anyway. We play on a chocolate bar of dimension n x m, i.e. the bar is divided in n x m squares. At each turn the…
Giacomo d'Antonio
  • 2,215
  • 3
  • 19
  • 23
10
votes
1 answer

Tic Tac Toe and Minimax - Creating an imperfect AI on a microcontroller

I have created a Tic-Tac-Toe game on a microcontroller, including a perfect AI (perfect meaning that it doesn't lose). I did not use a minimax algorithm for that, just a little state machine with all possible and optimal moves. My problem now is…
9
votes
1 answer

Understanding the minimax/maximin paths (Floyd-Warshall)

I've implemented the Floyd-Warshall-Algorithm to solve the All-pairs shortest path problem. Now I found out I can also compute the minimax or maximin path with easy modifications. But I don't understand what the result means (what a minimax path…
d.hill
  • 669
  • 3
  • 9
  • 16
9
votes
1 answer

Minimax vs Alpha Beta Pruning algorithms

I recently implemented Minimax and Alpha Beta Pruning algorithms and I am 100% sure that(autograder) I implemented them correctly. But when I executed my program they behaved differently. I am 99% sure that the end state of minimax and Alpha beta…
Prethia
  • 1,183
  • 3
  • 11
  • 26
8
votes
1 answer

What is the Max value for 'float'?

When I check the value of "float.MaxValue" I'm getting: 3.402823E+38 which is: 340,282,300,000,000,000,000,000,000,000,000,000,000 Then why when I'm trying to set a much smaller value into a float variable: float myValue =…
John White
  • 101
  • 1
  • 1
  • 2
1
2 3
60 61