Documentation
¶
Overview ¶
Package act is what a rule does: the Then of a Branch, every step said of whom it is done by or to, and the Branch itself, which given to a role is a rule.
act.Branch[Review]{
Name: "escalate",
When: cond.Self.If(overdue).And(cond.Self.If(cond.Not(escalated))),
Then: act.Steps(act.Self.Put(escalated), act.Self.Do(Notify{To: "lead"})),
}
Steps ¶
Self, Other, Around and Ahead are the subjects; their methods are the steps: Subject.Put, Subject.Take or Subject.Hold an effect, Subject.Do a command. Steps runs its parts in order, OneOf the first that does not fail; both take steps and branches.
Branches ¶
A Branch at the top of a rule says its Name; every Branch says its When and its Then. It fires at its moment and is done within the pass. A rule turning to places (cond.Around, Around; cond.Ahead, Ahead) runs once a place: the smallest part of it holding every clause of a place.
For package plan ¶
A plan is made of what lasts over steps, in package plan, out of the same steps: every Step is a Lasting, and NewWait, NewIdle, NewLoop, LastingSteps, LastingOneOf and TopNode are the parts package plan builds on.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Self is the entity the branch is about. Self = Subject{/* contains filtered or unexported fields */} // Other is the other of the pair the moment met, each of them, or the subject of the // moment or the fact; a step of it fails while there is none. Other = Subject{/* contains filtered or unexported fields */} )
Functions ¶
Types ¶
type Branch ¶
type Branch[P any] struct { Name string // required at the top of a rule When cond.Cond // required: cond.Self.If(cond.Always) for every time Then Step // required }
Branch is when what is done, every clause saying of whom: at the moment P a plugin's pass catches, or for P any on nothing but its When. Given to a role it is a rule; inside another branch's Then it asks more. In a plan it is a loop that ends with its steps.
func (Branch[P]) Hosted ¶
Hosted is the branch built into the rule its moment's plugin runs, for the hosts (host.Hosted).
type Lasting ¶
type Lasting interface {
// contains filtered or unexported methods
}
Lasting is a step as a plan takes it: every Step, and what package plan makes of its own — steps that last over ticks, loops, groups of them.
func LastingOneOf ¶
LastingOneOf is OneOf of what a plan takes; for package plan.
func LastingSteps ¶
LastingSteps is Steps of what a plan takes; for package plan.
func NewIdle ¶
func NewIdle() Lasting
NewIdle is the entity doing nothing for ever; for package plan.
func NewLoop ¶
func NewLoop[P any](name string, when cond.Cond, then Lasting, until cond.Cond, timeout, cooldown time.Duration) Lasting
NewLoop is a loop of a plan on the fact P (any for none): then run from the start as when comes to hold, ending well once until holds, failing after timeout, not beginning again within cooldown of its last run; for package plan.
type Rule ¶
type Rule interface {
fmt.Stringer
// Hosted is the rule as its host runs it (host.Hosted).
Hosted() any
// ForRole is the rule narrowed to the players of role.
ForRole(role cond.Role) Rule
}
Rule is what a role's players do at a moment a plugin catches: a Branch of that moment, or a role whose rules come with it. The moment's type says which plugin hosts it.
type Step ¶
type Step interface {
// Lasting is the step as a plan takes it (plan.Part).
Lasting() Lasting
// contains filtered or unexported methods
}
Step is a part of a rule's Then: a step said of somebody (Self.Do, Other.Put, Around(n).Put), a group of them (Steps, OneOf) or a Branch. Every Step is a Lasting too: a plan takes it.
type Subject ¶
type Subject struct {
// contains filtered or unexported fields
}
Subject is whom a step is done by or to: Self, Other, Around(n) or Ahead(n). Its methods are the steps.
func Ahead ¶ added in v0.2.1
Ahead is each place on the cells one to steps ahead of the entity, the way it faces, in a rule of a moment that is host.Headed.
func Around ¶
Around is each place within rings of where the entity stands, in a rule of a moment that is host.Placed.
func (Subject) Do ¶
Do gives the subject the command cmd and does well at once; a host.Aimed command is told the Subject of the moment or the fact, and fails while there is none. A command carrying ceremony.From is sent to the other as a message, a plan's alone. A command that names nobody panics here.