from .minmax import * import time class Gomoku_bot: def __init__(self, board, role, depth=4, enableVCT=False): self.board = board self.role = role self.depth = depth self.enableVCT = enableVCT def get_action(self, return_time=True): start = time.time() score = minmax(self.board, self.role, self.depth, self.enableVCT) end = time.time() sim_time = end - start move = score[1] # this move starts from left up corner (0,0), however, the move in the game starts from left bottom corner (0,0) move = (self.board.size - 1 - move[0], move[1]) # convert the move to the game's coordinate # turn tuple into an int move = move[0] * self.board.size + move[1] if return_time: return move, sim_time else: return move