refactore to new project structure

This commit is contained in:
2026-07-19 11:18:16 +02:00
parent 1ff0efb557
commit 9a69d4610c
12 changed files with 108 additions and 81 deletions
+15 -17
View File
@@ -3,7 +3,7 @@ package strategies
import (
"fmt"
"git.kleiax.de/homepage/libs/sudoku/board"
"git.kleiax.de/homepage/board"
)
// ────────────────────────────────────────────────────────────────────────────── //
@@ -14,11 +14,18 @@ type Strategy interface {
Init(f *board.Field)
ApplyAll() int
ApplyNext() bool
ApplyOne(n int) bool
Name() string
SearchProgressableCells() int
}
// ────────────────────────────────────────────────────────────────────────────── //
// VISUALITION INTERFACE //
// ────────────────────────────────────────────────────────────────────────────── //
type StrategyVisualization interface {
pointOut(f *board.Field) []board.Mark
}
// ────────────────────────────────────────────────────────────────────────────── //
// BASE STRUCTURE //
// ────────────────────────────────────────────────────────────────────────────── //
@@ -26,7 +33,7 @@ type Strategy interface {
type Base struct {
name string
field *board.Field
changes []board.Change //eigener Typ muss her
changes []board.ExternalChange
}
func (b *Base) Init(f *board.Field) {
@@ -34,9 +41,9 @@ func (b *Base) Init(f *board.Field) {
}
func (b *Base) ApplyAll() int {
// for _, change := range sb.changes {
// //change.do()
// }
for _, change := range b.changes {
b.field.AddChange(&change)
}
return len(b.changes)
}
@@ -44,24 +51,15 @@ func (b *Base) ApplyNext() bool {
if len(b.changes) < 1 {
return false
}
//sb.changes[0].do()
b.field.AddChange(&b.changes[0])
b.changes = b.changes[1:]
return true
}
func (b *Base) ApplyOne(n int) bool {
if len(b.changes) <= n || n < 0 {
return false
}
//sb.changes[n].do()
b.changes = append(b.changes[:n], b.changes[n+1:]...)
return true
}
func (b *Base) getName() string {
return "Unkown"
}
func (b *Base) Name() string {
return fmt.Sprintf("Die Strategie heißt: %s", b.getName())
return fmt.Sprintf("Diese Strategie heißt: %s", b.getName())
}