Skip to content

Fix PositionBonus wrapper ignoring the scale parameter (issue #473) - #505

Open
teddytennant wants to merge 1 commit into
Farama-Foundation:mainfrom
teddytennant:fix-positionbonus-scale
Open

Fix PositionBonus wrapper ignoring the scale parameter (issue #473)#505
teddytennant wants to merge 1 commit into
Farama-Foundation:mainfrom
teddytennant:fix-positionbonus-scale

Conversation

@teddytennant

Copy link
Copy Markdown

What

PositionBonus.__init__ accepts a scale argument but hardcoded self.scale = 1, so the argument was silently discarded. step() computes reward += bonus * self.scale, meaning PositionBonus(env, scale=k) returned identical rewards for every k. This changes the assignment to use the passed-in scale and documents the parameter in the Args: docstring.

Why

The scale parameter (added in #433) had no effect at all — the exploration bonus was always multiplied by 1 regardless of the value passed. See #473.

Testing

Added tests/test_wrappers.py::test_position_bonus_wrapper_scale, a parametrized test over scale in {0.5, 2, 3.0} that checks the wrapped reward equals base_reward + scale * bonus. It fails on main (rewards are unchanged by scale) and passes with this fix.

pytest tests/test_wrappers.py -k position_bonus
....                                                                     [100%]
4 passed, 2155 deselected in 0.18s

Fixes #473

PositionBonus.__init__ hardcoded self.scale = 1, so the scale argument
was silently discarded and PositionBonus(env, scale=k) produced the same
reward for every k. Assign the scale argument instead and document it.
Add a parametrized test that exercises non-unit scales.
Copilot AI review requested due to automatic review settings July 8, 2026 17:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Possible Mistake in Scaling Feature for PositionBonus Wrapper

2 participants