Documentation
¶
Overview ¶
Package goap provides deterministic goal-oriented action planning over immutable planning.WorldState values. Its Planner uses uniform-cost search, which is complete and cost-optimal for the non-negative finite Action costs accepted by the Planning domain.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ErrExpansionLimitReached = errors.New("goap: expansion limit reached")
ErrExpansionLimitReached distinguishes bounded search from an unsatisfiable goal.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxExpansions bounds states removed from the frontier. Zero selects a safe
// default of 10,000 expansions.
MaxExpansions uint32
}
Config contains the bounded search policy for a GOAP Planner.
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
Planner performs stateless uniform-cost search and is safe for concurrent use after construction.
func New ¶
New returns a planner whose search is bounded by configuration, because GOAP's state space grows with the action set and an unbounded search inside a Step would block the Process that owns it.
func (*Planner) Plan ¶
Example ¶
package main
import (
"context"
"fmt"
"github.com/Tangerg/scope/agent/planning"
"github.com/Tangerg/scope/agent/planning/goap"
)
func main() {
ready, err := planning.NewCondition("service.ready", planning.True)
if err != nil {
panic(err)
}
state, err := planning.NewWorldState(ready)
if err != nil {
panic(err)
}
goal, err := planning.NewGoal(planning.GoalConfig{
Name: "service.ready", Description: "The service is ready.", Conditions: []planning.Condition{ready},
})
if err != nil {
panic(err)
}
problem, err := planning.NewProblem(state, goal)
if err != nil {
panic(err)
}
plan, found, err := goap.New(goap.Config{}).Plan(context.Background(), problem)
if err != nil {
panic(err)
}
fmt.Println(found, len(plan.Actions()), plan.TotalCost())
}
Output: true 0 0