Skip to content

Commit 011f76d

Browse files
andy-kclaude
andcommitted
use extension sets in word generation
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) <noreply@anthropic.com>
1 parent 3c939e7 commit 011f76d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/movegen.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,6 +1523,8 @@ struct GenPlaceMovesParams<'a, CallbackType: FnMut(i8, &[u8], i32, f32), N: kwg:
15231523
board_snapshot: &'a BoardSnapshot<'a, N, L>,
15241524
board_strip: &'a [u8],
15251525
cross_set_strip: &'a [CrossSet],
1526+
left_extension_strip: &'a [u64],
1527+
right_extension_strip: &'a [u64],
15261528
remaining_word_multipliers_strip: &'a [i8],
15271529
remaining_tile_multipliers_strip: &'a [i8],
15281530
face_value_scores_strip: &'a [i8],
@@ -1655,6 +1657,11 @@ fn gen_classic_place_moves<
16551657
this_cross_bits = !1;
16561658
is_unique = true;
16571659
};
1660+
// Filter by left extension set (tiles to the right the traversal hasn't seen).
1661+
this_cross_bits &= env.params.left_extension_strip[idx as usize];
1662+
if this_cross_bits == 0 {
1663+
return;
1664+
}
16581665
let new_word_multiplier = acc.word_multiplier
16591666
* env.params.remaining_word_multipliers_strip[idx as usize] as i32;
16601667
let tile_multiplier = env.params.remaining_tile_multipliers_strip[idx as usize];
@@ -1777,6 +1784,11 @@ fn gen_classic_place_moves<
17771784
this_cross_bits = !1;
17781785
is_unique = true;
17791786
}
1787+
// Filter by right extension set (tiles to the left the traversal hasn't seen).
1788+
this_cross_bits &= env.params.right_extension_strip[idx as usize];
1789+
if this_cross_bits == 0 {
1790+
return;
1791+
}
17801792
let new_word_multiplier = acc.word_multiplier
17811793
* env.params.remaining_word_multipliers_strip[idx as usize] as i32;
17821794
let tile_multiplier = env.params.remaining_tile_multipliers_strip[idx as usize];
@@ -2234,6 +2246,20 @@ fn gen_place_moves_at<
22342246
} else {
22352247
&working_buffer.cross_set_for_across_plays[strip_range_start..strip_range_end]
22362248
},
2249+
left_extension_strip: if placement.down {
2250+
&working_buffer.left_extension_set_for_down_plays
2251+
[strip_range_start..strip_range_end]
2252+
} else {
2253+
&working_buffer.left_extension_set_for_across_plays
2254+
[strip_range_start..strip_range_end]
2255+
},
2256+
right_extension_strip: if placement.down {
2257+
&working_buffer.right_extension_set_for_down_plays
2258+
[strip_range_start..strip_range_end]
2259+
} else {
2260+
&working_buffer.right_extension_set_for_across_plays
2261+
[strip_range_start..strip_range_end]
2262+
},
22372263
remaining_word_multipliers_strip: if placement.down {
22382264
&working_buffer.remaining_word_multipliers_for_down_plays
22392265
[strip_range_start..strip_range_end]

0 commit comments

Comments
 (0)