From 994c5098313f53099196b6851e9da82713b02f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 24 May 2020 22:58:41 +0200 Subject: [PATCH] Fix calculating dst from player in dt objects --- .../DTEntities/DTSurvivalInteractable.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/AI/DecisionTrees/projectSpecificClasses/DTEntities/DTSurvivalInteractable.py b/src/AI/DecisionTrees/projectSpecificClasses/DTEntities/DTSurvivalInteractable.py index 5bed7b1..766ebe5 100644 --- a/src/AI/DecisionTrees/projectSpecificClasses/DTEntities/DTSurvivalInteractable.py +++ b/src/AI/DecisionTrees/projectSpecificClasses/DTEntities/DTSurvivalInteractable.py @@ -30,13 +30,17 @@ class DTSurvivalInteractable: distance = abs(playerX - interactable.x) + abs(playerY - interactable.y) - if distance < 3: + """ + Add + 1 everywhere, because player doesn't have to step on interactable in order to interact with it. + So for example if dst between player and object is 3, player has to go 2 fields in order to interact with this object. + """ + if distance < 3 + 1: distanceFromPlayer = DistFromObject.LT_3 - elif 3 <= distance < 8: + elif 3 + 1 <= distance < 8 + 1: distanceFromPlayer = DistFromObject.GE_3_LT_8 - elif 8 <= distance < 15: + elif 8 + 1 <= distance < 15 + 1: distanceFromPlayer = DistFromObject.GE_8_LT_15 - elif distance >= 15: + elif distance >= 15 + 1: distanceFromPlayer = DistFromObject.GE_15 else: return None