Intelligence · function

entityTool

A tool addressing an entity, whose guard checks the generation and not only the index.

Explained in Agents and behaviour.

function entityTool<R>(world: World, id: string, description: string, execute: (entity: Entity, world: World) => R): ToolDefinition<
import { entityTool } from '@driftengine/ai';

Parameters

ParameterTypeDescription
worldWorld
idstring
descriptionstring
execute(entity: Entity, world: World) => R

In depth

The staleness case the buffer makes likely rather than rare: an entity is destroyed and its slot is reused, so an index that still resolves resolves to something else entirely. A guard checking only the index would let a plan made about one thing run against another, which is worse than the plan failing.