예제 #1
0
    def init_game(self):
        #Init game
        for x in range(3):
            for y in range(3):
                #Adding actual buttons to the grid
                self.grid[x][y][0].set(" ")
                self.gameFrame.columnconfigure(y, weight=1)
                self.gameFrame.rowconfigure(x, weight=1)

                self.grid[x][y][1]=tk.Button(self.gameFrame, textvariable=self.grid[x][y][0], font=('Terminus', 24, "bold"),  command= lambda cell = self.grid[x][y]: self.move(cell), bg = "#002b36", fg= "RED")
                self.grid[x][y][1].grid(row=y, column=x, sticky=tk.N+tk.S+tk.W+tk.E)
        
        #Initialize game
        self.players = ("X", "O") 
        self.currentPlayer = random.choice(self.players)

        self.bot = False 

        if self.currentPlayer == "X":
            self.aiPlayer = Basic_AI("O")
        else:
            self.aiPlayer = Basic_AI("X")