BUG: correct averaging bug in compute_system_rewards

Open Beginner friendly
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
backend

Research direction

Start at Population.compute_system_rewards, where the issue shows the per-agent statistics are accumulated and the averaging loop is misplaced. Ensure the returned values are averages over the agents rather than raw sums, then verify the method's result for multiple agents.

Written by the indexing model from the issue text.

Description

Summary

Population.compute_system_rewards always returns the raw sum of per-agent stats instead of the average, inflating every value by a factor of N (number of agents).

Bug

The averaging loop has two problems — it modifies agent_reward (the local per-agent dict) instead of reward (the accumulated total), and it sits inside the for agent loop so the result is discarded on the next iteration anyway.

# buggy  [header-1](#header-1)
for agent in self.agents:  
    agent_reward = agent.compute_morphology_statistics()  
    for k, v in agent_reward.items():  
        reward[k] += v  
    # average — wrong variable, wrong scope  
    for k in agent_reward.keys():  
        agent_reward[k] = agent_reward[k] / len(self.agents)
Dominant language
Python
Stars
8
Forks
3
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SakanaAI/LanguageEvolution

All issues in SakanaAI/LanguageEvolution

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.