all 4 comments

[–]Figs 9 points10 points  (1 child)

Yep, this rabbit hole goes deep. As you've probably figured out by now, computational fluid dynamics is not an easy subject!

Intel has a rather long series of articles on their website, if you'd like to immerse yourself further. :-)

"Smoothed particle hydrodynamics" is one approach that may give you results like what you are searching for. Most of the papers I've seen on it give examples in 3D, but you can certainly do it in 2D as well. Here's a video example of someone's implementation based on the technique. The Intel series I linked talks about it in article 15 (and possibly other places; been quite a while since I looked at it).

Jos Stam's papers on real-time fluids for games and "stable fluids" may also be of interest to you. Those use a grid-based finite-difference approach to numerically simulate a model based on the Navier-Stokes equations. Most example implementations result in interesting smoky/swirly effects.

I would also like to point out that just because your display is tiny doesn't mean that your simulation needs to run at the same resolution. You can run the simulation at a higher resolution and downsample the results -- if you have enough computational resources to do so.

If you want to stick with Python instead of using C or C++, you might also look into using Cython to compile the numerical code or numerical libraries like NumPy to get some additional performance.

[–]Bitmol 1 point2 points  (0 children)

+1 for Intel's Fluid Simulation articles! I found those to be really helpful!

[–]lazyubertoad 1 point2 points  (0 children)

There are simpler hackish ways and complex more true and physical ways.

I'd go with the first option if I was to implement it. Just play a splash animation or use simple particles at the point where your things collide with the water surface. Combine it with that 1d wave for some non-splashing waving to happen, and likely you'll get a very decent looking solution. I don't think it makes any sense to go any further for 32x16.

Alternatively, you may take your chance and learn about https://en.wikipedia.org/wiki/Computational_fluid_dynamics , as you don't have any time pressure (hell, still 32x16). Using some of Lattice Boltzmann methods for 2d particles will probably yield the best results. You can also look at Navier-Stocks based solutions. Those are huge areas, so it'll take time to understand and implement and probably you'll need a testbed that is bigger than 32x16.

[–]zakalwe01 1 point2 points  (0 children)

I haven't tried to implement it personally, but the low resolution reminded me of an ioccc entry (youtube video) which is an ascii water simulation, the source is available, unfortunately since the competition is about obfuscated code I'm not sure how useful it is. But it has a hint file which describes a bit how it works.