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.
40 lines
888 B
Go
40 lines
888 B
Go
package encoding
|
|
|
|
import "testing"
|
|
|
|
func TestCellRoundTrip(t *testing.T) {
|
|
for letter := range byte(26) {
|
|
c := Cell(letter, false)
|
|
if IsEmpty(c) {
|
|
t.Errorf("Cell(%d,false) reports empty", letter)
|
|
}
|
|
if IsBlank(c) {
|
|
t.Errorf("Cell(%d,false) reports blank", letter)
|
|
}
|
|
if got := Letter(c); got != letter {
|
|
t.Errorf("Letter(Cell(%d,false)) = %d", letter, got)
|
|
}
|
|
|
|
b := Cell(letter, true)
|
|
if !IsBlank(b) {
|
|
t.Errorf("Cell(%d,true) not blank", letter)
|
|
}
|
|
if got := Letter(b); got != letter {
|
|
t.Errorf("Letter(Cell(%d,true)) = %d, want %d", letter, got, letter)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestEmpty(t *testing.T) {
|
|
if !IsEmpty(Empty) {
|
|
t.Error("IsEmpty(Empty) = false")
|
|
}
|
|
if IsEmpty(Cell(0, false)) {
|
|
t.Error("IsEmpty(Cell('a')) = true")
|
|
}
|
|
// 'a' (index 0) must not collide with empty.
|
|
if Cell(0, false) == Empty {
|
|
t.Error("Cell('a') collides with Empty")
|
|
}
|
|
}
|