Exemple #1
0
    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
Exemple #2
0
    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
Exemple #3
0
    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)
Exemple #4
0
    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
Exemple #5
0
    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
Exemple #6
0
    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)