Skip to content

Render every balloon in the vpython renderer#27

Open
thc1006 wants to merge 2 commits into
developfrom
mnt/vpython-render-all-balloons
Open

Render every balloon in the vpython renderer#27
thc1006 wants to merge 2 commits into
developfrom
mnt/vpython-render-all-balloons

Conversation

@thc1006
Copy link
Copy Markdown
Member

@thc1006 thc1006 commented May 18, 2026

Fixes #26: _render_frame's vpython branch only ever drew balloon 0.

What changed

_render_frame, the render_mode == "vpython" branch:

  • It created a single sphere and positioned it from self._balloon_states[0, 0:3] (hardcoded index 0), so a scenario with N balloons showed only the first one.
  • Now it creates one sphere per balloon and updates every sphere's .pos from its own row of self._balloon_states.

This matches the matplotlib branch in the same method, which already slices over all balloons (self._balloon_states[:, ...]).

Balloon colour stays magenta, the same as the previous single sphere. Status colouring and rocket rendering are still missing from the vpython branch (the matplotlib branch has both); those are out of scope here and noted in #26 for a later pass.

Verified

  • TDD: tests/test_render.py started red (the old code created 1 sphere; scenario 0 has 10 balloons) and went green after the change.
  • The new test mocks the vpython module, builds a scenario-0 env with render_mode="vpython", and asserts that a reset() creates one sphere per balloon.
  • ruff check and ruff format --check pass; the full test suite passes (10 tests).

vpython rendering itself needs a display, so it cannot be exercised headless; the test verifies the logic (one sphere per balloon, all updated).

Closes #26

_render_frame's vpython branch created a single sphere and
positioned it from _balloon_states[0], so a scenario with N
balloons showed only the first. Create one sphere per balloon and
update them all, which matches the matplotlib branch that already
slices over every balloon. Add tests/test_render.py, which mocks
vpython and checks that a reset creates one sphere per balloon.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 18, 2026 02:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the vpython renderer so it creates and updates a sphere for each balloon instead of rendering only balloon 0.

Changes:

  • Replaces the single vpython balloon sphere with a list of spheres.
  • Updates each sphere position from the corresponding balloon state.
  • Adds a behavioral test for vpython sphere creation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
BalloonPoppingGymEnv/envs/balloon_world.py Updates the vpython render branch to create and position one sphere per balloon.
tests/test_render.py Adds a mocked-vpython regression test for rendering all balloons.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +354 to +355
for balloon, state in zip(self.render_balloons, self._balloon_states):
balloon.pos = vector(state[0], state[1], state[2])
Comment thread tests/test_render.py
Comment on lines +29 to +32
"""True when the heavy simulation stack (rocketpy) is installed."""
return importlib.util.find_spec("rocketpy") is not None


The render test checked that num spheres are created but not that
all of them are repositioned each frame, so a regression updating
only one sphere would still pass. Add a vector() call-count
assertion that pins the per-balloon update loop.

Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
@thc1006 thc1006 self-assigned this May 18, 2026
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.

2 participants