0
Reply

difficulties with backing up values in minimax (negamax)

Chess_help

Chess_help

Apr 25 2005 8:19 AM
3.4k
I'm making a chess program. Think that I understand everything about minimax and negamax, except how to back up the values from the Evaluate function. I think I have a flawless evaluate function which only counts the materialbalance, but I will make it some more clever when I have understood how to back up values. Have made a separate function, BackUp, which back up values and moves, but it doesn't work well. I have read a large number of "web pages" which explains minimax and negamax, and some of them whit code or pseudo cod for minimax and negamax in different programlanguages, but those haven't get answers to these questions. I have some questions. How to 'store' the values, and exactly where, in minimax or negamax, put in and put out the values. The pseudo cod uses to look like int NegaMax(int depth) { int best = -INFINITY; if (depth = 0) return Evaluate(); GenerateLegalMoves(); while (MovesLeft()) { MakeNextMove(); val = -NegaMax(depth - 1); // Note the minus sign here. if (val > best) best = val; } return best; } If I have understood it correctly, then Val = -NegaMax and this is an 'invoke' to the function NegaMax, and then the variable NegaMax be equal to a value, and this is one of those things that I don't understand; exactly where (and how) does the variable NegaMax get its value, and from where. And after that, val is equal to -NegaMax. If I have understand it correctly, then the function NegaMax also has to store the value in the variable 'best' in another variable, where and how is that done? In the function BackUp, I store the values in an array / index variable int value[9], but to be true, I can't much c or c++. I have wrote my program in Delphi (Pascal), so I store the values in the array: value : array [1..10] of integer. And I also store the associated " first move's " from square and to square, to the variable 'best', in the array like this; value : array [1..10, 1..10, 1..10] of integer, because I have a one-dimensional board, and the pieces at the board I store as numbers. Is that a proper / appropriate way to do it, a way that works? And when a value has been backed up one or more layers, then has the computer to set the "lower layers" to infinity and -infinity? In addition, I don't use any pruning like alpha beta pruning yet, because I want to learn me negamax first. Thanks for help in advnce.