Advertisement

Alpha-beta with memory

Started by April 07, 2008 02:39 PM
-1 comments, last by tsiiiiing 16 years, 7 months ago
Hello, I have 2 questions about the implementation of this Alpha-beta with memory function: def alphaBetaWithMemory(node, alpha, beta, depth, printDepth): indent=printDepth-depth indentString=" "*indent #print indentString,"in ABwM(node=%d, alpha=%d, beta=%d, depth=%d)"%(node,alpha,beta,depth) transTableInfo=transTable.lookup(node, depth) if transTableInfo: #print indentString,"got transTableInfo: [%d, %d] depth: %d"%(transTableInfo.lowerBound, # transTableInfo.upperBound, # transTableInfo.furthestDepthSearched) if transTableInfo.lowerBound >= beta: return transTableInfo.lowerBound if transTableInfo.upperBound <= alpha: return transTableInfo.upperBound alpha = max(alpha, transTableInfo.lowerBound) beta = min(beta, transTableInfo.upperBound) terminal=isTerminal(node) if depth==0 or terminal: g=evaluate(node, AIPLAYER) #print indentString,"evaluating [%d] got %d"%(node,g) elif isMaximizing(node): g = NEGINFINITY a = alpha for c in getChildren(node): if g >= beta: break g=max(g,alphaBetaWithMemory(c, a, beta, depth-1, printDepth)) a=max(a,g) else: g = POSINFINITY b = beta for c in getChildren(node): if g <= alpha: break g = min(g,alphaBetaWithMemory(c, alpha, b, depth-1, printDepth)) b = min(b,g) if g <= alpha: transTable.storeUpperBound(node,g) elif g > alpha and g < beta: transTable.storeLowerBound(node,g) transTable.storeUpperBound(node,g) raise "never happens" else: transTable.storeLowerBound(node,g) transTable.storeDepth(node, depth) transTable.setTerminal(node, terminal) return g Source: http://www.meatengine.com/Docs/MeatEngine.AI.mtdf-pysrc.html#alphaBetaWithMemory First of all, is that true min(arg1, arg2) function return the smaller value between arg1 and arg2 ? And the bigger for max(arg1, arg2) ? My seconde question is about the name of this function. I don't understand why it called "With memory". Thank a lot. tsing

This topic is closed to new replies.

Advertisement