Skip to content

add extension set pruning to shadow play and word generation#15

Merged
andy-k merged 9 commits intomainfrom
extension-sets
Mar 28, 2026
Merged

add extension set pruning to shadow play and word generation#15
andy-k merged 9 commits intomainfrom
extension-sets

Conversation

@andy-k
Copy link
Copy Markdown
Owner

@andy-k andy-k commented Mar 28, 2026

Summary

  • Compute left/right extension sets per strip via GADDAG traversal: which tiles can extend toward valid words in the inline direction
  • AND extension sets with cross_set & rack_bits in shadow play (both directions) and word generation (play_left/play_right)
  • Single-pass GADDAG traversal: one node yields both left extension (children) and right extension (seek separator, children)
  • Skip shadow play entirely when extension set is zero at anchor
  • Reset extension sets in reset_for_another_kwg

Test plan

  • movegen baseline test passes (tie-breaking order changes from tighter shadow bounds)
  • cargo fmt, clippy, build pass on all commits
  • build round-trip tests pass

andy-k and others added 9 commits March 26, 2026 10:02
Compute left/right extension sets per strip via GADDAG traversal.
Left extension: which tiles can extend leftward (from tiles to
the right). Right extension: seek separator from the same node.
AND extension sets with cross_set & rack_bits in shadow play to
prune tiles that can't extend the main word.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
A non-empty extension set should allow blanks (bit 0), matching
how cross sets work. Use bits | (bits != 0) pattern.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
One right-to-left pass per strip computes both left and right
extension sets from each tile group's GADDAG node: children
give left extension, seek(separator) then children give right
extension. No behavioral change.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
AND left_extension_strip and right_extension_strip at every
position in both shadow_play_left and shadow_play_right. This
adds inline-direction pruning at positions between two tile
groups where both extension sets are non-trivial.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Pre-AND left and right extension sets during computation,
storing one combined extension_set per direction instead of
separate left/right arrays (4 arrays -> 2). No behavioral
change since both were already ANDed at each shadow play
position.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
If no tile can extend in either direction at an anchor position,
skip shadow play entirely. Avoids accumulator setup and rack
tally cloning for provably dead anchors.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Extension sets are derived from the KWG, so they must be
invalidated when switching to a different KWG.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Word generation needs left and right extension sets separately:
play_right uses left_extension (tiles ahead to the right),
play_left uses right_extension (tiles ahead to the left).
Shadow play continues to AND both at each position.

Upfront fill moved out of gen_extension_sets to a single memset
per array before the strip loops.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
AND left_extension_strip in play_right and right_extension_strip
in play_left before iterating KWG children. This prunes tiles
that pass the cross set but cannot extend toward board tiles
the traversal hasn't reached yet, avoiding unnecessary KWG arc
iterations.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@andy-k andy-k merged commit e74d6cd into main Mar 28, 2026
6 checks passed
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