def run(self): self.ai = searcher() self.ai.board = self.board # turn, depth # turn = 2 玩家先手,AI后手 # turn = 1 AI先手,玩家后手 score, x, y = self.ai.search(self.turn, 2, BLACKAI=0) # huzy added self.ai_tmp = searcher() self.ai_tmp.board = copy.deepcopy(self.board) self.ai_tmp.board[x][y] = self.turn #########gkh: global now_value, last_value if now_value != 0: last_value = now_value now_value = self.ai_tmp.evaluator.evaluate(self.ai_tmp.board, self.turn, BLACKAI=0) # huzy added end ##########gkh:learning weight function difference = 0 if last_value != 0: difference = get_difference(discount) print('difference is', difference) if difference != 0: learning_weight(learning_rate, difference, self.turn) self.ai_tmp.evaluator.count_evaluate(self.ai_tmp.board, self.turn) ################ self.finishSignal.emit(x, y)
def run(self): self.ai = searcher() self.ai.board = self.board # turn, depth # turn = 2 玩家先手,AI后手 # turn = 1 AI先手,玩家后手 score, x, y = self.ai.search(self.turn, 2, BLACKAI=1) self.finishSignal.emit(x, y)
def __init__(self,master,height=0,width=0): self.frame = Frame(master) self.frame.pack() self.printButton = Button(self.frame,text='game message',command=self.printMessage) self.printButton.pack(side=LEFT) self.quitButton = Button(self.frame,text='quit',command=self.frame.quit) self.quitButton.pack(side=RIGHT) self.orderButton = Button(self.frame,text='let computer go first',command=self.setturn) self.orderButton.pack(side=LEFT) self.canvas = Canvas(master,height=500,width=500)#range of our gameboard self.draw_board() self.canvas.bind('<Button-1>',self.gameloop) self.canvas.pack()# packs widgets in rows or columns self.turn=1 self.g = ai.game() self.s = ai.searcher() self.s.board = self.g.board self.depth = 2
def run(self): self.ai = searcher() self.ai.board = self.board x, y = self.ai.search(2, 2) self.finishSignal.emit(x, y)