Documentation
¶
Overview ¶
Package steps runs the steps of rules and plans: the nodes packages cond, act and plan build, laid out as a tree, run at a moment within a pass (Instant) or every step on the entities' minds (Plans). Those packages are its face.
Index ¶
- Constants
- Variables
- func PlanID(name string) uint64
- type Aimed
- type Guard
- func GuardAll(gs ...Guard) Guard
- func GuardAlways(w Whose) Guard
- func GuardAny(gs ...Guard) Guard
- func GuardCame[F any](k uint8, w Whose) Guard
- func GuardChance(p float64, w Whose) Guard
- func GuardNot(g Guard) Guard
- func GuardPlaying(bit uint8, w Whose) Guard
- func GuardUnder(e effect.Effect, w Whose) Guard
- func GuardWord[P any](name string, holds func(P) bool, w Whose) Guard
- type Instant
- type LowerAs
- type Lowered
- type Lowering
- type Pass
- type Plans
- type Status
- type Step
- func NewApply(e effect.Effect) Step
- func NewApplyFor(e effect.Effect, d time.Duration) Step
- func NewBranch[P any](name string, guard Guard, node Step, until Guard) Step
- func NewCooldown(d time.Duration, node Step) Step
- func NewDispel(e effect.Effect) Step
- func NewFirst(name string, nodes ...Step) Step
- func NewForOther(step Step) Step
- func NewIdle() Step
- func NewKeep(e effect.Effect) Step
- func NewOrder[C command.Command](cmd C) Step
- func NewPlaces(at host.Places, step Step) Step
- func NewSame(step Step) Step
- func NewThen(name string, nodes ...Step) Step
- func NewTimeout(d time.Duration, node Step) Step
- func NewWait(d time.Duration) Step
- type Whose
Constants ¶
const MaxCame = 8
MaxCame is how many facts one Until may wait for: a bit each in its slot.
Variables ¶
var ( // OfMe is the entity the rule or the plan is about. OfMe = Whose{/* contains filtered or unexported fields */} // OfSubject is the other of the pair the moment met, else the subject of the moment or // the fact; nobody while there is none. OfSubject = Whose{/* contains filtered or unexported fields */} // OfTarget is whom the steps act on now: the place the rule turned to. OfTarget = Whose{/* contains filtered or unexported fields */} )
Functions ¶
Types ¶
type Aimed ¶
Aimed is a command told the subject of the fact or moment it stands under as it is issued.
type Guard ¶
type Guard interface {
// contains filtered or unexported methods
}
Guard is a condition a branch asks of somebody's state besides its fact or moment.
func GuardCame ¶
GuardCame holds once the fact F has come to the entity afresh since the loop began: one carried from before does not count. k is its bit in the Until's slot.
func GuardChance ¶
GuardChance holds with the probability p, drawn afresh every step from the world's seed, the time and w, so a load and a replay draw alike.
func GuardPlaying ¶
GuardPlaying holds while w plays the role of bit.
func GuardUnder ¶
GuardUnder holds while w is under e.
type Instant ¶
type Instant struct {
// contains filtered or unexported fields
}
Instant is a rule laid out for running at a moment, every step of it done within the pass.
func NewInstant ¶
NewInstant lays root out as the rule named name, run on the moment payload points to. It panics on a step that lasts over ticks or one the moment cannot run.
type LowerAs ¶
type LowerAs uint8
LowerAs is where a condition stands: at the top of a rule, where the roles it names narrow the host; inside a branch or a plan, where they are guards; or as a loop's Until, where a fact that comes is allowed.
type Lowering ¶
type Lowering struct {
Guard Guard // nil for always
SelfRoles []uint8
OtherRole int // -1 for none
At host.Places // the places the rule turns to, with Places over 0
Places int
Words []reflect.Type
Came int
}
Lowering is a condition as a branch takes it: its guard, the roles it asks at the top of a rule (bits of the roles' family), the places it turns to, the moments its words are of and how many facts it waits for (MaxCame at most).
type Pass ¶
type Pass struct {
Commands *command.Carrier
Effects effect.Runtime
Dt time.Duration
Time time.Duration // game time at the step's end
Seed uint64
Places func(moment any, p host.Places, each func(uid.UID64))
Roles func(id uid.UID64) uint64 // a bit a role
}
Pass is what a rule is told of the pass it fires in.
type Plans ¶
type Plans struct {
// contains filtered or unexported fields
}
Plans runs the plans of every entity with a Mind, once every step of the simulation, over the blocks of entities a store's binding hands it.
func NewPlans ¶
func NewPlans(now func() time.Duration, seed uint64, fx effect.Runtime, commands *command.Carrier) *Plans
NewPlans is the plans on the clock now, drawing Chance from seed, casting fx and giving their commands to commands.
func (*Plans) Bind ¶ added in v0.2.0
Bind lays every plan out and binds the facts their steps read and write to the store's columns. Call it once, as the binding sets up; a plan defined after panics.
func (*Plans) Define ¶
Define lays root out as the plan named name and returns its id, what a Mind carries. A name defined twice, or after the plans are bound, panics.
func (*Plans) Facts ¶ added in v0.2.0
Facts are the types of the facts the plans read and write, for the store to keep.
type Step ¶
type Step interface {
// contains filtered or unexported methods
}
Step is a part of a rule or a plan, made by package rule.
func NewApplyFor ¶
NewApplyFor puts e on the entity for d.
func NewBranch ¶
NewBranch is a branch named name running node while guard holds, of the moment or the fact P. In a plan a branch of a fact runs once as the fact comes to hold, node to its end; one of any runs while its guard holds. With until, a plan's, the branch goes on after node is done and ends well once until holds, node halted.
func NewForOther ¶
NewForOther runs step on each of the others the moment met, or on its subject, in place of the entity.
func NewOrder ¶
NewOrder gives the entity the command cmd, or sends it as a message where cmd carries a From.
func NewPlaces ¶ added in v0.2.1
NewPlaces runs step on each of the places at the host tells for the moment, in place of the entity.