NegaMax help

Started by
1 comment, last by PacketLoss 20 years, 10 months ago
Hello again Ive implemented the negamax algorithm for my connect 4 game, but now i have a tiny problem. In my minimax aprouch to the problem i used the folowing "values" if player won return 100 if opponent won return -100 else return 0 Should i keep this or should i invert them, so that when the player wins the leaf returns -100?? Thx for your time. [edited by - PacketLoss on May 28, 2003 9:37:33 AM]
Advertisement
In negamax, you return the score from the point of view of the side to move . So if the side to move has lost, then you would return -100, and if the side to move has won, you would return +100.
Also, you should negate the score each time you return it. Here is an example, taken from this webpage:

int AlphaBeta(int depth, int alpha, int beta){    if (depth == 0)        return Evaluate();    GenerateLegalMoves();    while (MovesLeft()) {        MakeNextMove();        val = -AlphaBeta(depth - 1, -beta, -alpha); // <-- ***NEGATE HERE***        UnmakeMove();        if (val >= beta)            return beta;        if (val > alpha)            alpha = val;    }    return alpha;} 

This topic is closed to new replies.

Advertisement