Show HN: Neural Particle Automata

Comments

SPH perception is the particle-based counterpart of convolutional perception in grid-based Neural Cellular Automata. Each particle \(i\) has a continuous position \(\mathbf{x}_i\) and an internal state \(\mathbf{S}_i\); instead of reading from fixed lattice neighbors, it aggregates nearby particles \(j\) inside a support radius \(\epsilon\) using smooth kernels. These local sums estimate quantities such as density \(\rho_i\), smoothed state \(\tilde{\mathbf{S}}_i\), density gradient \(\nabla\rho_i\), the moment matrix \(\mathbf{M}_i\), and 0th- or 1st-order state gradients. In Neural Particle Automata, these measurements form a compact local perception vector for a shared update rule, preserving the locality of NCA while allowing particles to live on irregular and dynamic configurations.

This demo visualizes those operators around the selected center particle. For clarity, particles live in 2D, all particle masses are set to \(m_i=1.0\), and each state has only three channels, shown as RGB color; the center particle's state is fixed to \((0,0,0)\). The dashed circle marks the \(\epsilon\)-neighborhood, and the bottom plots show the smoothing kernel \(W_\epsilon(r)\) and spiky gradient kernel's magnitude \(\|W_\epsilon^{\nabla}(r)\|\) as functions of distance \(|r|\), with dots indicating where particles fall along those kernels. Density and count display scalar neighborhood summaries; smoothing shows the kernel-averaged RGB state; and \(\nabla\rho\) points toward the direction where particle density increases, indicating which side of the center particle is more crowded.

The state-gradient modes estimate how the RGB state changes around the center particle. The 0th-order estimator uses differences \(\mathbf{S}_j-\mathbf{S}_i\), so a constant state field gives exactly zero gradient even if the particles are irregularly placed. Under uneven sampling, however, this difference formula can be biased for fields that change linearly. The 1st-order correction uses the moment matrix \(\mathbf{M}_i\), which summarizes the local geometry of the neighbors around particle \(i\): roughly, it describes how the neighbor offsets and kernel-gradient directions cover space. Multiplying by \(\mathbf{M}_i^{-1}\) normalizes out this local geometric distortion, making the gradient estimate exact for locally linear fields when the neighborhood is well-conditioned. In the demo, the RGB arrows visualize per-channel state gradients, while the moment-matrix view shows the local geometric directions used by this correction.