本文整理汇总了Python中position.Position.undo方法的典型用法代码示例。如果您正苦于以下问题:Python Position.undo方法的具体用法?Python Position.undo怎么用?Python Position.undo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类position.Position
的用法示例。
在下文中一共展示了Position.undo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import undo [as 别名]
def main():
now = Position()
token = ""
print("Welcome to mbc - Enter h for help.")
while (token != "q"):
if now:
print(now)
token = input("mbc> ")
if token == "h":
print_help()
elif token == "n":
now = Position()
elif token == "e":
score = now.evaluate()
print("White:",score[0],"Black:",score[1])
elif token == "t":
best = bestMove(now, 2)
print(best)
try:
now.movePiece(best[0],best[1])
except IllegalMoveException:
print("bestMove has returned Illegal Move")
elif token == "q":
break
elif token == "u":
now.undo()
elif token[0] == "p":
now.parseFen(token[2:])
elif token == "f":
print(now.makeFen())
else:
try:
tup = translate_notation(token)
except TranslateException as e:
print(e.msg)
else:
if now.board[tup[0]].color != now.sideToMove:
print("Illegal Move: wrong side to move")
elif len(tup) == 3:
try:
now.movePiece(tup[0],tup[1],tup[2])
except IllegalMoveException as e:
print(e.msg)
else:
try:
now.movePiece(tup[0],tup[1])
except IllegalMoveException as e:
print(e.msg)