Documentation
¶
Overview ¶
Package sense is the perception engine behind ai.PerceptionSystem and perception3d.System: sight cones, a round-robin line-of-sight budget, hearing, and per-stimulus memory, all on float64 3D vectors so the 2D and 3D front ends share one implementation.
Its numeric codes match the public types in package ai: attitudes are 0 hostile, 1 neutral and 2 friendly; senses are 1 sight and 2 hearing; event kinds are 1 gained, 2 updated, 3 lost and 4 forgotten.
Index ¶
Constants ¶
const ( Hostile uint8 = 0 Neutral uint8 = 1 Friendly uint8 = 2 )
Attitude codes.
const ( BySight uint8 = 1 ByHearing uint8 = 2 )
Sense codes.
const ( Gained uint8 = 1 Updated uint8 = 2 Lost uint8 = 3 Forgotten uint8 = 4 )
Event kind codes.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Agent ¶
type Agent struct {
State *State
Self uint64
HasSelf bool
Team uint8
Eye, Fwd Vec
Sight Sight
HearRange float64
HearDetect uint8
Forget time.Duration
}
Agent is one agent's input to a step.
type Engine ¶
Engine steps agents against targets and noises and owns the round-robin line-of-sight cursor. Fill Agents and call SetTargets before each Step.
func (*Engine) Register ¶
Register claims st for the system owner and gives it the next place in the agent order. It reports false when owner already has st and panics when another system does. A struct copy of a registered State is a separate agent: Register gives it its own copy of the memories, no events and no owner before claiming it, so the copy and the original never share backing arrays.
func (*Engine) SetTargets ¶
SetTargets sets the step's targets from n calls to at, sorted by ID with the first of each ID kept.
type Memory ¶
type Memory struct {
ID uint64
Team uint8
Attitude uint8
Sense uint8
Pos, Vel Vec
Age time.Duration
Visible bool
// contains filtered or unexported fields
}
Memory is one remembered stimulus.
type Sight ¶
type Sight struct {
// contains filtered or unexported fields
}
Sight is an agent's resolved vision.
type State ¶
State is one agent's memories, sorted by ID, and the events of its last step.
type Stats ¶
type Stats struct {
Candidates, Checks, Deferred int
}
Stats is the line-of-sight work of a step.