Skip to content

Fix cooperative_pong ball bounce physics (v7) — supersedes #1336 - #1398

Open
RewardGuard wants to merge 2 commits into
Farama-Foundation:mainfrom
RewardGuard:pong-physics-v7
Open

Fix cooperative_pong ball bounce physics (v7) — supersedes #1336#1398
RewardGuard wants to merge 2 commits into
Farama-Foundation:mainfrom
RewardGuard:pong-physics-v7

Conversation

@RewardGuard

Copy link
Copy Markdown
Contributor

Description

Supersedes #1336 (which had merge conflicts and a failing CI) and fixes #1289.

Cooperative pong resolved collisions by snapping the ball's position exactly onto the colliding surface, throwing away the distance the ball had already travelled past the wall/paddle during that step. The correct behaviour is to reflect that overshoot back out of the surface, so the bounce conserves the ball's motion within the step.

This PR:

  • ball.py — reflects the overshoot on top/bottom wall bounces instead of clamping to the wall.
  • paddle.py — reflects the overshoot on all four paddle-collision cases (left/right/top/bottom) instead of clamping to the paddle edge.
  • Bumps cooperative_pong_v6v7 (the physics change alters environment dynamics) and updates every reference: the version module, all_modules.py, the env registry, docs, and tests.
  • Adds a v7 entry to the Version History.

Rebased cleanly on current main, so there are no merge conflicts (the pyproject.toml/pygame_init_test fixes that #1336 carried are already present on main).

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

Checklist:

  • I have run pytest for the affected env (api_test, parallel_api_test, seed_test all pass for cooperative_pong_v7).
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • New and existing unit tests pass locally with my changes.

🤖 Generated with Claude Code

@jkterry1

Copy link
Copy Markdown
Member

@RewardGuard I apologize for the hassle, but could you please rebase your changes off main?

The ball previously had its position clamped exactly to the colliding
surface on a bounce, discarding the distance it had already overshot past
the wall/paddle within that step. This made bounces lose energy/precision
and could let the ball clip through fast collisions.

Reflect the overshoot back out of the surface instead of clamping, in both
the top/bottom wall handling (ball.py) and the paddle collision handling
(paddle.py). Because this changes environment dynamics, bump
cooperative_pong_v6 -> v7 and update all references, docs, tests and the
env registry accordingly.

Supersedes Farama-Foundation#1336, fixes Farama-Foundation#1289.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@virgilt

virgilt commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

@RewardGuard there's merge conflicts.

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.

[Bug Report] Cooperative pong wall bounce physics is wrong

3 participants