コード例 #1
0
ファイル: module.py プロジェクト: TheSimoms/IT3105
    def run(self):
        twenty_forty_eight = TwentyFortyEight(ui=self.ui)

        twenty_forty_eight.run(twenty_forty_eight.make_player_move)

        try:
            input('Done. Press return to continue')
        except SyntaxError:
            pass
コード例 #2
0
ファイル: module.py プロジェクト: TheSimoms/IT3105
    def run(self):
        twenty_forty_eight = TwentyFortyEight(ui=self.ui)

        twenty_forty_eight.run(twenty_forty_eight.make_player_move)

        try:
            input('Done. Press return to continue')
        except SyntaxError:
            pass
コード例 #3
0
ファイル: Ann2048.py プロジェクト: TheSimoms/IT3105
    def generate_training_data(self, filename=TRAINING_DATA_FILENAME):
        """
        Generate training data sets. Play the 2048 game using A*-GAC, and write every move made to supplied file

        :param filename: Filename to save the results to
        """

        while True:
            logging.info('Starting AI run')

            twenty_forty_eight = TwentyFortyEight()
            moves = twenty_forty_eight.run(twenty_forty_eight.make_player_move,
                                           True)

            logging.info('AI run completed. Saving to file')

            with open(filename, 'a') as f:
                for move in moves:
                    game_board = self.flatten_list(move[0])
                    move_made = move[1]

                    f.write('[%s] %d\n' %
                            (','.join([str(element)
                                       for element in game_board]), move_made))

            logging.info('Moves successfully saved to file %s' % filename)
コード例 #4
0
ファイル: Ann2048.py プロジェクト: TheSimoms/IT3105
    def play_randomly():
        """
        Play 2048 using only random moves

        :return: Highest tile achieved
        """

        twenty_forty_eight = TwentyFortyEight()

        logging.info('Playing using random moves')

        result = twenty_forty_eight.run(twenty_forty_eight.make_random_move)

        logging.info('Result: %d' % result)

        return result
コード例 #5
0
ファイル: Ann2048.py プロジェクト: TheSimoms/IT3105
    def play_randomly():
        """
        Play 2048 using only random moves

        :return: Highest tile achieved
        """

        twenty_forty_eight = TwentyFortyEight()

        logging.info('Playing using random moves')

        result = twenty_forty_eight.run(twenty_forty_eight.make_random_move)

        logging.info('Result: %d' % result)

        return result
コード例 #6
0
ファイル: Ann2048.py プロジェクト: TheSimoms/IT3105
    def generate_training_data(self, filename=TRAINING_DATA_FILENAME):
        """
        Generate training data sets. Play the 2048 game using A*-GAC, and write every move made to supplied file

        :param filename: Filename to save the results to
        """

        while True:
            logging.info('Starting AI run')

            twenty_forty_eight = TwentyFortyEight()
            moves = twenty_forty_eight.run(twenty_forty_eight.make_player_move, True)

            logging.info('AI run completed. Saving to file')

            with open(filename, 'a') as f:
                for move in moves:
                    game_board = self.flatten_list(move[0])
                    move_made = move[1]

                    f.write('[%s] %d\n' % (','.join([str(element) for element in game_board]), move_made))

            logging.info('Moves successfully saved to file %s' % filename)