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

MiniMax algorithm Tic Tac Toe. Something's wrong?

I've written this code for tic-tac-toe AI implementing the MiniMax algorithm. The AI wins every time (full depth search). But there might be something wrong. Here's the output that makes me suspect the implementations correctness: 0 0 0 0 0 0 0 0…
CodeWriter
  • 77
  • 1
  • 10
0
votes
3 answers

How to Get Move From Minimax Algorithm in Tic-Tac-Toe?

So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value. However, I am confused as to how to take this value, and…
Ethan Kershner
  • 121
  • 3
  • 13
0
votes
1 answer

How should I do with evaluation function in minimax?

I want to implement PacMan game with minimax algorithm but I do not understand the meaning of algorithm fluently. I have written this code public MOVE miniMax(Game game,Node[] nodes,int depth,Boolean pacMan){ int value; MOVE…
user2944170
0
votes
1 answer

I want to modify the unbeatable tic tac to work for 5 by 5 block by introducing the depth to limit the search levels. Any suggestions?

Here's the code snippet for the minimax algorithm. For a 5 by 5 matrix it seems to take a lot of time. I want to introduce a variable that keeps track of the depth of the recursion and limits it. Here's the link to the entire code :…
Abhijay
  • 191
  • 4
  • 18
0
votes
3 answers

Java minimax abalone implementation

I want to implement Minimax in my Abalone game but I don't know how to do it. To be exact I don't know when the algo need to max or min the player. If I have understand the logic, I need to min the player and max the AI ? This is the wikipedia…
melkir
  • 405
  • 1
  • 5
  • 22
0
votes
2 answers

How to prove that every sub-section, the strategy is most optimal in minimax algorithm?

The question is as the title suggest. I know that minimax algorithm does this for 2-people game (assume we want to maximize A's profit): when it is A’s turn, we take the max of the child values because we are maximizing A's profit, and when it is…
LarsChung
  • 703
  • 5
  • 10
  • 24
0
votes
0 answers

Minimax: Should the evaluation function be different in different turns?

I am doing an AI using Minimax for dots and boxes. After the most of the work, I try some different evaluation function to find the most suitable one. But I get confused with the evaluation function one(below), for it make some stupid moves(like the…
Tony
  • 5,972
  • 2
  • 39
  • 58
0
votes
1 answer

Tic Tac Toe implements with min - max method with alfa-beta pruning is there any better solution?

There is a code implements function which assigned every status a value (both parts of min-max method) Procedure TGraph.Rate(const AState: TState); Var i: integer; Begin //hodnotí stav if AState.Children.Count > 0 then begin //není list if…
0
votes
0 answers

Variable reassigning itself - Javascript

I'm running this chess AI, and it correctly assigns the bestmove variable, but when it does its final recursion and returns the score, and bestmove, the bestmove is always undefined even though it was previously set. Why is that? var Buddha =…
TimCPogue
  • 57
  • 2
  • 8
0
votes
1 answer

Infinite recursion - Javascript minimax

I am trying to create a chess AI using the chess.js library. I am using the minimax solution with Alpha-Beta pruning, but for some reason, when the program runs it continues even after the depth reaches 0. Can anyone tell me why? var Buddha =…
TimCPogue
  • 57
  • 2
  • 8
0
votes
1 answer

Object not getting cloned - Javascript

I have a Javascript class that I need to clone to create the minimax algorithm with Alpha beta pruning in javascript. But when I pass the board object to the minimax function, its supposed to deep copy the board object then make changes, but it…
TimCPogue
  • 57
  • 2
  • 8
0
votes
1 answer

A better way to implement a "MiniMax" recursion

I'm using the MinMax algorithm for a game, and since there are a lot possibilities the MinMax recursion takes way too long, even with "alpha-beta pruning" My code looks some what like this: min(state,depth,alpha,beta): if stopingCond: …
ifryed
  • 605
  • 9
  • 21
0
votes
1 answer

Tic Tac Toe Minimax Algorithm returning empty boards

I've been struggling with implementing a miniMax algorithm for a Tic tac toe AI for a couple of days now. Right now, the problem I'm getting is that I get an empty board in the 'returnBoard' input when I call the minimax() function. I know that my…
user3126362
0
votes
0 answers

Alpha-beta in a Reversi game

I'm implementing the MiniMax algorithm for AI in a Reversi game, and I'm trying to add Alpha-Beta prunning method. If I get it correctly, the AI should choose exactly the same moves like in standard MiniMax, just in a reduced time, thanks to cutting…
Michał Szydłowski
  • 3,261
  • 5
  • 33
  • 55
0
votes
1 answer

MiniMax Algorithm for Tic Tac Toe failure

I'm trying to implement a minimax algorithm for tic tac toe with alpha-beta pruning. Right now I have the program running, but it does not seem to be working. Whenever I run it it seems to input garbage in all the squares. I've implemented it so…
user3126362