BarthPaleologue / CosmosJourneyer

A space exploration game with a fully simulated universe running in the browser
https://cosmosjourneyer.com/
GNU Affero General Public License v3.0
11 stars 4 forks source link

Solve A* in a separate thread #139

Open BarthPaleologue opened 2 months ago

BarthPaleologue commented 2 months ago

Plotting itineraries in the starmap is done using the A* algorithm.

Update steps take O(ln(n)) steps to complete where n is the number of steps already completed (insertion of new nodes inside a binary tree). This can become a problem for distant stars, causing the framerate to drop when looking for the shortest path.

A solution for this is to run the A* solver inside a Web Worker so that the main thread retains a constant framerate.