mirror of
https://github.com/jjaldridge2009/Project_Xs.git
synced 2024-08-18 14:59:38 +02:00
bump up reidentification blinks to 7, add reident_test.py
This commit is contained in:
parent
1ca51efed0
commit
71137cfcca
BIN
barry/eye.png
BIN
barry/eye.png
Binary file not shown.
Before Width: | Height: | Size: 1.1 KiB |
@ -1,14 +1,14 @@
|
|||||||
{
|
{
|
||||||
"MonitorWindow": true,
|
"MonitorWindow": true,
|
||||||
"WindowPrefix": "SysDVR-Client [PID ",
|
"WindowPrefix": "SysDVR-Client [PID ",
|
||||||
"image": "./images/cresselia/cress.png",
|
"image": "./images/cresselia/eye.png",
|
||||||
"view": [
|
"view": [
|
||||||
630,
|
617,
|
||||||
265,
|
330,
|
||||||
11,
|
24,
|
||||||
14
|
31
|
||||||
],
|
],
|
||||||
"thresh": 0.9,
|
"thresh": 0.8,
|
||||||
"white_delay": 0.0,
|
"white_delay": 0.0,
|
||||||
"advance_delay": 0,
|
"advance_delay": 0,
|
||||||
"advance_delay_2": 0,
|
"advance_delay_2": 0,
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 368 B |
Binary file not shown.
Before Width: | Height: | Size: 130 B |
Binary file not shown.
Before Width: | Height: | Size: 482 B After Width: | Height: | Size: 501 B |
@ -482,7 +482,7 @@ class Application(tk.Frame):
|
|||||||
self.s01_23.insert(1.0,s01+"\n"+s23)
|
self.s01_23.insert(1.0,s01+"\n"+s23)
|
||||||
|
|
||||||
print([hex(x) for x in state])
|
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.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"])
|
self.rng, adv = rngtool.reidentifyByIntervals(Xorshift(*state), observed_intervals, return_advance=True, npc=self.config_json["npc"])
|
||||||
|
|
||||||
|
71
src/reident_test.py
Normal file
71
src/reident_test.py
Normal file
@ -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=}")
|
@ -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:
|
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.
|
"""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.
|
This method is faster than "reidentifyByBlinks" in most cases since it can be reidentified by less blinking.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
rng (Xorshift): [description]
|
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.
|
npc (int, optional): [description]. Defaults to 0.
|
||||||
search_max ([type], optional): [description]. Defaults to 10**6.
|
search_max ([type], optional): [description]. Defaults to 10**6.
|
||||||
search_min (int, optional): [description]. Defaults to 0.
|
search_min (int, optional): [description]. Defaults to 0.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Xorshift: [description]
|
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]]
|
blinkrands = [(i, int((r&0b1110)==0)) for i,r in list(enumerate(identify_rng.getNextRandSequence(search_max)))[d::1+npc]]
|
||||||
|
|
||||||
#prepare
|
#prepare
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
expected_blinks_lst = []
|
expected_blinks_lst = []
|
||||||
expected_blinks = 0
|
expected_blinks = 0
|
||||||
lastblink_idx = -1
|
lastblink_idx = -1
|
||||||
|
Loading…
Reference in New Issue
Block a user