コード例 #1
0
    def start(self):
        '''
        Start a game for AI model
        '''
        n_mcts = 1000

        if self.verbose:
            starttime = time.time()
            print("Self-playing...", end="")

        gameengine = GameEngine(Nx=self.Nx,
                                Ny=self.Ny,
                                player=self.player,
                                timeperiod=0.5,
                                is_selfplay=True)
        gameengine.start()
        while gameengine.update():
            pass

        if self.verbose:
            endtime = time.time()
            print("End: Run Time {0:.2f}s".format(endtime - starttime))

        data = gameengine.get_data()
        data = self.__geometry_operators(data)

        return data
コード例 #2
0
    def evaluate(self, n_playout):
        '''
        Evaluate AI model
        '''
        player = EvaluationPlayer(ai=self.ai)

        if self.verbose:
            starttime = time.time()
            print("Evaluating...", end="")

        scores = list()
        for i in range(n_playout):
            gameengine = GameEngine(Nx=self.Nx,
                                    Ny=self.Ny,
                                    player=player,
                                    timeperiod=0.5,
                                    is_selfplay=False)
            gameengine.start()
            while gameengine.update():
                pass

            score = gameengine.get_score()
            scores.append(score)

        score = np.mean(scores)

        if self.verbose:
            endtime = time.time()
            print("End: Run Time {0:.2f}s".format(endtime - starttime))

        return score