Deepen GaugeGap into an eight-experiment science library#89
Conversation
There was a problem hiding this comment.
Code Review
This pull request expands the GaugeGap science arcade from four to eight live experiments by adding four new interactive simulation labs: Gravity Forge (orbital mechanics), Flock Mind (collective intelligence), Outbreak Zero (network epidemiology), and Chaos Twins (deterministic chaos). It also introduces shared chrome components and utilities for these labs, along with corresponding styles. The review feedback highlights a critical coordinate-scaling issue present in the Flock Mind, Outbreak Zero, and Gravity Forge simulations. On smaller screens where the canvas is scaled down, raw pointer and click coordinates do not align with the internal simulation space, causing misaligned interactions. Actionable code suggestions are provided to scale these coordinates relative to the bounding rect dimensions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| function pointer(event) { | ||
| const rect = canvas.getBoundingClientRect(); | ||
| pointerRef.current = { x: event.clientX - rect.left, y: event.clientY - rect.top, active: true }; | ||
| } |
There was a problem hiding this comment.
On screens where the canvas bounding rect is smaller than the minimum dimensions (320x360), the canvas is scaled down by the browser. However, the pointer coordinates are calculated using raw client coordinates relative to the bounding rect, which do not match the internal simulation coordinate space. This causes the pointer interaction to be misaligned with the visual elements on smaller screens.
To fix this, scale the pointer coordinates by the ratio of the simulation dimensions to the actual bounding rect dimensions.
function pointer(event) {
const rect = canvas.getBoundingClientRect();
const x = (event.clientX - rect.left) * (width / (rect.width || 1));
const y = (event.clientY - rect.top) * (height / (rect.height || 1));
pointerRef.current = { x, y, active: true };
}| function onClick(event) { | ||
| const rect = canvas.getBoundingClientRect(); | ||
| const x = event.clientX - rect.left; | ||
| const y = event.clientY - rect.top; |
There was a problem hiding this comment.
Similar to the flocking simulation, the click coordinates in the outbreak simulation are not scaled to the simulation coordinate space when the canvas bounding rect is smaller than the minimum dimensions (320x360). This makes it difficult or impossible to click nodes near the right or bottom edges on smaller screens.
Scale the click coordinates by the ratio of the simulation dimensions to the actual bounding rect dimensions to ensure accurate node selection.
| function onClick(event) { | |
| const rect = canvas.getBoundingClientRect(); | |
| const x = event.clientX - rect.left; | |
| const y = event.clientY - rect.top; | |
| function onClick(event) { | |
| const rect = canvas.getBoundingClientRect(); | |
| const x = (event.clientX - rect.left) * (width / (rect.width || 1)); | |
| const y = (event.clientY - rect.top) * (height / (rect.height || 1)); |
| function pointerPosition(event) { | ||
| const rect = canvas.getBoundingClientRect(); | ||
| return { x: event.clientX - rect.left, y: event.clientY - rect.top }; | ||
| } |
There was a problem hiding this comment.
In the gravity simulation, the pointer coordinates used for launching planets are not scaled to the simulation coordinate space when the canvas bounding rect is smaller than the minimum dimensions (320x360). This causes planet launches to be misaligned and have incorrect velocities on smaller screens.
Scale the pointer coordinates by the ratio of the simulation dimensions to the actual bounding rect dimensions to ensure consistent launch behavior across all screen sizes.
function pointerPosition(event) {
const rect = canvas.getBoundingClientRect();
return {
x: (event.clientX - rect.left) * (width / (rect.width || 1)),
y: (event.clientY - rect.top) * (height / (rect.height || 1)),
};
}There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4dfd2e41be
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const [alignment, setAlignment] = useState(shared?.alignment || 0.72); | ||
| const [cohesion, setCohesion] = useState(shared?.cohesion || 0.54); | ||
| const [separation, setSeparation] = useState(shared?.separation || 0.86); |
There was a problem hiding this comment.
Preserve zero-valued flock controls from shared links
When a shared Flock Mind URL contains a valid zero for any slider that allows it, such as ?lab=flock&state=120,0,0,0,predator, these || fallbacks replace the shared values with the defaults. That means links copied from the minimum alignment/cohesion/separation settings do not reload the experiment state the sender actually shared; use nullish fallback so 0 survives parsing.
Useful? React with 👍 / 👎.
What this adds
Expands the GaugeGap science arcade from four to eight genuinely different interactive systems.
New live experiments
Product depth
Validation requested