Пример #1
0
    def execute(self):
        reset_region = as64core.get_region(as64core.RESET_REGION)
        # TODO: SWITCH TO USING FADE_STATUS
        # If centre of screen is black, and the current split conditions are met, trigger split
        if is_black(reset_region, self._black_threshold) and as64core.incoming_split(star_count=False) and as64core.current_split().split_type == as64core.SPLIT_FADE_ONLY:
            as64core.split()
            self._split_occurred = True

        # Check for a match against the reset_template (SM64 logo)
        if as64core.fade_status == self._is_reset(reset_region, self._reset_template):
            as64core.enable_predictions(True)
            self._split_occurred = False
            self._reset()
            return self.signals["RESET"]
        elif self._is_reset(reset_region, self._reset_template_2):
            as64core.enable_predictions(True)
            self._split_occurred = False
            self._reset()
            return self.signals["RESET"]

        # If both star count, and life count are still black, reprocess fadeout, otherwise fadeout completed
        if as64core.fade_status in (as64core.FADEOUT_COMPLETE, as64core.FADEOUT_PARTIAL):
            return self.signals["LOOP"]
        else:
            as64core.enable_predictions(True)
            self._split_occurred = False
            return self.signals["COMPLETE"]
Пример #2
0
    def execute(self):
        no_hud = as64core.get_region(as64core.GAME_REGION)

        if as64core.fade_status == as64core.FADEOUT_COMPLETE:
            if self.orange_found and self.green_found:
                as64core.split()
            return ProcessLBLJ.FADEOUT

        if cv2.inRange(no_hud, self.green_lower_bound,
                       self.green_upper_bound).any():
            portal_mask = cv2.inRange(no_hud, self.green_lower_bound,
                                      self.green_upper_bound)
            output = cv2.bitwise_and(no_hud, no_hud, mask=portal_mask)
            cv2.imwrite("green.png", output)
            self.green_found = True

        if cv2.inRange(no_hud, self.purple_lower_bound,
                       self.purple_upper_bound).any() and cv2.inRange(
                           no_hud, self.green_lobby_lower_bound,
                           self.green_lobby_upper_bound).any(
                           ) and not self.green_found:
            #portal_mask = cv2.inRange(no_hud, self.purple_lower_bound, self.purple_upper_bound)
            #output = cv2.bitwise_and(no_hud, no_hud, mask=portal_mask)
            #cv2.imwrite("purple.png", output)
            self.orange_found = True

        return Process.LOOP
Пример #3
0
    def execute(self):
        if as64core.fade_status in (as64core.FADEOUT_PARTIAL,
                                    as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        if as64core.xcam_count == 1:
            as64core.split()
            return self.signals["ENTERED"]
        else:
            return self.signals["LOOP"]
Пример #4
0
    def execute(self):
        if as64core.incoming_split() and as64core.fade_status == as64core.FADEIN_COMPLETE:
            as64core.split()

        if as64core.fade_status == as64core.FADEIN_PARTIAL:
            return self.signals["LOOP"]
        else:
            # TODO: BUG: Fadein transition oscillation
            # Returns complete signal, transitions to star_count, is still white, transitions back on loop
            return self.signals["COMPLETE"]
Пример #5
0
    def execute(self):
        if as64core.fade_status in (as64core.FADEOUT_PARTIAL,
                                    as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        if not self._star_visible():
            as64core.split()
            print("Grabbed!")
            return self.signals["COMPLETE"]

        return self.signals["LOOP"]
Пример #6
0
    def execute(self):
        region = as64core.get_region(as64core.FADEOUT_REGION)

        if as64core.fade_status in (as64core.FADEOUT_COMPLETE, as64core.FADEOUT_PARTIAL):
            return self.signals["FADEOUT"]
        else:
            if as64core.split_index() > 0:
                prev_split_star = as64core.route.splits[as64core.split_index() - 1].star_count
            else:
                prev_split_star = as64core.route.initial_star

            if as64core.prediction_info.prediction == as64core.star_count and as64core.prediction_info.probability > config.get(
                    "thresholds", "probability_threshold"):
                as64core.enable_fade_count(True)
                as64core.enable_xcam_count(True)
                as64core.set_in_game(True)
                return self.signals["COMPLETE"]
            elif self._star_skip_enabled and prev_split_star <= as64core.prediction_info.prediction <= as64core.current_split().star_count and as64core.prediction_info.probability > config.get(
                    "thresholds", "probability_threshold"):
                if as64core.prediction_info.prediction == self._prev_prediction:
                    self._jump_predictions += 1
                else:
                    self._jump_predictions = 0

                if self._jump_predictions >= 4:
                    as64core.enable_fade_count(True)
                    as64core.enable_xcam_count(True)
                    as64core.set_star_count(as64core.prediction_info.prediction)
                    self._jump_predictions = 0
                    self._prev_prediction = -1
                    as64core.set_in_game(True)
                    return self.signals["COMPLETE"]

                self._prev_prediction = as64core.prediction_info.prediction

        if as64core.fadein_count == 2:
            region_int = region.astype(int)
            region_int_b, region_int_g, region_int_r = region_int.transpose(2, 0, 1)
            mask = (np.abs(region_int_r - region_int_g) > 25)

            region[mask] = [0, 0, 0]

            if np.any(region == [0, 0, 0]):
                try:
                    time.sleep(self._restart_split_delay)
                except ValueError:
                    pass
                as64core.fadein_count = 0
                as64core.fadeout_count = 0
                as64core.split()
                as64core.set_in_game(True)
                return self.signals["COMPLETE"]

        return self.signals["LOOP"]
Пример #7
0
    def execute(self):
        no_hud = as64core.get_region(as64core.NO_HUD_REGION)

        if as64core.fade_status in (as64core.FADEOUT_PARTIAL,
                                    as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        if not cv2.inRange(no_hud, self.lower_bound, self.upper_bound).any():
            as64core.split()
            return self.signals["ENTERED"]
        else:
            return self.signals["LOOP"]
Пример #8
0
    def _reset(self):
        if not config.get("general", "srl_mode"):
            if as64core.current_time - as64core.last_split < self._undo_threshold:
                as64core.undo()

            as64core.reset()
            if as64core.start_on_reset:
                as64core.split()

        as64core.enable_fade_count(False)
        as64core.enable_xcam_count(False)
        as64core.set_in_game(False)
        as64core.star_count = as64core.route.initial_star
Пример #9
0
    def execute(self):
        if as64core.fade_status in (as64core.FADEOUT_PARTIAL, as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        #if as64core.fade_status in (as64core.FADEIN_PARTIAL, as64core.FADEIN_COMPLETE):
            #return self.signals["FADEIN"]

        if as64core.incoming_split():
            if as64core.xcam_count == 0 and as64core.in_xcam and as64core.current_time - as64core.collection_time < 1:
                as64core.split()
            elif as64core.xcam_count == as64core.current_split().on_xcam:
                as64core.xcam_count = 0
                as64core.split()

        return self.signals["LOOP"]
Пример #10
0
    def execute(self):
        if as64core.fade_status in (as64core.FADEOUT_PARTIAL, as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        if as64core.fadeout_count == 1:
            as64core.fps = 29.97
            as64core.enable_predictions(not self._predictions)
            xcam = as64core.get_region(as64core.XCAM_REGION)
            lower = np.array(self.lower_bound, dtype="uint8")
            upper = np.array(self.upper_bound, dtype="uint8")

            mask = cv2.inRange(xcam, lower, upper)
            output = cv2.bitwise_and(xcam, xcam, mask=mask)

            if not is_black(output, 0.1, 0.7):
                as64core.split()
                as64core.fps = 10
                as64core.fadeout_count = 0
                as64core.set_in_game(True)
                return self.signals["START"]

        return self.signals["LOOP"]
Пример #11
0
    def execute(self):
        no_hud = as64core.get_region(as64core.GAME_REGION)

        if as64core.fade_status == as64core.FADEOUT_COMPLETE:
            c_time = time.time()
            print("Green", c_time - self.green_found_time)
            print("Red", c_time - self.red_found_time)
            print("Grey", c_time - self.grey_found_time)

            if c_time - self.red_found_time < 0.4 and c_time - self.green_found_time < 0.4 and c_time - self.grey_found_time > 0.75:
                as64core.split()
            return ProcessLBLJ.FADEOUT

        red_mask = cv2.inRange(no_hud, self.red_lower_bound,
                               self.red_upper_bound)
        red_output = cv2.bitwise_and(no_hud, no_hud, mask=red_mask)

        if not is_black(red_output, 0.1, 0.99):
            print("RED")
            self.red_found_time = time.time()

        grey_mask = cv2.inRange(no_hud, self.grey_lower_bound,
                                self.grey_upper_bound)
        grey_output = cv2.bitwise_and(no_hud, no_hud, mask=grey_mask)

        if not is_black(grey_output, 0.16, 0.88):
            cv2.imwrite("grey.png", grey_output)
            print("GREY!")
            self.grey_found_time = time.time()

        if cv2.inRange(no_hud, self.green_lower_bound,
                       self.green_upper_bound).any():
            print("GREEN FOUND!")
            self.green_found_time = time.time()

        return Process.LOOP
Пример #12
0
    def execute(self):
        if as64core.fade_status in (as64core.FADEOUT_PARTIAL, as64core.FADEOUT_COMPLETE):
            return self.signals["FADEOUT"]

        if as64core.fade_status in (as64core.FADEIN_PARTIAL, as64core.FADEIN_COMPLETE):
            return self.signals["FADEIN"]

        if as64core.prediction_info.prediction in (121, 122) and self.loop_time() > 1:
            return self.signals["FLASH"]

        if time.time() - as64core.collection_time > 11:
            self._death_check()

        if as64core.incoming_split():
            if as64core.xcam_count == 0 and as64core.in_xcam:
                as64core.split()
            elif as64core.xcam_count == as64core.current_split().on_xcam:
                as64core.xcam_count = 0
                as64core.split()

        if self.loop_time() < 6:
            return self.signals["LOOP"]
        else:
            return self.signals["COMPLETE"]