Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AStar ¶
type AStar struct {
// contains filtered or unexported fields
}
AStar implements the A* search algorithm. See https://en.wikipedia.org/wiki/A*_search_algorithm for a quick overview.
func (AStar) Run ¶
func (a AStar) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type Algorithm ¶
type Algorithm interface { // Run searches in the environment for the goal node Run(ctx search.Context, e environments.Environment) (search.Result, error) }
Algorithm defines the interface for a search algorithm
func GetAlgorithm ¶
GetAlgorithm returns the desired algorithm
type BreadthFirst ¶
type BreadthFirst struct {
// contains filtered or unexported fields
}
BreadthFirst implements the breadth first search algorithm
func (BreadthFirst) Run ¶
func (a BreadthFirst) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type DepthFirst ¶
type DepthFirst struct {
// contains filtered or unexported fields
}
DepthFirst implements the depth first search algorithm
func (DepthFirst) Run ¶
func (a DepthFirst) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type DepthLimited ¶
type DepthLimited struct {
// contains filtered or unexported fields
}
DepthLimited implements the depth limited search algorithm. It requires the `depth_limit` custom argument to be passed
func (DepthLimited) Run ¶
func (a DepthLimited) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type GreedyBestFirst ¶
type GreedyBestFirst struct {
// contains filtered or unexported fields
}
GreedyBestFirst implements the greedy best first search algorithm
func (GreedyBestFirst) Run ¶
func (a GreedyBestFirst) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type IterativeDeepening ¶
type IterativeDeepening struct {
// contains filtered or unexported fields
}
IterativeDeepening implements the depth limited search algorithm. It can take the `initial_depth` custom argument, but by the default the value will be 0
func (IterativeDeepening) Run ¶
func (a IterativeDeepening) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type PriorityNodeQueue ¶
type PriorityNodeQueue struct { PriorityNodeQueueConfig // Frontier is the current // open set Frontier []environments.Node // PriorityMap is referenced // to get the priority value // for a node. Lowest priority // nodes are the ones that are // popped PriorityMap map[string]int // NodeIndexes keeps track // of the indexes of nodes // based upon their name NodeIndexes map[string]int }
PriorityNodeQueue implements heap.Interface to allow for a priority queue based on a custom priority map; see heap.Interface for usage
func NewPriorityNodeQueue ¶
func NewPriorityNodeQueue(start environments.Node, priorityMap map[string]int, config PriorityNodeQueueConfig) *PriorityNodeQueue
NewPriorityNodeQueue initializes a priority queue with the provided start node and priority map to use
func (*PriorityNodeQueue) Len ¶
func (q *PriorityNodeQueue) Len() int
func (*PriorityNodeQueue) Less ¶
func (q *PriorityNodeQueue) Less(i, j int) bool
func (*PriorityNodeQueue) Pop ¶
func (q *PriorityNodeQueue) Pop() interface{}
Pop returns the value with the lowest
func (*PriorityNodeQueue) Push ¶
func (q *PriorityNodeQueue) Push(x interface{})
Push adds a new value
func (*PriorityNodeQueue) Swap ¶
func (q *PriorityNodeQueue) Swap(i, j int)
type PriorityNodeQueueConfig ¶
type PriorityNodeQueueConfig struct {
HigherIsBetter bool
}
PriorityNodeQueueConfig defines optional arguments when creating a priority node queue
type RecursiveBestFirstSearch ¶
type RecursiveBestFirstSearch struct {
// contains filtered or unexported fields
}
RecursiveBestFirstSearch implements the RBFS, a modification and/or optimization of A*
func (RecursiveBestFirstSearch) Run ¶
func (a RecursiveBestFirstSearch) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result
type UniformCost ¶
type UniformCost struct {
// contains filtered or unexported fields
}
UniformCost implements the uniform cost search algorithm
func (UniformCost) Run ¶
func (a UniformCost) Run(ctx search.Context, e environments.Environment) (search.Result, error)
Run runs A* on the environment and returns the result