Exemple #1
0
    def generate_seed(self):
        MAX_ATTEMPTS = self.settings.max_attempts
        success = False

        start_time = time.time()
        for attempts in range(MAX_ATTEMPTS):

            self.shuffle()
            analyzer = Analyzer(self.data, self.settings, self.allocation)
            if analyzer.success:
                if not self.settings.egg_goals:
                    success = True
                else:
                    shift_success, goal_eggs = self.shift_eggs_to_hard_to_reach(
                        analyzer.reachable, analyzer.hard_to_reach_items)
                    if shift_success:
                        analyzer = Analyzer(self.data,
                                            self.settings,
                                            self.allocation,
                                            goals=goal_eggs)
                        if analyzer.success:
                            success = True

            if success:
                difficulty_analysis = None
                if not self.settings.hide_difficulty or self.settings.min_difficulty > 0 or self.settings.max_sequence_breakability != None:
                    # Run difficulty analysis
                    if self.settings.egg_goals: goals = analyzer.goals
                    else: goals = analyzer.hard_to_reach_items
                    difficulty_analysis = DifficultyAnalysis(
                        self.data, analyzer, goals)

                if self.settings.min_difficulty > 0:
                    if difficulty_analysis.difficulty_score < self.settings.min_difficulty:
                        success = False

                if self.settings.max_sequence_breakability != None:
                    if difficulty_analysis.breakability_score > self.settings.max_sequence_breakability:
                        success = False

            if success:
                break

        if not success:
            fail('Unable to generate a valid seed after %d attempts.' %
                 MAX_ATTEMPTS)

        time_taken = time.time() - start_time
        time_string = '%.2f seconds' % (time_taken)

        print_ln('Seed generated after %d attempts in %s' %
                 (attempts + 1, time_string))

        # Generate Visualization and Print Output:
        if False:
            Analyzer(self.data, self.settings, self.allocation, visualize=True)
            self.allocation.print_important_item_locations()

        return self.allocation, analyzer, difficulty_analysis
Exemple #2
0
def shuffle_backgrounds(stored_datas, no_laggy_backgrounds,
                        no_difficult_backgrounds):
    #start_time = time.time()
    shuffler = BackgroundShuffler(stored_datas, no_laggy_backgrounds,
                                  no_difficult_backgrounds)
    shuffler.shuffle()
    print_ln('Backgrounds shuffled')

    shuffler = RoomColorShuffler(stored_datas)
    shuffler.shuffle()
    print_ln('Tile colors shuffled')
Exemple #3
0
    def print_important_item_locations(self):
        # DEBUG CODE FOR FINDING ITEMS
        print_ln('--Item Locations--')
        for k,v in self.item_at_item_location.items():
            if v in ('PIKO_HAMMER','WALL_JUMP','RABI_SLIPPERS','AIR_JUMP','AIR_DASH','BUNNY_WHIRL','HAMMER_ROLL','SLIDING_POWDER','CARROT_BOMB','CARROT_SHOOTER','FIRE_ORB','WATER_ORB','BUNNY_STRIKE','BUNNY_AMULET','SPEED_BOOST'):
                print_ln('%s @ %s' % (v, k))

        print_ln('--Modified Constraints--')
        print_ln('\n'.join(t.name for t in self.picked_templates))
Exemple #4
0
def check_for_updates():
    result, message = fetch_latest_version_id()
    if result:
        if VERSION_STRING == message:
            result = 'You have the latest version of Randomizer.'
        else:
            result = 'Randomizer version does not match latest version.'
        sb = [
            result, '',
            'Current Version: %s' % VERSION_STRING,
            'Latest Version: %s' % message
        ]
    else:
        sb = [
            'Failed to check for updates:',
            message,
            '',
            'Current Version: %s' % VERSION_STRING,
        ]
    print_ln('\n'.join(sb))
def shuffle_music(stored_datas):
    #start_time = time.time()
    shuffler = MusicShuffler(stored_datas)
    shuffler.shuffle()
    print_ln('Music shuffled')
Exemple #6
0
def check_branch():
    print_ln(get_current_branch())