From 466d0ca5754a70ae2bd20c730bbe080382d07780 Mon Sep 17 00:00:00 2001 From: Vadzim Valchkovich Date: Thu, 15 Jun 2023 21:39:36 +0200 Subject: [PATCH] no-log mode --- agent.py | 6 +++--- src/Engine.py | 5 ++++- src/controller/NeuralNetworkController.py | 5 ++++- src/controller/StateController.py | 9 ++++++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/agent.py b/agent.py index b667c9a..e97a787 100644 --- a/agent.py +++ b/agent.py @@ -16,12 +16,12 @@ engine = Engine(SCREEN_SIZE, SQUARE_SIZE, kitchen, waiter, ACTION_DURATION) layout = LayoutController(engine, store).create_and_subscribe(COUNT_OF_OBJECTS) -engine.loop() +# engine.loop() -''' +# ''' def example_stop(action_clock: int) -> bool: return action_clock < 1000 print(engine.train_loop(example_stop)) -''' +# ''' diff --git a/src/Engine.py b/src/Engine.py index b2ae7bc..16be145 100644 --- a/src/Engine.py +++ b/src/Engine.py @@ -83,12 +83,14 @@ class Engine: real_action_duration = self.action_duration self.action_duration = 0 self.is_simulation = True + self.predictor_c.is_simulation = True while stop_condition(self.action_clock): self.action() self.action_duration = real_action_duration self.is_simulation = False + self.predictor_c.is_simulation = False return self.serviced_tables @@ -157,7 +159,8 @@ class Engine: self.goal = None 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.revoke_goal() diff --git a/src/controller/NeuralNetworkController.py b/src/controller/NeuralNetworkController.py index c63d194..5d1be10 100644 --- a/src/controller/NeuralNetworkController.py +++ b/src/controller/NeuralNetworkController.py @@ -28,6 +28,8 @@ class NeuralNetworkController: # STEP 5. Set up path to the folder containing test images self.test_images_folder = 'dataset/testset' + self.is_simulation = False + def predict(self, image_path): # STEP 1. Load and preprocess the test image test_image = keras.preprocessing.image.load_img( @@ -44,7 +46,8 @@ class NeuralNetworkController: predicted_class_index = np.argmax(predictions[0]) 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 def random_path_img(self) -> str: diff --git a/src/controller/StateController.py b/src/controller/StateController.py index eb12405..4549e88 100644 --- a/src/controller/StateController.py +++ b/src/controller/StateController.py @@ -31,7 +31,8 @@ class StateController: self.path.append(self.path[-1].parent) 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 def graphsearch(self, engine): # A* @@ -41,7 +42,8 @@ class StateController: # STEP 1. Store 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 self.reset() @@ -73,7 +75,8 @@ class StateController: # STEP 9. Reset structures self.reset() - print(colored("Not found", "red")) + if not engine.is_simulation: + print(colored("Not found", "red")) return False