1 回答
TA贡献1805条经验 获得超9个赞
更新您的board_check_x功能。
试试这个:
def board_check_x():
board_check_board = ["null", board['1'], board['2'], board['3'] ,board['4'],board['5'],board['6'],board['7'],board['8'],board['9']]
if "|X|" == board_check_board[1] and "|X|" == board_check_board[2] and "|X|" == board_check_board[3]:
player_win("2")
elif "|X|" == board_check_board[4] and "|X|" == board_check_board[5] and "|X|" == board_check_board[6]:
player_win("2")
elif "|X|" == board_check_board[7] and "|X|" == board_check_board[8] and "|X|" == board_check_board[9]:
player_win("2")
elif "|X|" == board_check_board[1] and "|X|" == board_check_board[4] and "|X|" == board_check_board[7]:
player_win("2")
elif "|X|" == board_check_board[2] and "|X|" == board_check_board[5] and "|X|" == board_check_board[8]:
player_win("2")
elif "|X|" == board_check_board[3] and "|X|" == board_check_board[6] and "|X|" == board_check_board[9]:
player_win("2")
elif "|X|" == board_check_board[1] and "|X|" == board_check_board[5] and "|X|" == board_check_board[9]:
player_win("2")
elif "|X|" == board_check_board[3] and "|X|" == board_check_board[5] and "|X|" == board_check_board[7]:
player_win("2")
如果你的 o 有效,这应该适用于 x。我只是重构了您的 o 函数,以便在我的编辑器中使用两个快速正则表达式查找 x。
添加回答
举报