package strategies import ( "fmt" "git.kleiax.de/homepage/board" ) // ────────────────────────────────────────────────────────────────────────────── // // STRATEGY INTERFACE // // ────────────────────────────────────────────────────────────────────────────── // type Strategy interface { Init(f *board.Field) ApplyAll() int ApplyNext() bool Name() string SearchProgressableCells() int } // ────────────────────────────────────────────────────────────────────────────── // // VISUALITION INTERFACE // // ────────────────────────────────────────────────────────────────────────────── // type StrategyVisualization interface { pointOut(f *board.Field) []board.Mark } // ────────────────────────────────────────────────────────────────────────────── // // BASE STRUCTURE // // ────────────────────────────────────────────────────────────────────────────── // type Base struct { name string field *board.Field changes []board.ExternalChange } func (b *Base) Init(f *board.Field) { b.field = f } func (b *Base) ApplyAll() int { for _, change := range b.changes { b.field.AddChange(&change) } return len(b.changes) } func (b *Base) ApplyNext() bool { if len(b.changes) < 1 { return false } b.field.AddChange(&b.changes[0]) b.changes = b.changes[1:] return true } func (b *Base) getName() string { return "Unkown" } func (b *Base) Name() string { return fmt.Sprintf("Diese Strategie heißt: %s", b.getName()) }