From df70b321ae4e248712094c1f04d6a00e92a47dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czeka=C5=84ski?= Date: Sun, 24 May 2020 18:38:55 +0200 Subject: [PATCH] Adjust project after new enum value addition --- data/AI_data/DecisionTreeExamples/dt_examples | 1 - src/AI/DecisionTrees/ExamplesManager.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/data/AI_data/DecisionTreeExamples/dt_examples b/data/AI_data/DecisionTreeExamples/dt_examples index 7d3806f..e69de29 100644 --- a/data/AI_data/DecisionTreeExamples/dt_examples +++ b/data/AI_data/DecisionTreeExamples/dt_examples @@ -1 +0,0 @@ -FOOD|THREE_QUARTERS_TO_FULL|ZERO_TO_QUARTER|THREE_QUARTERS_TO_FULL|GE_8|LT_3|GE_3_LT_8 \ No newline at end of file diff --git a/src/AI/DecisionTrees/ExamplesManager.py b/src/AI/DecisionTrees/ExamplesManager.py index f9f3c08..21e081a 100644 --- a/src/AI/DecisionTrees/ExamplesManager.py +++ b/src/AI/DecisionTrees/ExamplesManager.py @@ -21,9 +21,11 @@ class ExamplesManager: file = open(self.examplesFilePath, "r") - line = file.readline() lineNum = 0 - while line != "": + while True: + line = file.readline() + if line == "": + break lineNum += 1 words = line.split("|") @@ -117,7 +119,6 @@ class ExamplesManager: dstFromRest) examples.append(example) - line = file.readline() file.close() return examples @@ -133,11 +134,11 @@ class ExamplesManager: example: SurvivalDTExample for example in examplesToAdd: strToWrite = "\n{}|{}|{}|{}|{}|{}|{}".format(example.classification.name, - example.hungerVal.name, - example.thirstVal.name, - example.staminaVal.name, - example.distFromFood.name, - example.distFromWater.name, - example.distFromRestPlace.name) + example.hungerVal.name, + example.thirstVal.name, + example.staminaVal.name, + example.distFromFood.name, + example.distFromWater.name, + example.distFromRestPlace.name) file.write(strToWrite) file.close()