Implement Scrabble move generator (DAWG) with English and Russian rules
A Go library that returns every legal play ranked by score and scores or validates plays, using the Appel-Jacobson DAWG algorithm over github.com/iliadenisov/dafsa v1.1.0. - DAWG move generation (across / down / both), full tournament scoring with a per-tile breakdown; public Solver: GenerateMoves (ranked), ScorePlay, ValidatePlay. - Rulesets: English Scrabble, Russian Scrabble, Эрудит (parameterizable Ruleset). - cmd/builddict (build the DAWG from the dictionaries submodule), cmd/stress (self-play benchmark), selfplay engine; brute-force test oracle. - A GADDAG was implemented, benchmarked and removed (the DAWG was smaller and faster for a scoring solver); see RESULTS.md and ALGORITHM.md.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package selfplay_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/iliadenisov/alphabet"
|
||||
|
||||
"scrabble-solver/internal/dictdawg"
|
||||
"scrabble-solver/internal/wordlist"
|
||||
"scrabble-solver/rules"
|
||||
"scrabble-solver/scrabble"
|
||||
"scrabble-solver/selfplay"
|
||||
)
|
||||
|
||||
func TestPlayGameSmoke(t *testing.T) {
|
||||
rs := rules.English()
|
||||
words := wordlist.Encode([]string{
|
||||
"cat", "cats", "car", "care", "cares", "cot", "cap", "cab", "at", "as",
|
||||
"tea", "eat", "ear", "era", "are", "oat", "oats", "sat", "set", "sea",
|
||||
"tar", "tars", "star", "arts", "rat", "rats", "ace", "aces", "scar", "scare",
|
||||
}, alphabet.Latin(), 2, 15)
|
||||
f, err := dictdawg.Build(alphabet.Latin(), words)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
gen := scrabble.NewDAWGGenerator(rs, f)
|
||||
|
||||
res := selfplay.PlayGame(rs, gen, scrabble.Both, 1, nil)
|
||||
if res.Turns == 0 || res.Plays == 0 {
|
||||
t.Errorf("degenerate game: %+v", res)
|
||||
}
|
||||
t.Logf("smoke game: turns=%d plays=%d scores=%v", res.Turns, res.Plays, res.Scores)
|
||||
}
|
||||
Reference in New Issue
Block a user