new ui elements for timing
This commit is contained in:
@@ -130,7 +130,7 @@ class PrimaryOverlay(threading.Thread):
|
||||
|
||||
self.global_timeout_label = tk.Label(self.timing_frame, text="Stop after (h):", font=("Helvetica", 10, "bold"),
|
||||
background="grey", width='13')
|
||||
self.hourly_breaks_label = tk.Label(self.timing_frame, text="Breaks per hour:", font=("Helvetica", 10, "bold"),
|
||||
self.hourly_breaks_label = tk.Label(self.timing_frame, text="Breaks:", font=("Helvetica", 10, "bold"),
|
||||
background="grey", width='13')
|
||||
self.break_duration_label = tk.Label(self.timing_frame, text="Break time (m):", font=("Helvetica", 10, "bold"),
|
||||
background="grey", width='13')
|
||||
@@ -139,7 +139,7 @@ class PrimaryOverlay(threading.Thread):
|
||||
self.hourly_breaks_entry = tk.Entry(self.timing_frame, textvariable=self.hourly_breaks_use, font=("Helvetica", 10, "bold"),
|
||||
width='2')
|
||||
self.break_duration_entry = tk.Entry(self.timing_frame, textvariable=self.break_duration_use, font=("Helvetica", 10, "bold"),
|
||||
width='2')
|
||||
width='2', state=tk.DISABLED)
|
||||
|
||||
|
||||
|
||||
|
||||
11
crops.py
11
crops.py
@@ -57,17 +57,6 @@ class Crops(GameBase):
|
||||
|
||||
self.set_color_order((GREEN, YELLOW, RED, BLUE, PURPLE))
|
||||
|
||||
def execute_main_loop(self):
|
||||
while True:
|
||||
if self.overlay.run_mode == 'paused':
|
||||
cv.waitKey(1)
|
||||
continue
|
||||
elif self.overlay.run_mode == 'stopped':
|
||||
break
|
||||
|
||||
self.assess_playfield_and_make_move()
|
||||
cv.waitKey(500)
|
||||
|
||||
def set_color_order(self, order):
|
||||
self.needles.clear()
|
||||
self.needles = {order[0]: cv.imread("crop/green.jpg", cv.IMREAD_COLOR),
|
||||
|
||||
10
farm.py
10
farm.py
@@ -58,16 +58,6 @@ class Farm(GameBase):
|
||||
ARTISENT: cv.imread("farm/artisent.jpg", cv.IMREAD_COLOR)
|
||||
}
|
||||
|
||||
def execute_main_loop(self):
|
||||
while True:
|
||||
if self.overlay.run_mode == 'paused':
|
||||
cv.waitKey(1)
|
||||
continue
|
||||
elif self.overlay.run_mode == 'stopped':
|
||||
break
|
||||
|
||||
self.assess_playfield_and_make_move()
|
||||
|
||||
def assess_playfield_and_make_move(self):
|
||||
|
||||
new_observation, new_screenshot = self.get_current_board_state()
|
||||
|
||||
@@ -5,6 +5,7 @@ import numpy as np
|
||||
from window_capture import WindowCapture
|
||||
from vision import Vision
|
||||
from config_file import UserConfigs
|
||||
from time import time
|
||||
|
||||
GREEN = 1
|
||||
YELLOW = 2
|
||||
@@ -49,6 +50,10 @@ class GameBase:
|
||||
|
||||
self.reset_counter = 0
|
||||
|
||||
self.stop_time = overlay.global_timeout_use.get()
|
||||
self.breaks = overlay.hourly_breaks_use.get()
|
||||
self.break_time = overlay.break_duration_use.get()
|
||||
|
||||
# initialize the user-class
|
||||
self.config = UserConfigs()
|
||||
# initialize the StunWindowCapture class
|
||||
@@ -56,6 +61,33 @@ class GameBase:
|
||||
# initialize the StunVision class
|
||||
self.vision_stun = Vision()
|
||||
|
||||
def execute_main_loop(self):
|
||||
start_time = time()
|
||||
breaks = []
|
||||
#breaks.append(7)
|
||||
for i in range(1, int(self.breaks) + 1, 1):
|
||||
avr_in_sec = int(self.stop_time) * 60 * 60 / int(self.breaks)
|
||||
breaks.append(random.randint(i * avr_in_sec * 0.60, i * avr_in_sec))
|
||||
while True:
|
||||
if (time() - start_time) > float(self.stop_time) * 60 * 60:
|
||||
self.overlay.run_mode = 'stopped'
|
||||
for break_ in breaks:
|
||||
elapsed = int(time() - start_time)
|
||||
if elapsed > break_:
|
||||
cv.waitKey(random.randint(1, 3) *60*1000)
|
||||
breaks.remove(break_)
|
||||
if self.overlay.run_mode == 'paused':
|
||||
cv.waitKey(1)
|
||||
continue
|
||||
elif self.overlay.run_mode == 'stopped':
|
||||
break
|
||||
|
||||
self.assess_playfield_and_make_move()
|
||||
cv.waitKey(500)
|
||||
|
||||
def assess_playfield_and_make_move(self):
|
||||
pass
|
||||
|
||||
def fill_data_coordinates(self):
|
||||
# 230 to 2110 = 1883 / 14 = 134.5
|
||||
# 60 to 1130 = 1076 / 8 = 134.5
|
||||
|
||||
Reference in New Issue
Block a user