Archived

This topic is now archived and is closed to further replies.

NegaMax help

This topic is 5533 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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]

Share on other sites
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.

Share on other sites
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;}

1. 1
2. 2
3. 3
Rutin
22
4. 4
JoeJ
16
5. 5

• 14
• 29
• 13
• 11
• 11
• Forum Statistics

• Total Topics
631774
• Total Posts
3002290
×