Foundation uses a lightweight registry system to organize the building-block classes (Components, Scenarios, Agents, Resources, Landmarks, and Endogenous entities) that make up an environment. Registries provide a uniform API for looking up classes by name and ensure every registered entry inherits from the correct base class.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/salesforce/ai-economist/llms.txt
Use this file to discover all available pages before exploring further.
How registries work
Each registry is an instance ofRegistry(base_class). When you decorate a class with @registry.add, the class is stored internally and keyed by its name attribute (case-insensitive). You can then retrieve it with registry.get("ClassName").
Registry API
Constructor
The base class that all entries must subclass. Pass
None to skip the subclass check.add
cls in the registry. Returns cls so it can be used as a decorator.
The class to register. Must be a subclass of
base_class (if set). The class’s name attribute must not contain a dot ("."). Lookup is case-insensitive.get
name matches cls_name (case-insensitive).
Name of the class to retrieve.
KeyError if no class with that name is registered.
has
True if a class named cls_name (case-insensitive) is in the registry.
Name to check.
entries
The six registries
The top-levelfoundation package exposes six registries as module attributes:
foundation.scenarios
Registry of BaseEnvironment scenario subclasses. Used to instantiate environments by name via foundation.make_env_instance.
Built-in entries:
| Name | Description |
|---|---|
CovidAndEconomySimulation | Joint COVID-19 health and economic simulation. |
one-step-economy | Minimal single-timestep economy scenario. |
uniform/simple_wood_and_stone | 2D gather-and-build economy with uniform resource layout. |
multi_zone/simple_wood_and_stone | 2D gather-and-build economy with multi-zone resource layout. |
quadrant/simple_wood_and_stone | 2D gather-and-build economy with quadrant resource layout. |
layout_from_file/simple_wood_and_stone | Wood-and-stone scenario loaded from a layout file. |
split_layout/simple_wood_and_stone | Wood-and-stone scenario with a split layout loaded from file. |
foundation.components
Registry of BaseComponent subclasses. The environment looks up and instantiates components from this registry during construction.
Built-in entries:
| Name | Description |
|---|---|
Build | Allows mobile agents to build houses using collected resources. |
ContinuousDoubleAuction | Continuous double-auction market for trading resources among agents. |
ControlUSStateOpenCloseStatus | COVID-19 component for controlling state open/close policy. |
FederalGovernmentSubsidy | COVID-19 component for distributing federal subsidies. |
Gather | Allows mobile agents to move around the world and collect resources. |
PeriodicBracketTax | Planner-controlled periodic bracket tax with redistribution. |
SimpleLabor | Simple labor-commodity exchange component. |
VaccinationCampaign | COVID-19 component for running vaccination campaigns. |
WealthRedistribution | Equal redistribution of total coin among all mobile agents. |
foundation.agents
Registry of BaseAgent subclasses.
Built-in entries:
| Name | Description |
|---|---|
BasicMobileAgent | Mobile agent that moves in the 2D world. Indexed by integer. |
BasicPlanner | Social planner agent. No location. Always indexed as "p". |
foundation.resources
Registry of Resource entity subclasses. Resources can be held in agent inventories and (if collectible=True) exist in the world map.
Built-in entries:
| Name | Collectible | Description |
|---|---|---|
Coin | No | Currency used across all environments. |
Stone | Yes | Collectible stone resource that agents can gather. |
Wood | Yes | Collectible wood resource that agents can gather. |
foundation.landmarks
Registry of Landmark entity subclasses. Landmarks exist exclusively in the world grid and are never held in agent inventories.
Built-in entries:
| Name | Ownable | Solid | Description |
|---|---|---|---|
House | Yes | Yes | Buildable structure. Only its owner can occupy the cell. |
StoneSourceBlock | No | No | Source tile where Stone is generated. |
Water | No | Yes | Impassable water tile. |
WoodSourceBlock | No | No | Source tile where Wood is generated. |
StoneSourceBlock and WoodSourceBlock are auto-generated at import time from each collectible resource in resource_registry.foundation.endogenous
Registry of Endogenous entity subclasses. Endogenous entities represent internal agent state quantities (e.g. effort) that are not physically exchangeable.
Built-in entries:
| Name | Description |
|---|---|
Labor | Accumulated labor effort. Included in all environments by default. |
Registering a custom class
To register a custom component, agent, resource, landmark, or endogenous entity:Subclass the base class
Create a class that inherits from the appropriate base (
BaseComponent, BaseAgent, Resource, Landmark, or Endogenous) and set its name attribute to a unique string with no dots.