Skip to content

feat: read more set codes in the collector line - #511

Merged
Reilley64 merged 4 commits into
mainfrom
ticket/507-read-more-set-codes
Oct 21, 2026
Merged

Reilley64 merged 4 commits into
mainfrom
ticket/507-read-more-set-codes

Conversation

@Reilley64

Copy link
Copy Markdown
Owner

Closes #507

Summary

The reader takes more set codes from the line with the language code, and decide matches them only against the sets of the image shortlist.

 CollectorLineReader.parse
+  map Cyrillic look-alike letters to Latin
+  take the code before the language code, spaces removed
+    separators: • · . * ★ ☆ - + # ~ %, or none ("DSCEN"), one stray digit before EN
+  read no collector number from the language line           # "M210 EN" is not 210
+  mark a number read before a rarity letter ("269 C")

 CardRecognizer.decide
-  setCode = exact code, or the one shortlist set one character from the token
+  setCode = exact code, or the one shortlist set at the best match level:
+    exact > equal after look-alikes > first character dropped or separator read > one character apart
+  drop a "269 C" number that names a printing the image does not support
   set code accept
+    needs the set to have one printing of the top card in the gallery
+    needs the next other card at least the art margin behind
   shared art, number with no set code
+    show the one same-art printing of the top card with that number first, abstain
   unique art accept
+    abstains when a set code was read and the top printing's frame (1993, 1997, 2003) prints none

README.md (Card recognizer) describes the rules. The research and the replay are in docs/research/collector-line-set-codes.md.

Evidence

Swift tests: swift test with the fixture model, 88 passed (22 new). Each new rule has a mutation check. I broke each rule on purpose and its test failed: the language line number, the two-set tie, the margin guard, the older-frame guard, the set guard, the dropped number, the number-first rule, the separator level, and the joined code in lowercase text.

Local recognizer replay

bun run recognizer:replay on the owner's Mac (Apple M3, macOS 27.0.1), with RECOGNIZER_GALLERY_DIR=~/Library/Caches/mtgscan/gallery/installed/20261021-c38f43. I ran it on main (a6fcfaf, exit 0, 0 changes against the expected files) and on this branch (68ffac7, exit 2, every gate passes). Feature print parity: lowest cosine 1 over 24 references.

Exact accepts / right printing first:

Test Before (main) After Replica estimate in #507
Gate 1, real crops 207 / 230 217 / 241 216 / 241
Gate 2, simulated scans 2,134 / 2,531 2,161 / 2,542 2,164 / 2,542
S07 crops (outside the replay) 75 / 89 85 / 94 85 / 94
Gate Before After
Wrong-card accepts, full and held out 0 0
Gate 2 accepts outside the candidate list 0 0
Real accepts with the true printing missing 0 0
Simulated accepts with the true printing missing 401, all the right card 398, all the right card
Non-card crops rejected 11 of 11 11 of 11

The expected files are recorded again with 68ffac7. A replay against them now has 0 changes.

Changed results:

  • Gate 1, 15 scans: 10 gain an exact accept. 5 abstains now show the right printing first. None lost.
  • Gate 2, 67 scans:
    • 30 gain an exact accept, and 13 abstains now show the right printing first.
    • 7 now accept another printing of the right card: 5 The List cards as the printing they reprint, and 2 promos as their same-text twin. Each is in the candidate list.
    • 9 abstains show a same-number printing of the right card first: 4 World Championship deck cards and 5 promo twins.
    • 3 exact accepts now abstain. Swamp MID 382: MID has 3 Swamps and no number was read. Command Tower DMC 204: after the look-alike map, "2MC" is one character from two shortlist sets. Andrios PH21 1: "121 • EN" is one character from LCI, and LCI 1 names another card.
    • Mountain PLST WOE-273, accepted as WOE 273 before, abstains for the set guard.
    • 4 other abstains change their first candidate.
  • Gate 2 held out, 13 scans: 398 accepts against 401, 0 wrong cards.

Guard 6c (a set with two printings of the top card needs a number) costs 1 exact accept, Swamp MID 382, on Gate 2. It costs none on Gate 1 or the S07 crops. That is below "a few", so I did not run a replay without it.

The S07 crops stay outside the repo. I ran them through the recognizer command on main and on this branch, with the true printing of each card from the S07 run.

Merge Danger

Door: two-way

Reverting the commits restores the old rules and the old expected files.

Blast Radius: recognition

Every scan goes through the new parser and decision. The gates show no wrong-card accept on the Mac. The phone reads the strip at another scale (research section 1), so Gate 3 and the next phone session are the check there.

The reader maps Cyrillic look-alike letters to Latin, takes the code before
the language code with spaces removed, allows more separators and one stray
digit before EN, and reads no collector number from the language line.

The decision matches a set code only against the sets of the image
shortlist, with ordered match levels, drops a number read before a rarity
letter when it names a printing the image does not support, and shows the one
same-art printing with a read number first. Three guards keep set-code
accepts safe: the next card must be the art margin behind, a set with two
printings of the card needs a number, and an older frame with a read set code
does not accept by unique art.

Refs #507
Gate 1 has 217 correct accepts, up from 207, and 241 right printings first,
up from 230. Gate 2 has 2,161 exact accepts, up from 2,134, and 2,542 right
printings first, up from 2,531. No gate records a wrong-card accept.

Refs #507
README.md (Card recognizer) describes how the reader takes a set code and
how the decision matches it. docs/research/collector-line-set-codes.md keeps
the research behind #507 and the replay of the built rules.

Refs #507
@Reilley64
Reilley64 marked this pull request as ready for review October 21, 2026 08:41
@Reilley64
Reilley64 merged commit 88004a9 into main Oct 21, 2026
6 checks passed
@Reilley64
Reilley64 deleted the ticket/507-read-more-set-codes branch October 21, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant