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)
engine.loop()
# engine.loop()
'''
# '''
def example_stop(action_clock: int) -> bool:
return action_clock < 1000
print(engine.train_loop(example_stop))
'''
# '''

View File

@ -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,6 +159,7 @@ class Engine:
self.goal = None
def unattainable_goal(self):
if not self.is_simulation:
print(colored("Object unattainable", "red"))
self.objects.remove(self.goal.parent)
self.revoke_goal()

View File

@ -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,6 +46,7 @@ class NeuralNetworkController:
predicted_class_index = np.argmax(predictions[0])
predicted_class = self.class_names[predicted_class_index]
if not self.is_simulation:
print(colored("Predicted class: ", "yellow")+f"{predicted_class}")
return predicted_class

View File

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