Browse Source

bug fix: prepare dict before use keys

Bastien Sevajol 9 years ago
parent
commit
6ea5f33128
1 changed files with 6 additions and 2 deletions
  1. 6 2
      intelligine/simulation/pheromone/PheromoneFlavour.py

+ 6 - 2
intelligine/simulation/pheromone/PheromoneFlavour.py View File

@@ -11,7 +11,9 @@ class PheromoneFlavour():
11 11
             pheromones_by_category = raw_data[category]
12 12
             for type in pheromones_by_category:
13 13
                 distance, intensity = pheromones_by_category[type]
14
-                flavour.update({category: {type: Pheromone(category, type, distance, intensity)}})
14
+                if category not in flavour:
15
+                    flavour[category] = {}
16
+                flavour[category][type] = Pheromone(category, type, distance, intensity)
15 17
         return cls(flavour)
16 18
 
17 19
     def get_raw_data(self):
@@ -20,7 +22,9 @@ class PheromoneFlavour():
20 22
             pheromones_by_category = self._flavour[category]
21 23
             for type in pheromones_by_category:
22 24
                 pheromone = pheromones_by_category[type]
23
-                raw_data.update({category: {type: (pheromone.get_distance(), pheromone.get_intensity())}})
25
+                if category not in raw_data:
26
+                    raw_data[category] = {}
27
+                raw_data[category][type] = (pheromone.get_distance(), pheromone.get_intensity())
24 28
         return raw_data
25 29
 
26 30
     def __init__(self, flavour):