-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathgenerator.go
More file actions
37 lines (29 loc) · 762 Bytes
/
Copy pathgenerator.go
File metadata and controls
37 lines (29 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package rush
import "fmt"
type Generator struct {
Width int
Height int
PrimarySize int
PrimaryRow int
// MinPieces int
// MaxPieces int
// MinSize int
// MaxSize int
}
func NewDefaultGenerator() *Generator {
return &Generator{6, 6, 2, 2}
}
func (g *Generator) Generate(iterations int) *Board {
// create empty board
board := NewEmptyBoard(g.Width, g.Height)
// place the primary piece
board.AddPiece(Piece{g.PrimaryRow * g.Width, g.PrimarySize, Horizontal})
// simulated annealing
board = anneal(board, 20, 0.5, iterations)
// unsolve step
before := NewSolver(board).Solve().NumMoves
board, _ = NewUnsolver(board).Unsolve()
after := NewSolver(board).Solve().NumMoves
fmt.Println(before, after)
return board
}