Refactor Sudoku solver architecture

This commit is contained in:
2026-09-10 23:11:34 +02:00
parent 7bf4a8d725
commit a5ec338277
21 changed files with 475 additions and 260 deletions
+7 -7
View File
@@ -1,7 +1,7 @@
package logic
import (
"git.kleiax.de/homepage/board"
"git.kleiax.de/homepage/field"
"git.kleiax.de/homepage/logic/strategies"
)
@@ -12,7 +12,7 @@ import (
type Solver struct {
strategies []strategies.Strategy
returnTo int
field *board.Field
field *field.Field
conf struct {
all bool
repeat bool
@@ -23,7 +23,7 @@ func (s *Solver) Add(strategy strategies.Strategy) {
s.strategies = append(s.strategies, strategy)
}
func (s *Solver) InitStragies(field *board.Field) {
func (s *Solver) InitStragies(field *field.Field) {
s.returnTo = 1
s.field = field
for _, strategy := range s.strategies {
@@ -38,11 +38,11 @@ func (s *Solver) Run(i int) bool {
}
for _, change := range s.strategies[j].ApplyAll() {
if change.Action != board.ActionSetNumber {
if change.Action != field.ActionSetNumber {
continue
}
s.field.ForEachPartAtPos(change.Cell.Pos, func(part board.Part) {
part.ForEachCell(func(cell *board.Cell) {
s.field.ForEachPartAtPos(change.Cell.Pos, func(part field.Part) {
part.ForEachCell(func(cell *field.Cell) {
cell.Notes.Remove(s.field, cell, change.Value, "remove note after insert of a number", nil)
})
})
@@ -61,6 +61,6 @@ func (s *Solver) Search() {
}
func (s *Solver) GetSolutionPath() []board.ExternalChange {
func (s *Solver) GetSolutionPath() []field.ExternalChange {
return nil
}