From 080d7c7671c1148b24a61ae79e182a7d6dcbb46e Mon Sep 17 00:00:00 2001 From: Kushagar Garg Date: Mon, 22 Jun 2026 21:10:59 +0530 Subject: [PATCH] fix: average reward over agents in compute_system_rewards The averaging loop was inside the for-agent loop and modified agent_reward (the local per-agent dict) instead of reward (the accumulated total). This meant reward always held the raw sum of all agents' stats, inflating all values by N (num agents). Fix: move the averaging loop outside the for-agent loop and apply it to reward instead of agent_reward. --- core/population.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/population.py b/core/population.py index 2e4e00a..151a368 100644 --- a/core/population.py +++ b/core/population.py @@ -818,9 +818,9 @@ def compute_system_rewards(self) -> Dict[str, float]: agent_reward = agent.compute_morphology_statistics() for k, v in agent_reward.items(): reward[k] += v - # average - for k in agent_reward.keys(): - agent_reward[k] = agent_reward[k] / len(self.agents) + # average + for k in reward.keys(): + reward[k] = reward[k] / len(self.agents) # Pairwise disagreement across agents' forms disagr = 0