Conversation
…erence - Introduced a new performance test for the Canvas2D implementation of TerritoryLayer in `TerritoryLayer.perf.test.ts`. - Added a benchmark harness in `territory-layer-bench-harness.ts` to facilitate performance testing of different layer implementations. - Fixed a reference issue in `AIPlayerExecution.ts` by removing the optional chaining operator on `nukeHandler` when accessing `getEffectiveSAMRange`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request significantly refactors the
TerritoryLayerclass to optimize territory rendering performance and simplify color management. The main changes include replacing the priority queue-based tile rendering with a deduplicated array-based queue, packing color values for faster rendering, and reducing per-tile color computation overhead. Additionally, it introduces new benchmarks for performance testing and removes unused imports and methods.Rendering and performance optimizations:
PriorityQueuefor tile rendering with a deduplicated array-based queue (renderQueue) and a bitmap (repaintFlags) to avoid redundant repaints, improving performance and simplifying the render logic. [1] [2]territoryPacked,borderPacked, etc.) indexed by player ID, reducing per-tile color computation and enabling direct pixel buffer writes. [1] [2] [3] [4]Uint32Arrayviews of the image data for faster pixel updates, replacing the previous method that wrote individual color channels. [1] [2] [3]Codebase simplification:
PriorityQueue,PseudoRandom) and methods (enqueueTile, per-tile color cache), and consolidated per-render-pass cached state for player highlighting and focus. [1] [2] [3] [4]Testing improvements:
TerritoryLayer.perf.test.tswith anImageDatapolyfill for jsdom, enabling benchmarking of the Canvas2D-basedTerritoryLayerand providing a harness for alternative implementations.Other minor fixes:
AIPlayerExecution.tsby removing the non-null assertion fornukeHandler.