no-log mode

This commit is contained in:
Vadzim Valchkovich 2023-06-15 21:39:36 +02:00
parent dae6ffb6f5
commit 466d0ca575
4 changed files with 17 additions and 8 deletions

View File

@ -16,12 +16,12 @@ engine = Engine(SCREEN_SIZE, SQUARE_SIZE, kitchen, waiter, ACTION_DURATION)
layout = LayoutController(engine, store).create_and_subscribe(COUNT_OF_OBJECTS) layout = LayoutController(engine, store).create_and_subscribe(COUNT_OF_OBJECTS)
engine.loop() # engine.loop()
''' # '''
def example_stop(action_clock: int) -> bool: def example_stop(action_clock: int) -> bool:
return action_clock < 1000 return action_clock < 1000
print(engine.train_loop(example_stop)) print(engine.train_loop(example_stop))
''' # '''

View File

@ -83,12 +83,14 @@ class Engine:
real_action_duration = self.action_duration real_action_duration = self.action_duration
self.action_duration = 0 self.action_duration = 0
self.is_simulation = True self.is_simulation = True
self.predictor_c.is_simulation = True
while stop_condition(self.action_clock): while stop_condition(self.action_clock):
self.action() self.action()
self.action_duration = real_action_duration self.action_duration = real_action_duration
self.is_simulation = False self.is_simulation = False
self.predictor_c.is_simulation = False
return self.serviced_tables return self.serviced_tables
@ -157,7 +159,8 @@ class Engine:
self.goal = None self.goal = None
def unattainable_goal(self): def unattainable_goal(self):
print(colored("Object unattainable", "red")) if not self.is_simulation:
print(colored("Object unattainable", "red"))
self.objects.remove(self.goal.parent) self.objects.remove(self.goal.parent)
self.revoke_goal() self.revoke_goal()

View File

@ -28,6 +28,8 @@ class NeuralNetworkController:
# STEP 5. Set up path to the folder containing test images # STEP 5. Set up path to the folder containing test images
self.test_images_folder = 'dataset/testset' self.test_images_folder = 'dataset/testset'
self.is_simulation = False
def predict(self, image_path): def predict(self, image_path):
# STEP 1. Load and preprocess the test image # STEP 1. Load and preprocess the test image
test_image = keras.preprocessing.image.load_img( test_image = keras.preprocessing.image.load_img(
@ -44,7 +46,8 @@ class NeuralNetworkController:
predicted_class_index = np.argmax(predictions[0]) predicted_class_index = np.argmax(predictions[0])
predicted_class = self.class_names[predicted_class_index] predicted_class = self.class_names[predicted_class_index]
print(colored("Predicted class: ", "yellow")+f"{predicted_class}") if not self.is_simulation:
print(colored("Predicted class: ", "yellow")+f"{predicted_class}")
return predicted_class return predicted_class
def random_path_img(self) -> str: def random_path_img(self) -> str:

View File

@ -31,7 +31,8 @@ class StateController:
self.path.append(self.path[-1].parent) self.path.append(self.path[-1].parent)
total_cost += self.path[-1].cost total_cost += self.path[-1].cost
print(colored(f"Total path cost: ", "green")+f"{total_cost}") if not engine.is_simulation:
print(colored(f"Total path cost: ", "green")+f"{total_cost}")
return self.path return self.path
def graphsearch(self, engine): # A* def graphsearch(self, engine): # A*
@ -41,7 +42,8 @@ class StateController:
# STEP 1. Store goal position # STEP 1. Store goal position
self.goal = engine.goal.position self.goal = engine.goal.position
print(colored(f"Search path to ", "yellow")+f"{self.goal}") if not engine.is_simulation:
print(colored(f"Search path to ", "yellow")+f"{self.goal}")
# STEP 2. Reset structures # STEP 2. Reset structures
self.reset() self.reset()
@ -73,7 +75,8 @@ class StateController:
# STEP 9. Reset structures # STEP 9. Reset structures
self.reset() self.reset()
print(colored("Not found", "red")) if not engine.is_simulation:
print(colored("Not found", "red"))
return False return False