Open sholloway opened 4 years ago
Spent a lot of time on this. Construction of a Z-curve is faster than building a pointer quadtree. However, performing range searches on the Z-curve using the bigmin algorithm is quite slow and not practical for this use case. Performing binary search on a sorted z-curve is quite fast, but initially sorting the curve is expensive and not a good fit for dynamically growing/shrinking data sets.
While replacing the quadtree with an Z-Curve is not feasible, the Morton encoding is still useful. There are a few properties of the cellular automata simulations that can be exploited.
Given these properties the quadtree can be replaced with a simpler solution of storing live cells in a Map object with the cell's Morton code as its key. The Moore neighborhood range searches are replaced by simply looking up each neighborhood in the map.
The slowest thing in the simulation is the construction of the quadtree every frame. It may be faster to construct a linear quadtree using Z-Ordering rather than using the pointer quadtree approach.
Approaches
Operations to Benchmark
Resources