You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calculating a movement, attack or vision radius is among the most computationally intensive code paths in Athena Crisis. While its performance does not affect normal gameplay, it matters massively when the AI figures out what to optimize for. This is further exacerbated by the fact that results of radius calculations cannot be cached for long, as any action executed against map state may change the radius that is returned. For example, defeating a unit that is blocking a path may make more movement and attack options available for other units in the same turn.
This task is focused on speeding up Radius.tsx by 2x or more. Given how critical the code path is, it is acceptable to make the code in this file slightly less readable (but still reasonably maintainable), and possibly also optimize some of the downstream algorithms – as long as it doesn't change the layout of MapData. It is preferred not to modify the return types given how widely they are used across the codebase, but I am open to it based on a proof-of-concept and some discussion of the trade-offs.
Guidelines
The current algorithm went through extensive testing and its behavior must not diverge. All changes must pass the full test suite.
More test cases may be added to ensure nothing breaks with the optimizations. It is allowed to update some snapshots if the order of the returned radius items is different, as long as it is the same.
The code must remain maintainable, but some trade-offs around readability close to Radius.tsx are acceptable if the performance improvements warrant it.
Performance improvements must be shown through the benchmark suite for calculating a radius. You can run the benchmark via pnpm vitest bench.
The primary focus should be on calculateRadius and movement radius. Speeding up attack or vision calculation by 2x while not speeding up movement radius calculation at all does not meet the objective of this task. However, speeding up movement radius calculation by 1.5x (for example) and speeding up attack and vision calculation by more beyond that might be worth it.
Apologies, yes that's the file. I updated the description. I'm sorry I haven't gotten around to putting the benchmark together yet, I was hoping to use Vitest's benchmarking and using a large map with many units and calculating moveable radius over and over again for every unit.
Calculating a movement, attack or vision radius is among the most computationally intensive code paths in Athena Crisis. While its performance does not affect normal gameplay, it matters massively when the AI figures out what to optimize for. This is further exacerbated by the fact that results of radius calculations cannot be cached for long, as any action executed against map state may change the radius that is returned. For example, defeating a unit that is blocking a path may make more movement and attack options available for other units in the same turn.
This task is focused on speeding up
Radius.tsx
by 2x or more. Given how critical the code path is, it is acceptable to make the code in this file slightly less readable (but still reasonably maintainable), and possibly also optimize some of the downstream algorithms – as long as it doesn't change the layout ofMapData
. It is preferred not to modify the return types given how widely they are used across the codebase, but I am open to it based on a proof-of-concept and some discussion of the trade-offs.Guidelines
Radius.tsx
are acceptable if the performance improvements warrant it.pnpm vitest bench
.calculateRadius
and movement radius. Speeding up attack or vision calculation by 2x while not speeding up movement radius calculation at all does not meet the objective of this task. However, speeding up movement radius calculation by 1.5x (for example) and speeding up attack and vision calculation by more beyond that might be worth it.Funding
The text was updated successfully, but these errors were encountered: