From c5e626a7727934b4373c5accae834aac8d3d297a Mon Sep 17 00:00:00 2001 From: Vadzim Valchkovich Date: Sat, 10 Jun 2023 15:43:48 +0200 Subject: [PATCH] priority optimization --- src/Engine.py | 3 +++ src/obj/Object.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Engine.py b/src/Engine.py index 5230cb0..cec00f3 100644 --- a/src/Engine.py +++ b/src/Engine.py @@ -147,6 +147,9 @@ class Engine: goal_queue = PriorityQueue() + # sorting objects by distance to waiter + self.objects.sort(key=lambda o: o.distance_to(self.user.obj.position)) + for o in self.objects: condition = o.agent_role in [ diff --git a/src/obj/Object.py b/src/obj/Object.py index 4ada777..86eabc2 100644 --- a/src/obj/Object.py +++ b/src/obj/Object.py @@ -23,10 +23,13 @@ class Object: def get_angle(self): ''' - orientation = 0 -> up\n - orientation = 1 -> left\n - orientation = 2 -> down\n - orientation = 3 -> right\n + orientation = 0 -> up + + orientation = 1 -> left + + orientation = 2 -> down + + orientation = 3 -> right ''' return self.orientation * 90