Perf/solver optimizations#28
Merged
Merged
Conversation
The optimalValue in BestNodeSearch was initialized to 0 instead of the guess parameter from the previous iteration. In MTD(f) iterative deepening the guess carries forward the best value found at shallower depths, so discarding it reset the search bounds unnecessarily.
Data structure changes: - Transposition<TStep>: class -> struct (eliminates heap allocations) - CacheTables: Dictionary -> array-based cache with power-of-2 bitmask indexing and KeyMarker XOR for empty slot disambiguation (TT: 2M slots, Eval: 8M slots) Search algorithm improvements: - Buffer-based move ordering: per-depth reusable List<TStep>[] replaces yield-return iterator state machines and per-node List allocations - TT step legality verification: transposition table optimal step is only used if confirmed present in LegalStepsAt output (prevents crashes from Zobrist hash collisions when Position.Identifier excludes LastStep) - IsGoal fast-path at depth 0: replaces expensive LegalStepsAt().Any() with O(1) IsGoal() check, reducing LegalStepsCalls by ~89%% - HeuristicValue simplified: terminal branch removed (handled by caller) Infrastructure: - History heuristic recording with depth-squared weighting (IHeuristicTables.GetHistoryScore, not yet used for move sorting) Benchmark results vs main (SixMaking depth-6): Test #1: 626ms -> 600ms (-4%%) Test #3: 1457ms -> 1266ms (-13%%) Test #4: CRASH -> 1030ms (fixed) Test #5: 16562ms -> 11218ms (-32%%)
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.
No description provided.