当前位置: 首页>>代码示例>>Python>>正文


Python Position.parseFen方法代码示例

本文整理汇总了Python中position.Position.parseFen方法的典型用法代码示例。如果您正苦于以下问题:Python Position.parseFen方法的具体用法?Python Position.parseFen怎么用?Python Position.parseFen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在position.Position的用法示例。


在下文中一共展示了Position.parseFen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from position import Position [as 别名]
# 或者: from position.Position import parseFen [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)
开发者ID:buesing,项目名称:mbc,代码行数:50,代码来源:mbc.py


注:本文中的position.Position.parseFen方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。