-
Notifications
You must be signed in to change notification settings - Fork 2
memchess: add adjusted-collision audit + prune ambiguous lines #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
To prevent information loss, I would rather not change js/lines.js. I would prefer it if any modification of the lines is done dynamically in javascript, for instance during import. Also, if I'm not mistaken this collision detection method is based of move sequences, it does not take transpositions into account. Granted, taking move sequences is a good start but since it's not the ultimate goal it's all the more reasons to do it in javascript first. |
|
Thanks for the feedback — that’s fair, and I understand the concern about information loss. About not changing
|
|
D. I think for now an offline audit is fine. We can duck-tape the runtime code to process the problematic lines separately (possibly even ignoring them if there aren't too many of them). |
|
Sounds good — option D makes a lot of sense as a first step. I’ll look into updating the offline collision audit to become transposition-aware (i.e. detecting ambiguities by position rather than strictly by SAN move sequence). Since Memchess already uses Once we have that transposition-aware report, we can keep the fix non-destructive and lightweight:
I’ll share the updated report/patch format once I have the transposition-aware detection working, and then we can iterate on the simplest runtime handling strategy. |
Hi! 👋
This PR fixes intra-opening ambiguities (“collisions”) in the Memchess opening book and updates the UI counters accordingly.
✅ Fixes issue #3: “Collisions (intra-opening ambiguities): 11 unique cases found + HTML report attached” (#3)
Summary
1) Remove intra-bucket ambiguities (Stockfish-guided prune)
Sometimes, inside a single opening bucket, the repertoire side can reach the same prefix and yet 2+ different next moves exist among the bucket’s lines. In Memchess this can cause “the move I played is wrong” even when the move is valid — because the app expects a single next move for that bucket/prefix.
This PR:
Files / tooling:
memchess/js/lines.jsaudit_collisions.pycollisions.html,after.htmlRun used (apply fix):
python audit_collisions.py --root . --side both --stockfish /path/to/stockfish \ --apply-fix --in-place --preserve-format --out collisions.htmlResults (before fix):
10Fix applied:
WHITE
188BLACK
144022Why “10 unique buckets” but “30 buckets touched”?
A collision often appears in broader ancestor buckets too, because ancestors contain the same underlying line set.
The audit uses deepest-bucket attribution:
When applying the fix, the “losing” line strings are removed globally for that side (from every bucket where they appear), so ancestor buckets get updated too.
That’s why only 10 buckets have unique collisions, but 8+22 = 30 buckets have their line lists modified by removal propagation.
Verification (after fix):
python audit_collisions.py --root . --side both --stockfish /path/to/stockfish --out after.html0(all detected intra-bucket ambiguities removed)2) Refresh UI “Lines” counters (opening_book totals)
After pruning
lines.js, Memchess’ UI “Lines” counts can remain unchanged because those totals come fromopening_bookinopening_names.js(not by recountingwhiteLines/blackLinesat runtime).So this PR also refreshes those counters so the UI matches the updated opening book data.
Files / tooling:
memchess/js/opening_names.jsrecount_opening_names.pyRun used:
python recount_opening_names.py --root . --in-placeResults:
lines.js: white=350· black=345opening_bookentries parsed:2915792463What does “absent from lines.js” mean?
opening_names.jscontains a global opening tree (opening_book) which is much larger than the subset of buckets that have actual line arrays inlines.js.2463entries have no correspondingwhiteLines[key]norblackLines[key]bucket, so they are intentionally left untouched.Reproduce locally (end-to-end)
1) Report only
python audit_collisions.py --root . --side both --stockfish /path/to/stockfish --out collisions.html2) Apply fix (prune) + keep diffs clean
python audit_collisions.py --root . --side both --stockfish /path/to/stockfish \ --apply-fix --in-place --preserve-format --out collisions.html3) Verify collisions are gone
python audit_collisions.py --root . --side both --stockfish /path/to/stockfish --out after.html4) Refresh UI counters
python recount_opening_names.py --root . --in-placeNotes
--in-place.--preserve-formatkeepslines.jsformatting aligned with upstream, so the Git diff stays focused on actual removed line strings.Thanks