addexx shineUsed and maxX
This commit is contained in:
parent
2d887a8295
commit
ffabe5e3e8
@ -36,9 +36,15 @@ def get_timestamp():
|
||||
|
||||
def mse(img1, img2):
|
||||
h, w = img1.shape
|
||||
diff = cv2.subtract(img1, img2)
|
||||
err = np.sum(diff**2)
|
||||
mse = err/(float(h*w))
|
||||
diff = 0
|
||||
mse = 0
|
||||
try:
|
||||
diff = cv2.subtract(img1, img2)
|
||||
err = np.sum(diff**2)
|
||||
mse = err/(float(h*w))
|
||||
except:
|
||||
diff = 1
|
||||
mse = .01
|
||||
return mse, diff
|
||||
|
||||
class ScryeState:
|
||||
@ -46,6 +52,7 @@ class ScryeState:
|
||||
s = {}
|
||||
stars = ""
|
||||
shine = False
|
||||
shineUsed = False
|
||||
instr = ""
|
||||
mark = ""
|
||||
qty = ""
|
||||
@ -63,6 +70,7 @@ class ScryeState:
|
||||
syell = False
|
||||
send_order = False
|
||||
x = 0
|
||||
maxX = 0
|
||||
buy_reset = {"W": 0, "Lb": 0, "B": 0, "G": 0, "Br": 0}
|
||||
sell_reset = {"R": 0, "P": 0, "L": 0, "T": 0, "Th": 0}
|
||||
|
||||
@ -121,7 +129,9 @@ class ScryeState:
|
||||
self.reset()
|
||||
self.instr = pairs
|
||||
if self.instr in HISTORY:
|
||||
self.stars = HISTORY[self.instr]
|
||||
#self.stars = HISTORY[self.instr]['stars']
|
||||
#self.shineUsed = HISTORY[self.instr]['shineUsed']
|
||||
self = HISTORY[self.instr]
|
||||
|
||||
|
||||
|
||||
@ -182,11 +192,11 @@ def scrye_log(cur, verbose, message, message_type="system"):
|
||||
#if isinstance(message,ScryeState):
|
||||
#message = f"{message}".replace("'","\"")
|
||||
#print(message)
|
||||
cur.execute(
|
||||
f"insert into logs(log_date, message, message_type) values (now(),%s, %s)",
|
||||
(message, message_type),
|
||||
)
|
||||
|
||||
try:
|
||||
cur.execute( f"insert into logs(log_date, message, message_type) values (now(),%s, %s)", (message, message_type),)
|
||||
except:
|
||||
print("dupe insert blocked")
|
||||
|
||||
|
||||
|
||||
(con, cur) = connectDB()
|
||||
@ -212,7 +222,7 @@ cl = {
|
||||
ACCESS_KEY = "OPhEO4lrn4VSwSReQPv2"
|
||||
SECRET_KEY = "khiSf1VceaprZbdyCEwvbAhWD0c72jPM1JDzVBUR"
|
||||
MINIO_CLIENT = Minio(
|
||||
"minio1.home.neb:9000", access_key=ACCESS_KEY, secret_key=SECRET_KEY, secure=False
|
||||
"minio2.home.neb:9000", access_key=ACCESS_KEY, secret_key=SECRET_KEY, secure=False
|
||||
)
|
||||
|
||||
|
||||
@ -277,6 +287,7 @@ while 1 > 0:
|
||||
instr = j
|
||||
pair_file = f"pair_{instr}.png"
|
||||
state = ScryeState(instr)
|
||||
|
||||
img = None
|
||||
|
||||
try:
|
||||
@ -298,7 +309,7 @@ while 1 > 0:
|
||||
continue
|
||||
fcur = open(f"{instr}.txt", "w")
|
||||
fcur.write("[")
|
||||
print(f"{j} STARTING WITH FRESH STATE")
|
||||
#print(f"{j} STARTING WITH FRESH STATE")
|
||||
scrye_log(cur, True, f"{{\"msg\": \"{j}\"}}")
|
||||
|
||||
pimg[pair_file] = imgx
|
||||
@ -318,16 +329,18 @@ while 1 > 0:
|
||||
for cm in STARS:
|
||||
(STARS[cm]["points"]) = process_colors(state.instr, img, STARS[cm])
|
||||
|
||||
if STARS["INDIGO"]["points"] != {} and state.stars == "indigo":
|
||||
if STARS["INDIGO"]["points"] != {} and state.stars == "indigo" and state.shineUsed:
|
||||
state.shine = False
|
||||
elif STARS["INDIGO"]["points"] != {} and state.stars != "indigo":
|
||||
state.stars = "indigo"
|
||||
state.shine = True
|
||||
elif STARS["YELLOW"]["points"] != {} and state.stars == "yellow":
|
||||
state.shineUsed = False
|
||||
elif STARS["YELLOW"]["points"] != {} and state.stars == "yellow" and state.shineUsed:
|
||||
state.shine = False
|
||||
elif STARS["YELLOW"]["points"] != {} and state.stars != "yellow":
|
||||
state.stars == "yellow"
|
||||
state.shine = True
|
||||
state.shineUsed = False
|
||||
#state.shine = True
|
||||
if state.shine != True:
|
||||
continue
|
||||
@ -358,11 +371,12 @@ while 1 > 0:
|
||||
#print(tsort)
|
||||
for x in tsort:
|
||||
state.x = x
|
||||
state.maxX = tsort[-1] - 10
|
||||
state.send_order = False
|
||||
if x >= state.actionP:
|
||||
state.action = True
|
||||
log_file(fcur, True, "{\"msg\": \"action is true\"}", state.instr)
|
||||
log_file(fcur, True, state, state.instr)
|
||||
#log_file(fcur, True, "{\"msg\": \"action is true\"}", state.instr)
|
||||
#log_file(fcur, True, state, state.instr)
|
||||
|
||||
#log_file(fcur, True, state, state.instr)
|
||||
|
||||
@ -441,7 +455,7 @@ while 1 > 0:
|
||||
state.savefile = True
|
||||
#if state.action and state.shine:
|
||||
log_file(fcur, True, "{\"msg\":\"everything shiny\"}", state.instr)
|
||||
if x +10 >= tsort[-1] and state.shine:
|
||||
if x >= state.maxX and state.shine and state.shineUsed == False:
|
||||
requests.get(
|
||||
f"http://oversite.home.neb:3000/order/{state.instr}/{state.qty}"
|
||||
)
|
||||
@ -450,8 +464,14 @@ while 1 > 0:
|
||||
cur.execute(f"select dictum from dictum where tpair = '{state.instr}'")
|
||||
cur.execute( f"insert into chronicle_history (tpair, cmd_date, dictum, glimpse) values ('{state.instr}',now(), '{state.mark}','{sendf}')")
|
||||
cur.execute( f"insert into dictum (tpair, dictum,dictum_date) values ('{state.instr}', '{state.mark}', now()) on conflict(tpair) do update set dictum = '{state.mark}', dictum_date = now()")
|
||||
log_file(fcur, True, state, state.instr)
|
||||
log_file(fcur, True, "{\"msg\":\"sending order\"}", state.instr)
|
||||
state.shineUsed = True
|
||||
log_file(fcur, True, state, state.instr)
|
||||
log_file(fcur, True, "{\"msg\":\"sending order\"}", state.instr)
|
||||
else:
|
||||
log_file(fcur, True, state, state.instr)
|
||||
print(f"{state}")
|
||||
log_file(fcur, True, "{\"msg\":\"not enough for send order\"}", state.instr)
|
||||
|
||||
state.reset_map()
|
||||
state.flip()
|
||||
state.send_order = False
|
||||
@ -462,7 +482,9 @@ while 1 > 0:
|
||||
print("write error")
|
||||
if state.savefile:
|
||||
state.savefile = False
|
||||
HISTORY[state.instr] = state.stars
|
||||
#HISTORY[state.instr]['stars'] = state.stars
|
||||
HISTORY[state.instr] = state
|
||||
#HISTORY[state.instr]['shineUsed'] = state.shineUsed
|
||||
log_file(fcur, True, state, state.instr)
|
||||
fcur.write("{}]")
|
||||
fcur.close()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user