bgo

package
v0.0.0-...-c3e735c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SUCCESS = Status("Success")
	FAILURE = Status("Failure")
	RUNNING = Status("Runnig")
	ERROR   = Status("Error")

	COMPOSITE = NodeCategorie("Composite")
	DECORATOR = NodeCategorie("Decorator")
	ACTION    = NodeCategorie("Action")
	CONDITION = NodeCategorie("Condition")
)

Functions

func CreateUUID

func CreateUUID() string

Types

type BaseNode

type BaseNode struct {
	ID          string
	Name        string
	Category    NodeCategorie
	Title       string
	Description string
}

func CreateBaseNode

func CreateBaseNode(title string) *BaseNode

func (*BaseNode) Close

func (bn *BaseNode) Close(context *Context)

func (*BaseNode) Enter

func (bn *BaseNode) Enter(context *Context)

func (*BaseNode) Exit

func (bn *BaseNode) Exit(context *Context)

func (*BaseNode) Id

func (this *BaseNode) Id() string

func (*BaseNode) Open

func (bn *BaseNode) Open(context *Context)

func (*BaseNode) Tick

func (bn *BaseNode) Tick(context *Context) Status

type BehaviorTree

type BehaviorTree struct {
	Id          string
	Title       string
	Description string
	Root        Node
	*Blackboard
}

func CreateBehaviorTree

func CreateBehaviorTree(title, desc string, blackboard *Blackboard) *BehaviorTree

func (*BehaviorTree) GetNodeMemory

func (this *BehaviorTree) GetNodeMemory(node Node) *Memory

func (*BehaviorTree) GetTreeMemory

func (this *BehaviorTree) GetTreeMemory() *Memory

func (*BehaviorTree) Tick

func (this *BehaviorTree) Tick(context *Context) Status

type Blackboard

type Blackboard struct {
	// contains filtered or unexported fields
}

func CreateBlackboard

func CreateBlackboard() *Blackboard

func (*Blackboard) GetBaseMemory

func (this *Blackboard) GetBaseMemory() *Memory

type Context

type Context struct {
	*BehaviorTree
	ContextId string
	Target    interface{}
	// contains filtered or unexported fields
}

func CreateContext

func CreateContext(target interface{}) *Context

func (*Context) GetContextMemory

func (this *Context) GetContextMemory() *Memory

type Decorator

type Decorator struct {
	BaseNode
	// contains filtered or unexported fields
}

*

  • Decorator is the base class for all decorator nodes. Thus, if you want to
  • create new custom decorator nodes, you need to inherit from this class.

*

type Inverter

type Inverter struct {
	Decorator
}

*

  • The Inverter decorator inverts the result of the child, returning `SUCCESS`
  • for `FAILURE` and `FAILURE` for `SUCCESS`. *

func NewInverter

func NewInverter(title string, child Node) *Inverter

func (*Inverter) Tick

func (this *Inverter) Tick(context *Context) Status

type Limiter

type Limiter struct {
	Decorator
	// contains filtered or unexported fields
}

*

  • This decorator limit the number of times its child can be called. After a
  • certain number of times, the Limiter decorator returns `FAILURE` without
  • executing the child. *

func NewLimiter

func NewLimiter(title string, maxLoop int, child Node) *Limiter

func (*Limiter) Open

func (this *Limiter) Open(context *Context)

func (*Limiter) Tick

func (this *Limiter) Tick(context *Context) Status

type MaxTime

type MaxTime struct {
	Decorator
	// contains filtered or unexported fields
}

*

  • The MaxTime decorator limits the maximum time the node child can execute.
  • Notice that it does not interrupt the execution itself (i.e., the child
  • must be non-preemptive), it only interrupts the node after a `RUNNING`
  • status.

*

func NewMaxTime

func NewMaxTime(title string, duration time.Duration, child Node) *MaxTime

func (*MaxTime) Open

func (this *MaxTime) Open(context *Context)

func (*MaxTime) Tick

func (this *MaxTime) Tick(context *Context) Status

type Memory

type Memory struct {
	Integer      map[string]int
	Float        map[string]float32
	Complex      map[string]complex64
	Byte         map[string]byte
	Rune         map[string]rune
	Bool         map[string]bool
	String       map[string]string
	Memory       map[string]*Memory
	Time         map[string]time.Time
	ArrayInteger map[string][]int
	ArrayFloat   map[string][]float32
	ArrayComplex map[string][]complex64
	ArrayByte    map[string][]byte
	ArrayRune    map[string][]rune
	ArrayBool    map[string][]bool
	ArrayString  map[string][]string
	ArrayNode    map[string][]Node
}

func CreateMemory

func CreateMemory() *Memory

type Node

type Node interface {
	Id() string
	Enter(context *Context)
	Exit(context *Context)
	Open(context *Context)
	Close(context *Context)
	Tick(context *Context) Status
}

type NodeCategorie

type NodeCategorie string

type Priority

type Priority struct {
	BaseNode
	// contains filtered or unexported fields
}

*

  • Priority contexts its children sequentially until one of them returns
  • `SUCCESS`, `RUNNING` or `ERROR`. If all children return the failure state,
  • the priority also returns `FAILURE`.

*

func NewPriority

func NewPriority(title string, children ...Node) *Priority

func (*Priority) Tick

func (this *Priority) Tick(context *Context) Status

type RepeatUntilFailure

type RepeatUntilFailure struct {
	Decorator
	// contains filtered or unexported fields
}

func NewRepeatUntilFailure

func NewRepeatUntilFailure(title string, maxLoop int, child Node) *RepeatUntilFailure

func (*RepeatUntilFailure) Open

func (this *RepeatUntilFailure) Open(context *Context)

func (*RepeatUntilFailure) Tick

func (this *RepeatUntilFailure) Tick(context *Context) Status

type RepeatUntilSuccess

type RepeatUntilSuccess struct {
	Decorator
	// contains filtered or unexported fields
}

func NewRepeatUntilSuccess

func NewRepeatUntilSuccess(title string, maxLoop int, child Node) *RepeatUntilSuccess

func (*RepeatUntilSuccess) Open

func (this *RepeatUntilSuccess) Open(context *Context)

func (*RepeatUntilSuccess) Tick

func (this *RepeatUntilSuccess) Tick(context *Context) Status

type Repeater

type Repeater struct {
	Decorator
	// contains filtered or unexported fields
}

*

  • Repeater is a decorator that repeats the tick signal until the child node
  • return `RUNNING` or `ERROR`. Optionally, a maximum number of repetitions
  • can be defined.

*

func NewRepeater

func NewRepeater(title string, maxLoop int, child Node) *Repeater

func (*Repeater) Open

func (this *Repeater) Open(context *Context)

func (*Repeater) Tick

func (this *Repeater) Tick(context *Context) Status

type Sequence

type Sequence struct {
	BaseNode
	// contains filtered or unexported fields
}

*

  • The Sequence node contexts its children sequentially until one of them
  • returns `FAILURE`, `RUNNING` or `ERROR`. If all children return the
  • success state, the sequence also returns `SUCCESS`. *

func NewSequence

func NewSequence(title string, children ...Node) *Sequence

func (*Sequence) Tick

func (this *Sequence) Tick(context *Context) Status

type Status

type Status string

func ExecuteNode

func ExecuteNode(node Node, context *Context) Status

type Wait

type Wait struct {
	BaseNode
	// contains filtered or unexported fields
}

*

  • Wait a few seconds. *

func NewWait

func NewWait(title string) *Wait

func (*Wait) Open

func (this *Wait) Open(context *Context)

func (*Wait) Tick

func (this *Wait) Tick(context Context) Status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL