Sephfox commited on
Commit
e905375
·
verified ·
1 Parent(s): 39a0169

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -35,14 +35,15 @@ class HiveMind:
35
  self.pheromone_importance = {'food': 0.5, 'danger': 0.3, 'exploration': 0.2}
36
 
37
  def update_collective_memory(self, ant_memories):
38
- for position, info in memory:
 
39
  if position not in self.collective_memory:
40
  self.collective_memory[position] = info
41
  else:
42
  old_info = self.collective_memory[position]
43
  new_info = tuple((old + new) / 2 for old, new in zip(old_info, info))
44
  self.collective_memory[position] = new_info
45
-
46
  def update_global_strategy(self, ant_performances):
47
  best_ants = sorted(ant_performances, key=lambda x: x[1], reverse=True)[:5]
48
  self.global_strategy = {
 
35
  self.pheromone_importance = {'food': 0.5, 'danger': 0.3, 'exploration': 0.2}
36
 
37
  def update_collective_memory(self, ant_memories):
38
+ for ant_memory in ant_memories:
39
+ for position, info in ant_memory:
40
  if position not in self.collective_memory:
41
  self.collective_memory[position] = info
42
  else:
43
  old_info = self.collective_memory[position]
44
  new_info = tuple((old + new) / 2 for old, new in zip(old_info, info))
45
  self.collective_memory[position] = new_info
46
+
47
  def update_global_strategy(self, ant_performances):
48
  best_ants = sorted(ant_performances, key=lambda x: x[1], reverse=True)[:5]
49
  self.global_strategy = {