Variant form of minimax search that relies on the zero-sum property of a two-player game. The objective is to find the best move for the player that's playing at the root node.
Questions tagged [negamax]
62 questions
2
votes
1 answer
Converting Minimax to Negamax (python)
I'm making an Othello player, and implemented a minimax algorithm with alpha-beta pruning. Then I did a bunch of research on the best ones online and keep hearing about a "negamax" algorithm that they all use. It seems like most people think negamax…

singmotor
- 3,930
- 12
- 45
- 79
2
votes
1 answer
Negamax not working beyond depth 1
I am making a chess engine in C++ and with this algorithm, I get expected play with max depth set to 1. Beyond that however, it ignores pieces that are in danger and seems to even willingly put itself in danger.
Here is my code:
int negamax(int…

TheWaterIsCold
- 85
- 6
1
vote
0 answers
Can't implement alpha beta pruning on negamax
I'm struggling to get this code working, there is a problem somewhere but I can't understand where.
I'm developing a simple AI for a generalized TicTacToe and I would like to use negamax instead of MiniMax, with alpha-beta pruning.
The problem is…

Marco Coppola
- 66
- 3
1
vote
1 answer
(Chess) Problem with negamax search missing checkmate
I'm implementing a search algorithm into the search function with Negamax with alpha-beta pruning. However, it often misses forced checkmate.
(Note: "Mate in X" counts whole turns, while "depth" and "move(s)" relies on half moves.)
Example
The…

羅凋守 WitherClubtw
- 13
- 2
1
vote
1 answer
Predicting remaining runtime for minimax algorithm with alpha-beta-pruning
Problem
I am trying to solve a perfekt information zero-sum game (like tick-tack-toe or chess) using a negamax algorithm with alpha-beta-pruning. The goal is to proof wheter one player can force a win or draw. This means that there is no depth-limit…

wuerfelfreak
- 2,363
- 1
- 14
- 29
1
vote
0 answers
Problem setting the best move in the Negamax algorithm
Hey i am tring to make a chess engine but when i run the code it plays fine, the problem is sometimes it does not set the best move and it shows an error becuase the search did not return a move to play. My negamax includes AB pruning, MD Pruning,…

Nicholas English
- 11
- 2
1
vote
0 answers
How to get the predicted move sequence that a negamax algorithm is basing its evaluation upon?
My chess algorithm is based on negamax. The relevant part is:
private double deepEvaluateBoard(Board board, int currentDepth, double alpha, double beta, Move initialMove) {
if (board.isCheckmate() || board.isDraw() || currentDepth <= 0) {
…

K. Raivio
- 100
- 8
1
vote
1 answer
Saving valid moves in Negamax makes little to no difference in speed
I have a normal Negamax algorithm with alpha-beta pruning which is initiated with iterative deepening (ID). I thought that to really get use of ID I save the calculated valid moves from depth 1 in a table, so next time I go for depth 2 and the same…

eligolf
- 1,682
- 1
- 6
- 22
1
vote
1 answer
Negamax Cut-off Return Value?
I have a problem with my Negamax algorithm and hope someone could help me.
I'm writing it in Cython
my search method is a following:
cdef _search(self, object game_state, int depth, long alpha, long beta, int max_depth):
if depth == max_depth or…

Pascal Sochacki
- 69
- 1
- 5
1
vote
1 answer
Translating minimax function from Java to JavaScript
This is gonna be a big wall of code, but I hope somebody out there has the time and patience to help me.
I'm currently trying to create an AI player for my HTML Tic-Tac-Toe game. I'm using this resource which contains working AI player code…

DaDo
- 443
- 1
- 6
- 20
1
vote
2 answers
How to parallelize a negamax algorithm?
Is there a way to parallelize the following negamax algorithm?
01 function negamax(node, depth, color)
02 if depth = 0 or node is a terminal node
03 return color * the heuristic value of node
04 bestValue := −∞
05 foreach child…

Pietro Gerace
- 45
- 1
- 10
1
vote
1 answer
adding alpha beta to negamax
I'm implementing a version of Negamax for "Chain Reaction" game. Here there is a version of the algorithm that works good:
public int[] think(Field field, int profondita, int alpha, int beta,
int color) {
// TODO Auto-generated method…

Pietro Gerace
- 45
- 1
- 10
1
vote
2 answers
C++ Negamax alpha-beta wrong cutoff?
I've been using negamax to play connect four. The thing I noticed is, that if I add alpha-beta it gives sometimes "wrong" results, as in making a losing move I don't believe it should make with the depth I am searching at. If I remove the alpha-beta…

lightxbulb
- 1,251
- 12
- 29
1
vote
1 answer
Negamax C++ Implemention Give Wrong Result
NOTE: Please comment if you think this post looks to you not having adequate details e.g. codes, results and other stuff; I will edit the post accordingly.
NOTE 2: I wrote this program by hand myself.
I have a negamax implementation the result of…

stucash
- 1,078
- 1
- 12
- 23
1
vote
0 answers
negaMax algorithm producing some odd results
I'm currently implementing a checkers game and the only thing holding me be back is the poor state of my AI. It's being written in Groovy.
I have the following (attempted) negaMax algorithm with alpha, beta pruning. I've followed several pseudo…

Luke Vincent
- 1,266
- 2
- 19
- 35