Archived

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

PacketLoss

NegaMax help

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 this post


Link to post
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 this post


Link to post
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;
}

Share this post


Link to post
Share on other sites