first successful run to solve a simple puzzle
This commit is contained in:
@@ -12,8 +12,8 @@ import (
|
||||
|
||||
type Strategy interface {
|
||||
Init(f *board.Field)
|
||||
ApplyAll() int
|
||||
ApplyNext() bool
|
||||
ApplyAll() []board.ExternalChange
|
||||
ApplyNext() board.ExternalChange
|
||||
Name() string
|
||||
SearchProgressableCells() int
|
||||
}
|
||||
@@ -40,23 +40,31 @@ func (b *Base) Init(f *board.Field) {
|
||||
b.field = f
|
||||
}
|
||||
|
||||
func (b *Base) ApplyAll() int {
|
||||
func (b *Base) ApplyAll() []board.ExternalChange {
|
||||
changesCopy := make([]board.ExternalChange, len(b.changes))
|
||||
copy(changesCopy, b.changes)
|
||||
|
||||
for _, change := range b.changes {
|
||||
b.field.AddChange(&change)
|
||||
}
|
||||
len := len(b.changes)
|
||||
|
||||
b.changes = b.changes[:0]
|
||||
|
||||
return len
|
||||
return changesCopy
|
||||
}
|
||||
|
||||
func (b *Base) ApplyNext() bool {
|
||||
func (b *Base) ApplyNext() board.ExternalChange {
|
||||
if len(b.changes) < 1 {
|
||||
return false
|
||||
return board.ExternalChange{}
|
||||
}
|
||||
|
||||
changeCopy := b.changes[0]
|
||||
|
||||
b.field.AddChange(&b.changes[0])
|
||||
|
||||
b.changes = b.changes[1:]
|
||||
return true
|
||||
|
||||
return changeCopy
|
||||
}
|
||||
|
||||
func (b *Base) getName() string {
|
||||
|
||||
Reference in New Issue
Block a user