Improving performance is mostly affected by enlarging the radius and board size.
Your function fillingIntegralN_M
seems to perform a 2D convolution. Am I correct?
When dealing with large kernels, especially a radius of a few grid units, using a fast Fourier transform (FFT) can significantly improve efficiency.
The approach involves precomputing FFTs for inner and outer "filling integral" kernels, where cells within specified radii have values of 1 or normalized factors if optimization is desired, while those outside are set to 0. Applying proper boundary treatments for cells at the edges adheres to the cyclic nature of the domain.
During each simulation iteration, the FFT of the grid is multiplied element-wise with these precomputed kernel FFTs. The inverse FFT of resulting grids provides updated m and n values per point for subsequent grid updates.
If your update rule were entirely linear, computations could be performed primarily in "Fourier space," toggling back occasionally to visually display the grid. However, since SmoothLife follows a non-linear update rule, constant transitioning between spaces is necessary leveraging optimized FFT implementations for fast execution.
In regard to JavaScript FFT implementation, building one from scratch as an initial step might divert focus to unnecessary complexities. Opting for existing alternatives like JavaScript FFT libraries such as fft.js, jsfft, or utilizing functions like math.fft in math.js would ensure both accurate implementation and speeder performance.
Moreover, consider exploring additional resources like p5.js' FFT module although primarily designed for audio applications. Its applicability for acquiring "raw" FFT of numerical data may require further insight due to certain limitations on input/output sizes affecting grid dimensions.
Addendum: Below is snippet demonstrating FFT convolution using jsfft library tailored to complement the SmoothLife algorithm. Although inspired by the referenced paper, slight modifications may be needed for alignment with personal code structure.
// Implementing JS code here...
<div id="smoothlife"></div>
<div id="fps"></div>
Running this example on my laptop achieved approximately 20 FPS with a grid measuring 512 by 256 points. Incidentally, optimizing it further could potentially enhance performance outcomes. Nonetheless, maintaining power-of-2 grid dimensions seemingly boosts FFT code execution efficiency.
Note that despite employing a single-dimensional FFT instead of a genuine 2D FFT, the choice doesn't impair convolution results as long as consistency prevails. As arrays storing two-dimensional grids mimic one-dimensional structures, deploying a 1D FFT simplifies coding and possibly enhances speeds.
Still, achieving classic SmoothLife dynamics similar to illustrated videos, even with identical parameter setups, remains elusive reflecting potential undiscovered bugs. Further comparisons with other implementations or analysis of specific integrations used may uncover discrepancies impacting outcome variations.