diff --git a/data/images/entities/herb1.png b/data/images/entities/herb1.png new file mode 100644 index 0000000..f24b264 Binary files /dev/null and b/data/images/entities/herb1.png differ diff --git a/data/images/entities/herb2.png b/data/images/entities/herb2.png new file mode 100644 index 0000000..a129e70 Binary files /dev/null and b/data/images/entities/herb2.png differ diff --git a/data/mapdata/mapEntities.json b/data/mapdata/mapEntities.json index f49f321..0c3e617 100644 --- a/data/mapdata/mapEntities.json +++ b/data/mapdata/mapEntities.json @@ -459,5 +459,35 @@ "y": 15 }, "isPickupable" : false + }, + { + "name" : "herb1", + "position" : { + "x": 12, + "y": 12 + }, + "isPickupable": true, + "effect" : { + "hp" : 0, + "stamina" : 0, + "thirst" : 0, + "hunger" : 0 + }, + "type" : "herb" + }, + { + "name" : "herb2", + "position" : { + "x": 14, + "y": 8 + }, + "isPickupable": true, + "effect" : { + "hp" : 0, + "stamina" : 0, + "thirst" : 0, + "hunger" : 0 + }, + "type" : "herb" } ] \ No newline at end of file diff --git a/src/AI/resultsExplorer/results.txt b/src/AI/resultsExplorer/results.txt new file mode 100644 index 0000000..8f33e77 --- /dev/null +++ b/src/AI/resultsExplorer/results.txt @@ -0,0 +1,41 @@ +GA Results from 2020-05-25 14:52:10.398825 +Population: 0 +Best fitness: 71 +Best offspring: [0.4617656024456773, 0.5990607970781336, 0.44395485033011356, 0.3943162694343978] + +Population: 1 +Best fitness: 125 +Best offspring: [0.4241776287024901, 0.7330816824377345, 0.5033842793318899, 0.5250431705157725] + +Population: 2 +Best fitness: 130 +Best offspring: [0.5997880055122891, 0.6462721899244326, 0.23090549744347125, 0.6682296855487012] + +Population: 3 +Best fitness: 130 +Best offspring: [0.5997880055122891, 0.622805396229243, 0.23361305509908434, 0.6015199688363583] + +Population: 4 +Best fitness: 130 +Best offspring: [0.5853943750328781, 0.6680555543169949, 0.31129888112036036, 0.6300813433522894] + +Population: 5 +Best fitness: 181 +Best offspring: [0.5745485398305222, 0.6613255347457894, 0.27558572895124217, 0.698772916997859] + +Population: 6 +Best fitness: 186 +Best offspring: [0.5709501322106695, 0.6734792710611923, 0.26190097471811163, 0.6632002687383984] + +Population: 7 +Best fitness: 186 +Best offspring: [0.5847284354417799, 0.6529132370776863, 0.2597728412225748, 0.6725458259803849] + +Population: 8 +Best fitness: 186 +Best offspring: [0.591617587057335, 0.6603693158815798, 0.2612154609367813, 0.6339049209442479] + +Population: 9 +Best fitness: 186 +Best offspring: [0.6668927319878386, 0.6640973552835265, 0.2631901140248719, 0.6892719308559486] + diff --git a/src/AI/resultsExplorer/resultsRaw.txt b/src/AI/resultsExplorer/resultsRaw.txt new file mode 100644 index 0000000..759c049 --- /dev/null +++ b/src/AI/resultsExplorer/resultsRaw.txt @@ -0,0 +1,11 @@ +=HEADER=GA= +[0.4617656024456773, 0.5990607970781336, 0.44395485033011356, 0.3943162694343978, 71] +[0.4241776287024901, 0.7330816824377345, 0.5033842793318899, 0.5250431705157725, 125] +[0.5997880055122891, 0.6462721899244326, 0.23090549744347125, 0.6682296855487012, 130] +[0.5997880055122891, 0.622805396229243, 0.23361305509908434, 0.6015199688363583, 130] +[0.5853943750328781, 0.6680555543169949, 0.31129888112036036, 0.6300813433522894, 130] +[0.5745485398305222, 0.6613255347457894, 0.27558572895124217, 0.698772916997859, 181] +[0.5709501322106695, 0.6734792710611923, 0.26190097471811163, 0.6632002687383984, 186] +[0.5847284354417799, 0.6529132370776863, 0.2597728412225748, 0.6725458259803849, 186] +[0.591617587057335, 0.6603693158815798, 0.2612154609367813, 0.6339049209442479, 186] +[0.6668927319878386, 0.6640973552835265, 0.2631901140248719, 0.6892719308559486, 186] diff --git a/src/entities/Enums.py b/src/entities/Enums.py index 161509f..abc29a0 100644 --- a/src/entities/Enums.py +++ b/src/entities/Enums.py @@ -25,3 +25,4 @@ class Classifiers(Enum): FOOD = 0 WATER = 1 REST = 2 + HERB = 3 diff --git a/src/entities/Interactable.py b/src/entities/Interactable.py index bd4f37d..484994c 100644 --- a/src/entities/Interactable.py +++ b/src/entities/Interactable.py @@ -26,6 +26,8 @@ class Interactable(Entity): self.classifier = Classifiers.WATER elif classifier == "rest": self.classifier = Classifiers.REST + elif classifier == "herb": + self.classifier = Classifiers.HERB def on_interaction(self, Player): """ @@ -38,5 +40,15 @@ class Interactable(Entity): Player.statistics.set_thirst(self.Statistics.thirst) Player.statistics.set_hunger(self.Statistics.hunger) + if self.classifier == Classifiers.HERB: + Player.herbs += 1 + print(Player.herbs) + + if Player.herbs == 2: + Player.statistics.set_hp(100) + Player.statistics.set_stamina(100) + Player.statistics.set_thirst(0) + Player.statistics.set_hunger(0) + def __str__(self): return "Entity - ID:{}, pos:({}x, {}y), {}".format(self.id, self.x, self.y, self.classifier.name) diff --git a/src/entities/Player.py b/src/entities/Player.py index 3460892..cd858c5 100644 --- a/src/entities/Player.py +++ b/src/entities/Player.py @@ -22,6 +22,7 @@ class Player(Entity): super().__init__("player.png", size, spawnpoint, False) self.statistics = Statistics(100, 0, 0, 100) + self.herbs = 0 # How many steps has the player taken through its lifetime self.movePoints = 0 # Tracks how much time has passed since the player is alive