Initial commit
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package strategies
|
||||
|
||||
type XChain struct {
|
||||
Base
|
||||
}
|
||||
type XYChain struct {
|
||||
Base
|
||||
}
|
||||
|
||||
type XChainLoop struct {
|
||||
Base
|
||||
}
|
||||
type XYChainLoop struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package strategies
|
||||
|
||||
import "git.kleiax.de/homepage/libs/sudoku/board"
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// LAST_DIGIT STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type LastDigit struct {
|
||||
Base
|
||||
}
|
||||
|
||||
func (ld *LastDigit) SearchProgressableCells() int {
|
||||
ld.field.ForEachPart(func(part board.Part) {
|
||||
missingNumbers := part.GetMissingNumbers()
|
||||
if len(missingNumbers) == 1 {
|
||||
// var emptyCell *Cell
|
||||
// part.forEachCell(func(cell *Cell) {
|
||||
// if cell.number == 0 {
|
||||
// emptyCell = cell
|
||||
// }
|
||||
// })
|
||||
// change := Change{
|
||||
// cell: emptyCell,
|
||||
// action: ActionSetNumber,
|
||||
// value: missingNumbers[0],
|
||||
// }
|
||||
// ld.changes = append(ld.changes, change)
|
||||
}
|
||||
})
|
||||
//fmt.Printf("LastDigit Changes %d", len(ld.changes))
|
||||
return len(ld.changes)
|
||||
}
|
||||
|
||||
func (ld *LastDigit) getName() string {
|
||||
return "Last Digit - Letzte Zahl"
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// CRP STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type CRP struct {
|
||||
Base
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// SIMPLE_COLORING_T1 STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type SimpleColoringT1 struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package strategies
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// HIDDEN_SINGLE STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type HiddenSingle struct {
|
||||
Base
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// HIDDEN_PAIR STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type HiddenPair struct {
|
||||
Base
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// HIDDEN_TRIPLE STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type HiddenTriple struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package strategies
|
||||
|
||||
type LockedPair struct {
|
||||
Base
|
||||
}
|
||||
|
||||
type LockedCandidateT1 struct {
|
||||
Base
|
||||
}
|
||||
type LockedCandidateT2 struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package strategies
|
||||
|
||||
import "git.kleiax.de/homepage/libs/sudoku/board"
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// NAKED_SINGLE STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type NakedSingle struct {
|
||||
Base
|
||||
}
|
||||
|
||||
func (ns *NakedSingle) SearchProgressableCells() int {
|
||||
ns.field.ForEachPart(func(part board.Part) {
|
||||
part.ForEachCell(func(cell *board.Cell) {
|
||||
// candidates := cell.notes.numbers
|
||||
// if len(candidates) == 1 {
|
||||
// change := Change{
|
||||
// cell: cell,
|
||||
// action: ActionSetNumber,
|
||||
// value: candidates[0],
|
||||
// }
|
||||
// ns.changes = append(ns.changes, change)
|
||||
// }
|
||||
})
|
||||
})
|
||||
return len(ns.changes)
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// NAKED_DOUBLE STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type NakedPair struct {
|
||||
Base
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// NAKED_TRIPLE STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type NakedTriple struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package strategies
|
||||
|
||||
type EmptyRectangle struct {
|
||||
Base
|
||||
}
|
||||
type UniqueRectangleT1 struct {
|
||||
Base
|
||||
}
|
||||
type UniqueRectangleT4 struct {
|
||||
Base
|
||||
}
|
||||
type UniqueRectangleT7 struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package strategies
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.kleiax.de/homepage/libs/sudoku/board"
|
||||
)
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// STRATEGY INTERFACE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type Strategy interface {
|
||||
Init(f *board.Field)
|
||||
ApplyAll() int
|
||||
ApplyNext() bool
|
||||
ApplyOne(n int) bool
|
||||
Name() string
|
||||
SearchProgressableCells() int
|
||||
}
|
||||
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
// BASE STRUCTURE //
|
||||
// ────────────────────────────────────────────────────────────────────────────── //
|
||||
|
||||
type Base struct {
|
||||
name string
|
||||
field *board.Field
|
||||
changes []board.Change //eigener Typ muss her
|
||||
}
|
||||
|
||||
func (b *Base) Init(f *board.Field) {
|
||||
b.field = f
|
||||
}
|
||||
|
||||
func (b *Base) ApplyAll() int {
|
||||
// for _, change := range sb.changes {
|
||||
// //change.do()
|
||||
// }
|
||||
return len(b.changes)
|
||||
}
|
||||
|
||||
func (b *Base) ApplyNext() bool {
|
||||
if len(b.changes) < 1 {
|
||||
return false
|
||||
}
|
||||
//sb.changes[0].do()
|
||||
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())
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package strategies
|
||||
|
||||
type Turbot2StringKite struct {
|
||||
Base
|
||||
}
|
||||
type TurbotSkyscraper struct {
|
||||
Base
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package strategies
|
||||
|
||||
type XWing struct {
|
||||
Base
|
||||
}
|
||||
type XYWing struct {
|
||||
Base
|
||||
}
|
||||
type XYZWing struct {
|
||||
Base
|
||||
}
|
||||
type WXYZWingBasic struct {
|
||||
Base
|
||||
}
|
||||
Reference in New Issue
Block a user