#原创,受人工智能启发式搜索算法所想
import copy
import time
class Tic_toc_tae():
def __init__(self):
self.chessboard=[[],[],[]]
self.line=[[],[],[],[],[],[],[],[]]
self.player_plot='x'
self.rebot_plot='o'
self.n=0
self.STOP=False
def initialation(self):
for i in range(len(self.chessboard)):
self.chessboard[i]=[' ',' ',' ']
for j in range(3):
self.line[j]=self.chessboard[j]
self.line[j+3]=[self.chessboard[j][0],self.chessboard[j][1],self.chessboard[j][2]]
self.line[6]=[self.chessboard[0][0],self.chessboard[1][1],self.chessboard[2][2]]
self.line[7]=[self.chessboard[2][0],self.chessboard[1][1],self.chessboard[2][2]]
return self.chessboard
def get_now_line(self,chessboard):
line=[[],[],[],[],[],[],[],[]]
for j in range(3):
line[j]=copy.deepcopy(chessboard[j])
line[j+3]=copy.deepcopy([chessboard[0][j],chessboard[1][j],chessboard[2][j]])
line[6]=copy.deepcopy([chessboard[0][0],chessboard[1][1],chessboard[2][2]])
line[7]=copy.deepcopy([chessboard[2][0],chessboard[1][1],chessboard[0][2]])
return line
def change_chessboard(self,keys1):
plot=self.player_plot
chessboard=copy.deepcopy(self.chessboard)
STOP=0
n=0
body=True
key=False
while(True and STOP==0):
if keys1==0:
try:
n=int(input("从小键盘输入对应位置"))
except(ValueError):
print("请重新输入")
else:
STOP=1
if keys1!=0: