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

Conversion of minimax with alpha beta pruning to negamax

I've written a minimax algorithm with alpha beta pruning for the game Checkers, and now I'm trying to rewrite it using the negamax approach. I'm expecting the two to be equivalent, since negamax is just a technique to write the minimax. But for some…
estan
  • 1,444
  • 2
  • 18
  • 29
5
votes
2 answers

Can "Monte-Carlo Tree Search" be applied on a "two player game with imperfect information" like Stratego?

I want to develop a two player game with imperfect information - "Stratego". The game is "somewhat" like chess but initially we don't know anything about the ranks of the opponent's pieces. When a piece attacks or is attacked by some opponent's…
Abhinav Chauhan
  • 1,900
  • 1
  • 18
  • 18
5
votes
3 answers

Tic Tac Toe with Minimax: Computer sometimes losing when Player goes first; works otherwise

I am working on a Minimax algorithm for unbeatable Tic Tac Toe. I need it to work both for when the Computer goes first as well as when the Player goes first. With the current version, the Computer will never lose when going first. However, it seems…
jneander
  • 1,150
  • 14
  • 34
4
votes
1 answer

Minimax implement in "Prolog Programming for Artificial Intelligence" - what are min_to_move/1 and max_to_move/1?

Let me start by saying that this question can possibly be answered by AI wizards with no Prolog experience. The excellent Prolog Programming for Artificial Intelligence book has this quite terse and clever minimax implementation: minimax( Pos,…
F. P.
  • 5,018
  • 10
  • 55
  • 80
4
votes
0 answers

Minimax algorithm AI not picking the correct choice

I have tried to impliment the minimax algorithm with alpha/beta pruning for a TicTacToe game I'm making in the Godot Engine, however, it doesn't seem to work as expected. The AI seems to always pick the next available spot on the board from left to…
4
votes
1 answer

What would Negamax' initial function call look like were it to minimize root node rather than maximize?

Negamax typically looks like the below: function negamax(node, depth, α, β, color) is if depth = 0 or node is a terminal node then return color × the heuristic value of node childNodes := generateMoves(node) childNodes :=…
gator
  • 3,465
  • 8
  • 36
  • 76
4
votes
1 answer

Is there a problem with my Negamax algorithm with alpha-beta pruning?

I'm trying to build a chess AI. My negamax function with alpha-beta pruning (ABP) runs much slower (about 8 times) than separate min and max functions also with ABP, though the moves returned are equal. My board evaluation function always returns a…
4
votes
1 answer

2048 game - AI can't score more that 256 average

I'm trying to implement AI for 2048 with MiniMax and Alpha-Beta pruning, based on a snake strategy (see this paper), which seems to be the best as a single heuristics. Unfortunately, AI makes 256 in most games, what is not much better than empty…
4
votes
1 answer

Minimax algorithm for Tic Tac Toe Python

I kind of understand how the minimax algorithm works for Tic Tac Toe python but I have no idea how to actually code it in Python... this is what I have so far: from copy import deepcopy class TicTacToeBrain : def __init__(self, player = "x")…
MTsiang
  • 73
  • 1
  • 2
  • 8
4
votes
2 answers

Implementing minimax algorithm in Javascript

As a personal exercise I'm trying to implement a minimax based tic-tac-toe game. I've been studying examples in a variety of languages I have found online. My implementation is at a point where it seems like its working but then the AI loses in…
Solomon Bothwell
  • 1,004
  • 2
  • 12
  • 21
4
votes
1 answer

When does alpha-beta search with memory return cutoff values?

I have implemented an alpha beta search with transposition table. Do I have the right ideas here about storing cutoffs in the table? Specifically, is my scheme for returning the cutoffs when a table hit occurs correct? (And likewise, storing them.)…
4
votes
2 answers

Did I implement this minimax function correctly?

It's for a game of checkers. See revision history for older versions of code. private static Move GetBestMove(Color color, Board board, int depth) { var bestMoves = new List(); var validMoves =…
mpen
  • 272,448
  • 266
  • 850
  • 1,236
4
votes
3 answers

Android Java Minimax implementation in a tic-tac-toe game

I'm trying to make a Tic-Tac-Toe Android application, of course in Java. After debugging for maybe a few hours, fixing things here and there, I have come upon a problem that I can not solve by myself at this time, with this knowledge. I have…
Filip Markoski
  • 333
  • 3
  • 19
4
votes
3 answers

Better Heuristic function for a game (AI Minimax)

There is a game that I've programmed in java. The game is simple (refer to the figure below). There are 4 birds and 1 larva. It is a 2 player game (AI vs Human). Larva can move diagonally forward AND diagonally backward Birds can ONLY move…
4
votes
0 answers

Difference between Hypermax and Approximate Deep Maxn

I do not understand the difference between Hypermax and Approximate Deep Maxn (ADP, page 87, 98). ADP predates Hypermax by about 10 years. To me it seems like the very small differences between the two algorithms can be transformed away by modifying…