diff --git a/barry/eye.png b/barry/eye.png deleted file mode 100644 index 5950cf7..0000000 Binary files a/barry/eye.png and /dev/null differ diff --git a/configs/config_cresselia.json b/configs/config_cresselia.json index 82d237a..77657c7 100644 --- a/configs/config_cresselia.json +++ b/configs/config_cresselia.json @@ -1,14 +1,14 @@ { "MonitorWindow": true, "WindowPrefix": "SysDVR-Client [PID ", - "image": "./images/cresselia/cress.png", + "image": "./images/cresselia/eye.png", "view": [ - 630, - 265, - 11, - 14 + 617, + 330, + 24, + 31 ], - "thresh": 0.9, + "thresh": 0.8, "white_delay": 0.0, "advance_delay": 0, "advance_delay_2": 0, diff --git a/cresselia/eye.png b/cresselia/eye.png deleted file mode 100644 index 453d494..0000000 Binary files a/cresselia/eye.png and /dev/null differ diff --git a/images/cresselia/cress.png b/images/cresselia/cress.png deleted file mode 100644 index 2445223..0000000 Binary files a/images/cresselia/cress.png and /dev/null differ diff --git a/images/cresselia/eye.png b/images/cresselia/eye.png index ea32339..22e5749 100644 Binary files a/images/cresselia/eye.png and b/images/cresselia/eye.png differ diff --git a/src/player_blink_gui.py b/src/player_blink_gui.py index ad937d5..a496fa7 100644 --- a/src/player_blink_gui.py +++ b/src/player_blink_gui.py @@ -482,7 +482,7 @@ class Application(tk.Frame): self.s01_23.insert(1.0,s01+"\n"+s23) print([hex(x) for x in state]) - observed_blinks, observed_intervals, offset_time = rngtool.tracking_blink(self.player_eye, *self.config_json["view"], MonitorWindow=self.config_json["MonitorWindow"], WindowPrefix=self.config_json["WindowPrefix"], crop=self.config_json["crop"], camera=self.config_json["camera"], tk_window=self, th=self.config_json["thresh"], size=6) + observed_blinks, observed_intervals, offset_time = rngtool.tracking_blink(self.player_eye, *self.config_json["view"], MonitorWindow=self.config_json["MonitorWindow"], WindowPrefix=self.config_json["WindowPrefix"], crop=self.config_json["crop"], camera=self.config_json["camera"], tk_window=self, th=self.config_json["thresh"], size=7) # self.rng, adv = rngtool.reidentifyByBlinks(Xorshift(*state), observed_blinks, return_advance=True, npc=self.config_json["npc"]) self.rng, adv = rngtool.reidentifyByIntervals(Xorshift(*state), observed_intervals, return_advance=True, npc=self.config_json["npc"]) diff --git a/src/reident_test.py b/src/reident_test.py new file mode 100644 index 0000000..5428e93 --- /dev/null +++ b/src/reident_test.py @@ -0,0 +1,71 @@ +from xorshift import Xorshift +from random import randint + +# randomly generate a state to use +seed = [randint(0,0xFFFFFFFF),randint(0,0xFFFFFFFF),randint(0,0xFFFFFFFF),randint(0,0xFFFFFFFF)] +# amount of blinks used to reidentify +blink_len = 20 +# max advances to search +max_advance = 10000 +# advance when starting reidentify +reident_advance = 1001 + +# init rng +rng = Xorshift(*seed) +# advance pre-reident +rng.advance(reident_advance) + +# simulate observing player blinks +counter = 0 +observed_blinks = [] +wait = rng.rangefloat(3,12) +while observed_blinks.count(True) < blink_len: + if counter % 1 <= 0.1: + observed_blinks.append(rng.next() & 0b1110 == 0) + if wait <= 0: + wait = rng.rangefloat(3,12) + wait -= 0.1 + counter += 0.1 + +# time elapsed during reidentification +reident_time = len(observed_blinks) +# account for the maximum amount of extra advances caused by pokemon blinks +possible_length = int(reident_time*4//3) + +# begin to calc current advance +possible = [] +rng = Xorshift(*seed) +rng.next() +blink_rands = [int((r&0b1110)==0) for r in rng.getNextRandSequence(max_advance)] +# loop through all possible advances +for adv in range(max_advance-possible_length): + # slice blink_rands to only give only the random values that could happen since this advance during reidentification + blinks = blink_rands[adv:adv+possible_length] + # init index variables + i = 0 + j = 0 + # difference = the amount of pokemon blinks that must have happened for this to be possible + differences = [] + try: + while i < reident_time: + diff = 0 + # if observed_blinks[i] != blinks[j], assuming this is the correct advance, a pokemon blink must have happened inbetween + while observed_blinks[i] != blinks[j]: + diff += 1 + j += 1 + if diff != 0: + differences.append(diff) + j += 1 + i += 1 + # if pattern does not line up, check next advance + except IndexError: + continue + # at this point, only a handful of potential advances have made it through + # calculate the total amount of pokemon blinks that have happened during reident + cress_pred_blinks = sum(differences) + # add a tuple to possible that can be sorted by the amount of pokemon blinks + possible.append((cress_pred_blinks,adv)) +# get the tuple with the lowest amount of pokemon blinks +cresselia_blinks, advance = min(possible) +# display our prediction +print(f"{advance=} {cresselia_blinks=}") \ No newline at end of file diff --git a/src/rngtool.py b/src/rngtool.py index 9621e6e..a1870c9 100644 --- a/src/rngtool.py +++ b/src/rngtool.py @@ -463,14 +463,12 @@ def reidentifyByBlinks(rng:Xorshift, observed_blinks:List[int], npc = 0, search_ def reidentifyByIntervals(rng:Xorshift, rawintervals:List[int], npc = 0, search_max=10**6, search_min=0, return_advance=False)->Xorshift: """reidentify Xorshift state by intervals of observed blinks. This method is faster than "reidentifyByBlinks" in most cases since it can be reidentified by less blinking. - Args: rng (Xorshift): [description] - rawintervals (List[int]): list of intervals of blinks. 6 or more is recommended. + rawintervals (List[int]): list of intervals of blinks. 7 or more are recommended. npc (int, optional): [description]. Defaults to 0. search_max ([type], optional): [description]. Defaults to 10**6. search_min (int, optional): [description]. Defaults to 0. - Returns: Xorshift: [description] """ @@ -485,9 +483,6 @@ def reidentifyByIntervals(rng:Xorshift, rawintervals:List[int], npc = 0, search_ blinkrands = [(i, int((r&0b1110)==0)) for i,r in list(enumerate(identify_rng.getNextRandSequence(search_max)))[d::1+npc]] #prepare - - - expected_blinks_lst = [] expected_blinks = 0 lastblink_idx = -1