Context
Issue #19 raised two separable points about main.py's render loop. The first — that the loop was uncapped and RenderWindow.tick() was never called — is addressed in PR #23, which is why #19 is being closed. The second is recorded here so that it is not closed along with it.
Observation
drawEnvironment (main.py:60-67) picks a fresh random colour for every location on every call:
for location in locations:
red = random.randrange(50, 200)
green = random.randrange(50, 200)
blue = random.randrange(50, 200)
Because it is called once per frame from the render loop, the whole visualization re-randomizes on every frame. Before PR #23 that happened as fast as the machine could redraw; with the frame cap in place it now happens at the target frame rate, measured at roughly 58 frames per second in a headless run. The behavior is therefore bounded, but unchanged in kind.
The question
It is not evident from the source which of these is intended:
- Stable colours. Each location is assigned a colour once — when
locationsCache is populated — and keeps it. The window then presents a steady image, which is what the window title, "Visualizing Environment With Random Colors", most plausibly describes.
- Animated colours. The re-randomization is the point, and the frame cap is simply what sets its speed.
The first reading is the one #19 leaned toward, but the issue explicitly declined to implement it on the grounds that it changes what the tool displays and should be confirmed against the intended behavior first. That confirmation is what is being asked for here.
Suggested resolution, if stable colours are intended
Compute the colour map once at the point locationsCache is filled, keyed by the location, and have drawEnvironment look colours up rather than generate them. This also removes per-frame random.randrange calls from the hot loop, three per location per frame.
Acceptance criteria
- A decision is recorded on which behavior is intended.
- If stable colours are chosen, a location retains its colour across frames, and that is covered by a unit test under
tests/ driving several frames and asserting the colours passed to Graphik.drawRectangle are identical between them.
This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson
Context
Issue #19 raised two separable points about
main.py's render loop. The first — that the loop was uncapped andRenderWindow.tick()was never called — is addressed in PR #23, which is why #19 is being closed. The second is recorded here so that it is not closed along with it.Observation
drawEnvironment(main.py:60-67) picks a fresh random colour for every location on every call:Because it is called once per frame from the render loop, the whole visualization re-randomizes on every frame. Before PR #23 that happened as fast as the machine could redraw; with the frame cap in place it now happens at the target frame rate, measured at roughly 58 frames per second in a headless run. The behavior is therefore bounded, but unchanged in kind.
The question
It is not evident from the source which of these is intended:
locationsCacheis populated — and keeps it. The window then presents a steady image, which is what the window title, "Visualizing Environment With Random Colors", most plausibly describes.The first reading is the one #19 leaned toward, but the issue explicitly declined to implement it on the grounds that it changes what the tool displays and should be confirmed against the intended behavior first. That confirmation is what is being asked for here.
Suggested resolution, if stable colours are intended
Compute the colour map once at the point
locationsCacheis filled, keyed by the location, and havedrawEnvironmentlook colours up rather than generate them. This also removes per-framerandom.randrangecalls from the hot loop, three per location per frame.Acceptance criteria
tests/driving several frames and asserting the colours passed toGraphik.drawRectangleare identical between them.This issue body was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).
drafted by Claude on behalf of Daniel Stephenson