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()