Objectives¶
Defines built-in objectives for determining win conditions in Grid Universe environments.
Each objective is a BaseObjective instance containing one or more functions
that accept the current State and the agent's entity ID, and return a
boolean indicating whether the win condition has been met.
Users can select from built-in objectives via OBJECTIVE_REGISTRY or define
custom objectives by subclassing BaseObjective.
OBJECTIVE_REGISTRY = {'collect': CollectObjective(), 'exit': ExitObjective(), 'collect_exit': CollectAndExitObjective(), 'unlock': UnlockObjective(), 'push': PushObjective()}
module-attribute
¶
Registry of built-in objectives by name.
Use these objective objects when creating State instances. Each objective
encapsulates one or more functions that together define whether the agent
has satisfied the win condition.
BaseObjective(name, description, functions)
dataclass
¶
Base class for objective functions.
__call__(state, agent_id)
¶
Evaluate the objective function.
CollectAndExitObjective(name='collect_exit', description='Collect all required items and reach an exit tile.', functions=(collect_objective_fn, exit_objective_fn))
dataclass
¶
CollectObjective(name='collect', description='Collect all required items.', functions=(collect_objective_fn,))
dataclass
¶
ExitObjective(name='exit', description='Reach an exit tile.', functions=(exit_objective_fn,))
dataclass
¶
PushObjective(name='push', description='Push all pushable entities to exit tiles.', functions=(all_pushable_at_exit_objective_fn,))
dataclass
¶
UnlockObjective(name='unlock', description='Unlock all locked entities.', functions=(all_unlocked_objective_fn,))
dataclass
¶
all_pushable_at_exit_objective_fn(state, agent_id)
¶
Every Pushable entity currently occupies an exit tile.
all_unlocked_objective_fn(state, agent_id)
¶
No remaining locked entities (doors, etc.).
collect_objective_fn(state, agent_id)
¶
All entities marked Requirable have been collected.
exit_objective_fn(state, agent_id)
¶
Agent stands on any entity possessing an Exit component.