问题描述
我不知道如何用python-chess来找到特定团队的分数。我尝试了很多方法,例如white(),并查看了文档,但我只是想不通
到目前为止,这是我的代码。
import chess
import chess.engine
import random
import chess.svg
from chessboard import display
from time import sleep
engime = chess.engine
playing = True
board = chess.Board()
move_list = []
possible_moves = [""]
characters_to_remove = "()<>,"
random1 = 0
running = True
black = False
complete = False
def playermovement():
global complete
global black
if playing == True:
while black == True or complete == True:
possible_moves.clear()
print(board.legal_moves)
makepossiblemoveslist()
length = len(possible_moves)-1
random1 = random.randint(0,length)
print(len(possible_moves))
currentmove = possible_moves[random1]
move_list.append(currentmove)
black = False
complete = False
else:
currentmove = input("what is your next move?")
#with engine.analysis(chess.Board()) as analysis:
#for info in analysis:
#print(info.get("score"),info.get("pv"))
makepossiblemoveslist()
if currentmove in possible_moves:
try:
DoMove(currentmove)
black = True
except:
complete = False
def makepossiblemoveslist():
global possible_moves
moves = board.legal_moves
for character in characters_to_remove:
moves = str(moves).replace(character,"")
moves = moves[36:]
#print(moves)
possible_moves = moves.split()
def DoMove(currentmove):
print(possible_moves)
if currentmove in possible_moves:
board.push_san(currentmove)
display.update(board.fen())
complete = True
sleep(0.25)
else:
print("this is an illegal move!")
complete = False
#def minimax(position,depth,player):
display.start(board.fen())
while running == True:
playermovement()
请原谅错误的代码,任何改进的技巧都将适用!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)