Code: Select all
def pvs_LMR(self,alpha,beta,nodetype):
global count
count+=1
if(self.d==0):
return self.value
else:
for i in xrange(0,self.w):
if nodetype==PV and i==0:
s=-self.tree[i].pvs_LMR(-beta,-alpha,PV)
if s>=beta:
return s
elif s>alpha:
alpha=s
else:
if nodetype==PV or nodetype==ALL: # if nodetype==PV then i>0
nodetype_child=CUT
else:
nodetype_child=ALL
#Fake LMR
if nodetype==ALL:
s=rand() # fake result of LMR search
if s <= alpha:
s=-self.tree[i].pvs_LMR(-beta,-alpha,nodetype_child)
elif nodetype==CUT:
s=rand() # fake result of LMR search
if s>=beta:
s=-self.tree[i].pvs_LMR(-beta,-alpha,nodetype_child)
elif nodetype==PV:
s =-self.tree[i].pvs_LMR(-alpha-1,-alpha,nodetype_child)
else: #no LMR at other node types
s =-self.tree[i].pvs_LMR(-beta,-alpha,nodetype_child)
if nodetype==PV and s>alpha: # PVS research
# Normally we could raise alpha here
# but with our broken LMR this fails
###########################
#if s>=beta:
# return s
#alpha=s
###########################
s=-self.tree[i].pvs_LMR(-beta,-alpha,PV)
if s>=beta:
return s;
elif s>alpha:
alpha=s
return alpha