Authoritative owner and deterministic scheduler for NPC AI agents. 更多...
#include <NpcAi.h>
Public 成员函数 | |
| NpcAiWorld (NpcAiWorldConfig config={}) | |
| Npc ai world. | |
| NpcAiWorld (const NpcAiWorld &)=delete | |
| NpcAiWorld & | operator= (const NpcAiWorld &)=delete |
| Result< void > | registerBehavior (BehaviorDefinition definition) |
| Validates and atomically publishes a behavior definition. | |
| Result< void > | registerTaskService (std::string type, std::unique_ptr< ITaskService > service) |
| Transfers ownership of a task provider into this world. | |
| Result< AgentHandle > | createAgent (std::string_view behaviorId) |
| Creates an agent bound to an existing behavior definition. | |
| Result< void > | destroyAgent (AgentHandle handle) |
| Stops active tasks and invalidates the agent handle. | |
| Result< void > | setBlackboard (AgentHandle handle, std::string key, BlackboardValue value) |
| Writes one authoritative blackboard value. | |
| Result< void > | signal (AgentHandle handle, std::string signalName) |
| Queues a named wake-up signal for evaluation on the next tick. | |
| Result< void > | remember (AgentHandle handle, PerceptionMemory memory) |
| Upserts one bounded memory and queues a sense-specific wake-up signal. | |
| Result< void > | forget (AgentHandle handle, std::string_view subject, std::string_view sense) |
| Explicitly forgets one subject/sense pair. | |
| Result< TickReport > | tick (const TickContext &context) |
| Advances agents in stable handle order within the explicit budget. | |
| Result< AgentSnapshot > | snapshot (AgentHandle handle) const |
| Returns an owning diagnostic snapshot, or StaleHandle. | |
| Result< AgentArchive > | archive (AgentHandle handle) const |
| Captures a versioned owning archive without invoking task providers. | |
| Result< AgentHandle > | restoreAgent (const AgentArchive &archive) |
| Validates a complete candidate and atomically publishes a restored agent. | |
| bool | isStale (AgentHandle handle) const noexcept |
| Reports whether a process-local agent handle no longer resolves. | |
| Result< std::vector< TraceEvent > > | trace (AgentHandle handle, std::uint64_t fromTick=0) const |
| Returns owning trace records for one agent at or after a tick. | |
静态 Public 成员函数 | |
| static Result< void > | validate (const BehaviorDefinition &definition) |
| Validates definition shape without publishing it. | |
详细描述
Authoritative owner and deterministic scheduler for NPC AI agents.
- 备注
- Definitions are validated and copied on registration. Agent handles are process-local and become stale after destruction. The world owns task services and must be used only on its simulation thread.
构造及析构函数说明
◆ NpcAiWorld() [1/2]
|
explicit |
◆ NpcAiWorld() [2/2]
|
delete |
成员函数说明
◆ archive()
| Result< AgentArchive > eve::npc_ai::NpcAiWorld::archive | ( | AgentHandle | handle | ) | const |
Captures a versioned owning archive without invoking task providers.
引用了 eve::npc_ai::AgentArchive::activeState, eve::npc_ai::AgentArchive::behaviorId, eve::npc_ai::AgentArchive::blackboard, eve::Result< T >::failure(), handle, eve::npc_ai::AgentArchive::lastTick, eve::npc_ai::AgentArchive::pendingSignals, eve::npc_ai::AgentArchive::perception, state, eve::Result< T >::success() , 以及 eve::npc_ai::AgentArchive::tasks.
◆ createAgent()
| Result< AgentHandle > eve::npc_ai::NpcAiWorld::createAgent | ( | std::string_view | behaviorId | ) |
Creates an agent bound to an existing behavior definition.
引用了 eve::npc_ai::AgentCreated, eve::Diagnostic::error(), eve::Result< T >::failure(), generation, handle, index, key, eve::NotFound, eve::PreconditionViolation, state , 以及 eve::Result< T >::success().
◆ destroyAgent()
| Result< void > eve::npc_ai::NpcAiWorld::destroyAgent | ( | AgentHandle | handle | ) |
Stops active tasks and invalidates the agent handle.
引用了 eve::npc_ai::AgentDestroyed, eve::Applied, eve::Result< T >::failure(), handle, eve::RuntimeHandle< AgentHandleTag >::nextGeneration(), path, state, eve::Status::success() , 以及 eve::Result< T >::success().
◆ forget()
| Result< void > eve::npc_ai::NpcAiWorld::forget | ( | AgentHandle | handle, |
| std::string_view | subject, | ||
| std::string_view | sense | ||
| ) |
Explicitly forgets one subject/sense pair.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), found, handle, eve::InvalidArgument, eve::NotFound, subject, eve::Status::success() , 以及 eve::Result< T >::success().
◆ isStale()
|
noexcept |
◆ operator=()
|
delete |
◆ registerBehavior()
| Result< void > eve::npc_ai::NpcAiWorld::registerBehavior | ( | BehaviorDefinition | definition | ) |
Validates and atomically publishes a behavior definition.
引用了 eve::AlreadyExists, eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::Status::success(), eve::Result< T >::success() , 以及 validate().
◆ registerTaskService()
| Result< void > eve::npc_ai::NpcAiWorld::registerTaskService | ( | std::string | type, |
| std::unique_ptr< ITaskService > | service | ||
| ) |
Transfers ownership of a task provider into this world.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, service, eve::Status::success(), eve::Result< T >::success() , 以及 type.
◆ remember()
| Result< void > eve::npc_ai::NpcAiWorld::remember | ( | AgentHandle | handle, |
| PerceptionMemory | memory | ||
| ) |
Upserts one bounded memory and queues a sense-specific wake-up signal.
引用了 a, b, eve::Diagnostic::error(), eve::Result< T >::failure(), found, handle, eve::InvalidArgument, eve::npc_ai::NpcAiWorldConfig::maxMemoriesPerAgent, memory, eve::npc_ai::PerceptionForgotten , 以及 eve::Unsupported.
◆ restoreAgent()
| Result< AgentHandle > eve::npc_ai::NpcAiWorld::restoreAgent | ( | const AgentArchive & | archive | ) |
Validates a complete candidate and atomically publishes a restored agent.
引用了 a, eve::npc_ai::AgentArchive::activeState, b, eve::npc_ai::AgentArchive::behaviorId, eve::npc_ai::AgentArchive::blackboard, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, key, eve::npc_ai::AgentArchive::lastTick, memory, eve::NotFound, path, eve::npc_ai::AgentArchive::pendingSignals, eve::npc_ai::AgentArchive::perception, eve::PreconditionViolation, eve::npc_ai::AgentArchive::schemaId, eve::npc_ai::AgentArchive::schemaVersion, state, eve::npc_ai::AgentArchive::tasks, eve::Unsupported , 以及 value.
◆ setBlackboard()
| Result< void > eve::npc_ai::NpcAiWorld::setBlackboard | ( | AgentHandle | handle, |
| std::string | key, | ||
| BlackboardValue | value | ||
| ) |
Writes one authoritative blackboard value.
引用了 eve::Applied, eve::npc_ai::BlackboardChanged, eve::Diagnostic::error(), eve::Result< T >::failure(), handle, eve::InvalidArgument, key, eve::NotFound, eve::Status::success(), eve::Result< T >::success() , 以及 value.
◆ signal()
| Result< void > eve::npc_ai::NpcAiWorld::signal | ( | AgentHandle | handle, |
| std::string | signalName | ||
| ) |
Queues a named wake-up signal for evaluation on the next tick.
引用了 eve::Applied, eve::Diagnostic::error(), eve::Result< T >::failure(), handle, eve::InvalidArgument, eve::npc_ai::SignalQueued, eve::Status::success() , 以及 eve::Result< T >::success().
◆ snapshot()
| Result< AgentSnapshot > eve::npc_ai::NpcAiWorld::snapshot | ( | AgentHandle | handle | ) | const |
Returns an owning diagnostic snapshot, or StaleHandle.
引用了 eve::Result< T >::failure(), handle, path, state , 以及 eve::Result< T >::success().
◆ tick()
| Result< TickReport > eve::npc_ai::NpcAiWorld::tick | ( | const TickContext & | context | ) |
Advances agents in stable handle order within the explicit budget.
引用了 active, eve::npc_ai::TickReport::agentsDeferred, eve::npc_ai::TickReport::agentsUpdated, context, eve::Diagnostic::error(), eve::Result< T >::failure(), handle, index, eve::InvalidArgument, eve::InvariantViolation, memory, eve::NotFound, path, eve::npc_ai::Transition::priority, service, eve::npc_ai::Transition::signal, eve::npc_ai::TaskContext::simulationTick, started, state, eve::Result< T >::success(), target, eve::npc_ai::Transition::targetState, eve::npc_ai::TickReport::tasksTicked, eve::npc_ai::TickReport::transitionBudgetsExhausted , 以及 eve::npc_ai::TickReport::transitionsApplied.
◆ trace()
| Result< std::vector< TraceEvent > > eve::npc_ai::NpcAiWorld::trace | ( | AgentHandle | handle, |
| std::uint64_t | fromTick = 0 |
||
| ) | const |
◆ validate()
|
static |
Validates definition shape without publishing it.
引用了 current, eve::Diagnostic::error(), eve::Result< T >::failure(), ids, eve::InvalidArgument, key, eve::NotFound, origin, s, state, eve::Result< T >::success() , 以及 eve::Unsupported.
被这些函数引用 registerBehavior().
该类的文档由以下文件生成: