本文整理匯總了Python中rule.Rule.refresh方法的典型用法代碼示例。如果您正苦於以下問題:Python Rule.refresh方法的具體用法?Python Rule.refresh怎麽用?Python Rule.refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類rule.Rule
的用法示例。
在下文中一共展示了Rule.refresh方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: min
# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import refresh [as 別名]
def min(brd, aa= -64, depth=10, best=()):
if depth == 0:
return ((), calc(brd))
val = 64
bestmove = ()
moves = brd.getMove(brd.w)
if len(moves) == 0:
return (bestmove, 64)
if best:
moves.append(best)
for i in range(len(moves)-1, -1, -1):
if best and i < len(moves)-1 and moves[i] == best:
continue;
w = move(moves[i][0], moves[i][1], brd.w)
tmp = Brd(brd.b, w)
Rule.refresh(moves[i][1], tmp.w, tmp.b, tmp)
response = max(tmp, val, depth - 1, best=())[1]
if response < aa:
bestmove = moves[i]
val = response
break
if response < val:
bestmove = moves[i]
val = response
if val == 64: #white lose anyway
bestmove = moves[0]
return (bestmove, val)
示例2: max
# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import refresh [as 別名]
def max(brd, bb=64, depth=10, best=()):
if depth == 0:
return ((), calc(brd))
bestmove = ()
val = -64
moves = brd.getMove(brd.b)
if len(moves) == 0:
return (bestmove, -64)
if len(best) > 0:
moves.append(best)
for i in range(len(moves)-1, -1, -1):
if best and i < len(moves)-1 and moves[i] == best:
continue;
b = move(moves[i][0], moves[i][1], brd.b)
tmp = Brd(b, brd.w)
Rule.refresh(moves[i][1], tmp.b, tmp.w, tmp)
response = min(tmp, val, depth - 1, best=())[1]
if response > bb:
bestmove = moves[i]
val = response
break;
if response > val:
bestmove = moves[i]
val = response
if val == -64: #black lose anyway
bestmove = moves[0]
return (bestmove, val)
示例3: moveb
# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import refresh [as 別名]
def moveb(frm, to, brd):
brd.b = move(frm, to, brd.b)
Rule.refresh(to, brd.b, brd.w, brd)
return brd
示例4: movew
# 需要導入模塊: from rule import Rule [as 別名]
# 或者: from rule.Rule import refresh [as 別名]
def movew(frm, to, brd):
brd.w = move(frm, to, brd.w)
Rule.refresh(to, brd.w, brd.b, brd)
return brd