top of page

게시판 댓글

04052023
In 소스 코드 제출
cha0e708
2023년 5월 16일
# Tic-Tac-Toe # input, 2 numbers ''' 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2 ''' class ttt: def __init__(self): print('Tic-Tac-Toe Init S') self.map = [] self.arr = [] self.win = [] for i in range(3): v = [0] * 3 self.map.append(v) self.arr.append(v) self.win.append(v) self.drawMap() self.controller() self.winlose() def drawMap(self): for i in range(3): for j in range(3): if self.map[i][j] == 0: print('_ ',end='') elif self.map[i][j] == 1: print('O ',end='') elif self.map[i][j] == 2: print('X ',end='') print() a=0 def controller(self): for i in range (9999999999999999999): n, m = map(int, input().split()) if (i%2==0): a=1 elif (i%2==1): a=2 if (a==1): print('O turn') self.map[n][m] = 1 self.drawMap() elif(a==2): print('X turn') self.map[n][m] = 2 self.drawMap() def winlose(self): for i in range (3): for j in range (3): self.map[i][j] = self.arr[i][j].text() for i in range (3): if self.map * 3 == self.win [i][0]+self.win[i][1]+self.win[i][2]: print (self, "종료", self.map+"가 이겼습니다") if (self.map[0][0] == self.map[1][1] == self.map[2][2]): print (self.map[0][0].text, 'is the winner') if (self.map[0][0] and self.map[0][1] and self.map[0][2] == 1): print ('O is the winner') if (self.map[1][0] and self.map[1][1] and self.map[1][2] == 1): print('0 is the winner') if (self.map[2][0] and self.map[2][1] and self.map[2][2] == 1): print('O is the winner') if (self.map[0][2] and self.map[1][1] and self.map[2][0] == 1): print ('O is the winner') if (self.map[0][0] and self.map[1][0] and self.map[2][0] == 1): print ('O is the winner') x = ttt()
0
0

cha0e708

더보기
bottom of page