Fire spreading modelling

I am developing a wild fire spreading model based on a cellular automata paradigm (a grid of cells). I used to update the grid every second or so. Unfortunately, as the grid dimensions grows, the computation time starts to be too long… I already adopted some optimization such as limiting the computation to the rectangular area (+1 row/column) where the fire is developing. Now I am thinking to go forward with some multithreading approach. I know there is a new stuff in Unity as Jobs, Entities and such. But I do not know how to start. In particular it is not necessary to update every frame, maybe some time step like one or even 5 seconds would be enough. But how to pass all the data to the jobs? How reading the results (new updated grid). Any suggestion?

I would just start with some tutorials on using the basic systems you contemplate for this: Jobs, ECS, DOTS, whatever the technology stack for async stuff is in Unity right now.

Keep in mind this stuff (I think) is still i flux and not a lot of people (as a fraction of Unity users) have any need for this, so you’ll probably have to experiment a lot on your own once you understand the basics from the tutorials.

Until you are familiar with how it all goes together, what it can and cannot do, you won’t really be able to reason about implementing your current problem space in a way that gets you a measurable benefit.

If you don’t need the computation to complete within a single frame there are still steps you can try before jumping to a multithreaded solution. Have you tried doing partial computation during each frame? You can easily split the computation across multiple frames using Coroutines for example.

1 Like