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

Alpha-beta pruning in Common Lisp

I tried coding Alpha-beta using the pseudocode found in Wikipedia. After the program reaches (EQ depth 0) it returns the heuristic value but depth continues deacreasing causing a cycle. Right now my code looks like this: (defun ab(tab node depth a…
-1
votes
1 answer

connect four - comparison of evaluation - c

I try to implement the minimax algorithm into my connect four game. I´m done with the evaluation-function and halfway done with the algorithm-function. I just can`t find the solution for the "last" problem. Here are my functions: void minimax(field…
whatever.idc
  • 92
  • 1
  • 1
  • 10
-1
votes
2 answers

TicTacToe Minimax Algorithm Always Returns Lowest Value

I'm trying to implement a TicTacToe AI using a minimax algorithm. When it's the AI's turn to play, I call ComputerTurn (which takes in the board state, an array of ints that tracks whether a square is X, O, or empty). ComputerTurn then calls minimax…
-1
votes
1 answer

How to keep track of current player minimax algorithm

I am trying to build a tic-tac-toe game using the minimax algorithm. It is not functioning correctly yet (meaning it is generating moves that are not optimal), and I think this is because I am not accounting for the moves of the opposite player. I'm…
Galen
  • 13
  • 1
  • 3
-1
votes
1 answer

Tic tac toe implemented with lisp is finishing game instead of making a single move

I'm making a simple CLI tic-tac-toe game with an AI that uses a negamax algorithm with alpha-beta pruning using LISP and I am having problems with how the AI makes its move. Instead of making the single move that it should, it is playing out the…
Christian.M
  • 173
  • 8
-1
votes
1 answer

Why my minimax is not working

I already have tried to modify my algorithm to work better, but I haven't achieved any result. My problem is that after the first moves, if I have, for example: XX. OO. ... The Computer, instead of choosing 0 2, choses for example 1 2 and…
warwcat
  • 309
  • 3
  • 5
  • 13
-1
votes
1 answer

Warlight Game AI - MiniMax Approach

I want to code an AI for the Warlight Game. I read about the MiniMax algorithm for the TicTacToe game but I suppose this situation is different. For the TicTacToe game we have states in the nodes. But I can't imagine how to store a state of the…
user2337191
-1
votes
1 answer

Path of minimaxalpha beta

Well i have the pacman game with a global vector CharactersLocation with row, column of each character...( ex: character[0] is row of ghost1, character[1] is column of ghost1, character[2] the row of ghost2...and character[8] and character[9] are…
-1
votes
1 answer

How this evaluation function work in a Connect 4 game? (Java)

I am exploring how a Minimax algorithm can be used in a connect four game with alpha-beta pruning. So I was looking through a source code about a Connect4 player strategy and found this evaluation function: /** * Get the score of a board */ public…
steexd
  • 107
  • 1
  • 4
  • 13
-1
votes
2 answers

Building tree in Nim game

I want to create a game like Nim. The player can take 1 or M (defined) cubes and the winner is the player who takes the last cube. I will also create a minimax function, so the MAX player (always plays first) is making the best move. I started…
tath
  • 41
  • 1
  • 8
-1
votes
1 answer

Depth first Minimax Segmentation Fault

I am trying to make a reverse 4x3 tic tac toe game in c++ using a depth first search and minimax. I keep getting a segmentation fault whenever the tree is trying to get the minimax value and I'm not sure why. I've looked at my logic a bunch of times…
-1
votes
1 answer

Minimax algorithm always returns one number

I have got a problem with minimax algorithm. I want to make tic tac toe game with AI. I used JFrame to make that. So my minimax algorithm returns always number 9 and I don't know why. What's wrong ? import java.awt.GridLayout; import…
midryuk
  • 85
  • 2
  • 8
-1
votes
2 answers

Pseudocode for Minimax

I am learning minimax and was wondering my logic for minimax is correct(rough pseudocode).: fun minimax(tree, depth) { #assume the tree has already been built; if terminal node; # if we reach a node with no children, return the score; return…
lord12
  • 2,837
  • 9
  • 35
  • 47
-1
votes
1 answer

Create GO like AI - maybe with minimax algorithm?

So I'm trying to make a game that's similar to the game GO. Essentially I've got a grid of faces, and when you click on a face they turn your respective color (red and blue). You and your opponent take turns clicking on faces to color them your…
Wazzup67
  • 1
  • 1
-1
votes
2 answers

Implementing MiniMax Algorithm in Tic Tac Toe for C

I'm trying to make an unbeatable AI for a tic tac toe game, much like the one at http://perfecttictactoe.herokuapp.com/. However, since I'm still learning C, its a bit simpler as the user always goes first and there's no GUI, and ASCII art is used…
Kai Tang
  • 21
  • 1
  • 5