scrabble: add single-word-per-turn rule via PlayOptions
Add an optional "single word per turn" rule: only the main word along the
play direction is validated and scored; perpendicular cross-words are ignored
— not formed, validated, scored, or used to constrain move generation. The
zero PlayOptions stays standard Scrabble, so existing callers are unchanged.
- PlayOptions{IgnoreCrossWords} threaded through new EvaluateOpts,
Solver.{ScorePlay,ValidatePlay,GenerateMoves}Opts and the DAWG generator
(relaxed cross-sets via fullSet, main-word-only scoring).
- connected() tests perpendicular adjacency directly instead of via
Move.Cross, so an all-new main word touching the board only sideways still
connects when cross-words are suppressed (behaviour-preserving for standard
play).
- Tests: focused corner-case suite (solver_opts_test.go) and a single-word
GCG fixture; the 17 real-game GCG fixtures stay green as the standard-rules
regression guard.
This commit is contained in:
@@ -72,3 +72,14 @@ type Move struct {
|
||||
Bonus int // all-tiles (bingo) bonus included in Score, or 0
|
||||
Score int // total: Main.Score + Σ Cross.Score + Bonus
|
||||
}
|
||||
|
||||
// PlayOptions tunes optional rule variations applied when evaluating, validating or
|
||||
// generating plays. The zero value is standard Scrabble.
|
||||
type PlayOptions struct {
|
||||
// IgnoreCrossWords makes a play's perpendicular cross-words irrelevant: they are not
|
||||
// formed, validated, scored or used to constrain move generation. It expresses the
|
||||
// "single word per turn" house rule, under which only the main word along the play
|
||||
// direction must be a valid word; board connectivity and the first-move centre rule
|
||||
// still apply.
|
||||
IgnoreCrossWords bool
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user