载入中...
搜索中...
未找到
eve::npc_ai::NpcAiWorld类 参考

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.

在文件 NpcAi.h 第 216 行定义.

构造及析构函数说明

◆ NpcAiWorld() [1/2]

eve::npc_ai::NpcAiWorld::NpcAiWorld ( NpcAiWorldConfig  config = {})
explicit

Npc ai world.

在文件 NpcAi.cpp 第 46 行定义.

◆ NpcAiWorld() [2/2]

eve::npc_ai::NpcAiWorld::NpcAiWorld ( const NpcAiWorld &  )
delete

成员函数说明

◆ archive()

◆ createAgent()

Result< AgentHandle > eve::npc_ai::NpcAiWorld::createAgent ( std::string_view  behaviorId)

Creates an agent bound to an existing behavior definition.

在文件 NpcAi.cpp 第 142 行定义.

引用了 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)

◆ forget()

Result< void > eve::npc_ai::NpcAiWorld::forget ( AgentHandle  handle,
std::string_view  subject,
std::string_view  sense 
)

◆ isStale()

bool eve::npc_ai::NpcAiWorld::isStale ( AgentHandle  handle) const
noexcept

Reports whether a process-local agent handle no longer resolves.

在文件 NpcAi.cpp 第 645 行定义.

引用了 handle.

◆ operator=()

NpcAiWorld & eve::npc_ai::NpcAiWorld::operator= ( const NpcAiWorld &  )
delete

◆ registerBehavior()

Result< void > eve::npc_ai::NpcAiWorld::registerBehavior ( BehaviorDefinition  definition)

Validates and atomically publishes a behavior definition.

在文件 NpcAi.cpp 第 122 行定义.

引用了 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.

在文件 NpcAi.cpp 第 134 行定义.

引用了 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.

在文件 NpcAi.cpp 第 248 行定义.

引用了 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()

◆ setBlackboard()

Result< void > eve::npc_ai::NpcAiWorld::setBlackboard ( AgentHandle  handle,
std::string  key,
BlackboardValue  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.

在文件 NpcAi.cpp 第 236 行定义.

引用了 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.

在文件 NpcAi.cpp 第 521 行定义.

引用了 eve::Result< T >::failure(), handle, path, state , 以及 eve::Result< T >::success().

◆ tick()

◆ trace()

Result< std::vector< TraceEvent > > eve::npc_ai::NpcAiWorld::trace ( AgentHandle  handle,
std::uint64_t  fromTick = 0 
) const

Returns owning trace records for one agent at or after a tick.

在文件 NpcAi.cpp 第 651 行定义.

引用了 handle.

◆ validate()

Result< void > eve::npc_ai::NpcAiWorld::validate ( const BehaviorDefinition &  definition)
static

Validates definition shape without publishing it.

在文件 NpcAi.cpp 第 48 行定义.

引用了 current, eve::Diagnostic::error(), eve::Result< T >::failure(), ids, eve::InvalidArgument, key, eve::NotFound, origin, s, state, eve::Result< T >::success() , 以及 eve::Unsupported.

被这些函数引用 registerBehavior().


该类的文档由以下文件生成: