Skip to content

main.py's render loop is uncapped and RenderWindow.tick() is never called #19

Description

@dmccoystephenson

Observation

main.py's render loop is uncapped. Every iteration re-fills the surface, re-draws the
whole environment and calls pygame.display.update(), with nothing limiting how often
that happens:

while window.should_continue():
    ...
    gameDisplay.fill(white)
    drawEnvironment(locationsCache, graphik, locationWidth, locationHeight)
    pygame.display.update()

RenderWindow already exposes tick(fps) for exactly this purpose, and it is not
called from anywhere in the repository.

Because drawEnvironment chooses a fresh random colour per location on every call:

red = random.randrange(50, 200)
green = random.randrange(50, 200)
blue = random.randrange(50, 200)

the visualization also re-randomizes as fast as the machine can redraw, rather than
presenting a stable image.

Suggested change

  • Call window.tick(60) (or another chosen frame rate) at the end of the loop body so
    the loop stops consuming a whole CPU core.
  • Separately, decide whether the per-location colour is meant to be stable. If it is,
    the colours should be computed once — for example when locationsCache is populated
    — rather than on every frame.

The two are related but separable: the frame-rate cap is a small change confined to the
loop, whereas making colours stable changes what the tool actually displays and should
be confirmed against the intended behavior first.

Scope note

This touches the live render loop, so the project's live-Viron manual-validation anchor
is expected to be required.

This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions