Refactor Sudoku solver architecture
This commit is contained in:
+7
-7
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user