feat(ai): optimize game simulation speed with fast in-memory copying and iterative loops#10647
Open
suspectedspam wants to merge 1 commit into
Open
Conversation
…and iterative loops - Implemented CardCopyService.fastGameCopy for rapid card deep-cloning. - Refactored ComputerUtil, ComputerUtilCard, and ComputerUtilMana to use iterative loops instead of stream pipelines in hot paths. - Integrated fast in-memory copying into GameCopier to avoid PaperCard re-parsing. - Implemented signature caching in SpellAbilityPicker to prune redundant simulation branches. - Fixed a bug where simulation state leaked into the live game by ensuring abilities are correctly copied in fastGameCopy.
Contributor
|
@suspectedspam should probably outline your benchmarks, performance profiling and methodology on this given the claims in the PR about significant performance improvements. I've had AI agents recommend performance optimisations in the past based on code analysis alone which don't bear out when you actually profile the results. |
tool4ever
reviewed
May 10, 2026
| .max(Comparator.comparing(Card::getCMC)) | ||
| .orElse(null); | ||
| Card best = null; | ||
| for (Card c : list) { |
Contributor
There was a problem hiding this comment.
I don't understand why these changes should make a huge difference 🤔
Aren't Streams specifically designed to be cheap and fast in usage...?
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 PR introduces several optimizations to the Forge AI engine to significantly improve the performance of deep-tree game simulations.
Key Changes:
Performance Impact:
In internal benchmarks, these changes resulted in a significant reduction in time-to-decision for complex board states, particularly those involving many available spells and abilities.