-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.go
43 lines (36 loc) · 910 Bytes
/
options.go
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
38
39
40
41
42
43
package astar
type heuristic int
const (
// Manhattan heuristic.
man heuristic = iota
// Diagonal distance heuristic.
dd
// Euclidean distance heuristic.
euc
)
// Option is a functional option for the pathfinder.
type Option func(o *option)
// option contains the options for the pathfinder.
type option struct {
diagonals bool
heuristic heuristic
punishChangeDirection bool
}
// WithDiagonals enables diagonal movement in the search space.
func WithDiagonals() Option {
return Option(func(o *option) {
o.diagonals = true
})
}
// PunishChangeDirection punishes changing direction when calculating G.
func PunishChangeDirection() Option {
return Option(func(o *option) {
o.punishChangeDirection = true
})
}
// EuclideanDistance sets the heuristic to Euclidean distance.
func EuclideanDistance() Option {
return Option(func(o *option) {
o.heuristic = euc
})
}