[Gravity_Particles] Add a true N-body mode (softened gravity / Barnes-Hut) and a web build

Open
#400 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
cmake, cpp
Domain
game-dev

Research direction

Start with Math_Chaos/Gravity_Particles/main.cpp:31-56 and the gravity particles documentation at docs/src/content/docs/math-chaos/gravity-particles.mdx:20. Identify how cursor attraction and particle updates currently work, then determine how the proposed integrator, Barnes-Hut option, controls, tests, and Emscripten build fit the project. Done means the acceptance criteria pass and the documentation describes the available modes.

Written by the indexing model from the issue text.

Description

area: math-chaos priority: P3 size: L type: enhancement

Summary

The docs already promise N-body gravity, and raylib supports Emscripten. A real N-body mode (O(N^2) for a few thousand bodies, or Barnes-Hut for more) with optional mouse attraction would match the project name and the docs. A WASM build could be embedded in the docs site.

Location

  • Math_Chaos/Gravity_Particles/main.cpp:31-56
  • docs/src/content/docs/math-chaos/gravity-particles.mdx:20

Evidence

Currently there is only cursor attraction (main.cpp:37), with no particle-particle forces.

Expected

A toggle between “cursor” and “N-body” modes, configurable particle count, and an optional web build.

Proposed fix

  1. Add an NBody integrator (leapfrog/velocity Verlet with Plummer softening). Start with O(N^2) and add a quadtree Barnes-Hut (theta = 0.5).
  2. Add key bindings (G toggles mode, +/- changes count).
  3. Add an Emscripten CMake preset (-DPLATFORM=Web) and embed the result in the docs page.

Acceptance criteria

  • N-body mode conserves total momentum within 1e-3 over 1000 steps (test)
  • Web build runs in a browser

Repository audit, November 2026 · Phase 9 · New features · evidence: found by code reading · ref chaos-native-055


Generated by Claude Code

Dominant language
C++
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ibra-kdbra/Math-Problems

All issues in ibra-kdbra/Math-Problems

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.