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

Understanding constraints of Negamax

The snippet of code is constructed for calculating the bestMove of a position in a tictactoe game . I got almost every part of the code , except the condition in the for loop , which says that minRating != LOSING_POSITION . This code comes from a…
motiur
  • 1,640
  • 9
  • 33
  • 61
0
votes
2 answers

What value are alpha/beta to begin with in Minimax algorithm?

I understand the algorithm, as it applies to Alpha-Beta pruning. What I don't understand is since there is no way to represent ∞ in Java, on my first call to the Minimax method, what value should Alpha and Beta be to start out with? (Normally I…
Houdini
  • 3,442
  • 9
  • 31
  • 47
0
votes
1 answer

Is applying Minimax possible with 4 * 4 board Tic Tac Toe or need Alpha-Beta pruning?

I've implement a 3 * 3 Tic Tac Toe game in java applying Minimax algorithm only. However, when I change the board size to 4 * 4, the program seems to hang. I wanna ask whether I should apply Minimax with alpha-beta pruning to solve this problem or…
Duc Tran
  • 6,016
  • 4
  • 34
  • 42
0
votes
2 answers

Is the tree data structure needed in the alpha-beta pruning algorithm?

The alpha-beta pruning algorithm is as follows: function ALPHA-BETA-SEARCH(state) returns an action v <- MAX-VALUE(state, -∞, +∞) return the action in ACTIONS(state) with value v function MAX-VALUE(state, α, β) returns a utility value …
-1
votes
0 answers

why am i having this following error whenever i exit the tkinter window?

This is the error i am having. Whenever i run the program everything runs smoothly but as soon as i close the GUI window the following error shows on my terminal. what should i doo to eliminate the problem Exception in Tkinter callback Traceback…
-1
votes
1 answer

Minimax algorithm not working in tic tac toe game

I have recently learned about minimax and I am trying to make an unbeatable AI tic tac toe game. I don't know why my minimax function does not work and my computer sometime plays un optimal moves. This is my full code: from random import…
-1
votes
1 answer

Haskell Tree Structure Explanation

Im currently trying to write a minimax algorithm using tree in haskell for a connect four game where it takes maximum tree when its ai's turn and minimum when players. I've tried to find how use the tree structure in general such as : create, write,…
P47HF1ND3R
  • 45
  • 7
-1
votes
1 answer

TicTacToe minimax function returns moves in order of the board

I simply followed the structure of basic Minimax functions with: def player(board): if Terminal(board) != False: return None else: if turn(board) == "X": value,move = max_value(board) return move + 1 else: …
-1
votes
1 answer

Minimax method in an AI TicTacToe game

The following code describes an AI TicTacToe game(the main file is game.py) **player.py:** import math import random class Player(): def __init__(self, letter): self.letter = letter def get_move(self, game): pass class…
d2w3t
  • 13
  • 5
-1
votes
1 answer

Minimax evaluation in chess

I am implementing an artificial intelligence that plays chess using the minimax algorithm. The initial board I have is white rook and white king against black rook and black king. All the evaluations I've thought of, do not provide enough…
Sergio
  • 81
  • 4
-1
votes
2 answers

minimax alsways plays the same against itself

it is only logically that minimax alsways plays same against itself because of the way you code that but is it really right? (I wont add my code now just asking that question)
Wyrden
  • 45
  • 6
-1
votes
2 answers

why minimax don't choose the optimal solution in this situation

im doing tictactoe project for cs50 course when i was using minimax i find out the minimax in some situation couldnt find the optimal solution here is my code : """ Tic Tac Toe Player """ import copy import math X = "X" O = "O" EMPTY = None def…
-1
votes
1 answer

Why is my Minimax algorithm for chess taking so long to evaluate a move?

I am trying to create a simple chess AI in C# and have so far been successful to an extent using the minimax algorithm with alpha-beta pruning. However, with the code below it literally takes around 5 seconds for it to evaluate a move at depth 3 and…
jack
  • 1
-1
votes
1 answer

How to quickly deallocate an entire subtree?

I'm implementing an Alpha-Beta pruning (MiniMax) algorithm for a board game. I have a Board class with GetAvailableMoves(), PlayMove(Move x) and UndoMove() which all modify the game position inside the Board class. To implement Alpha-Beta I need a…
Ivan
  • 1
  • 1
-1
votes
1 answer

How to fix minimax algorithm

Required to write a minimax algorithm that returns a value from a array of random numbers, the length of which is 2 ^ depth(the algorithm works on a binary tree). my code: int minimax(int* scores, unsigned int left, unsigned int right, int depth,…