15c7959d96
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.
38 lines
881 B
Go
38 lines
881 B
Go
package wordlist
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/iliadenisov/alphabet"
|
|
)
|
|
|
|
func TestFoldYo(t *testing.T) {
|
|
if got := FoldYo("ёлка"); got != "елка" {
|
|
t.Errorf("FoldYo(ёлка) = %q, want елка", got)
|
|
}
|
|
if got := FoldYo("Ёжик"); got != "Ежик" {
|
|
t.Errorf("FoldYo(Ёжик) = %q, want Ежик", got)
|
|
}
|
|
}
|
|
|
|
func TestEncodeFilterSortDedupe(t *testing.T) {
|
|
got := Encode([]string{
|
|
"cat", "CATS", "ab", "b", "abcdefghi", "cat", " do ", "qu1rk",
|
|
}, alphabet.Latin(), 2, 8)
|
|
|
|
want := [][]byte{
|
|
{0, 1}, // ab
|
|
{2, 0, 19}, // cat
|
|
{2, 0, 19, 18}, // cats (from CATS, case-folded)
|
|
{3, 14}, // do (trimmed)
|
|
}
|
|
if len(got) != len(want) {
|
|
t.Fatalf("got %d words %v, want %d", len(got), got, len(want))
|
|
}
|
|
for i := range want {
|
|
if string(got[i]) != string(want[i]) {
|
|
t.Errorf("word %d = %v, want %v", i, got[i], want[i])
|
|
}
|
|
}
|
|
}
|