Skip to main content

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.

Foundation is an open-source Python framework for building flexible, modular, and composable environments that model socio-economic behaviors and dynamics in a society with both agents and governments. It is the simulation engine underlying the AI Economist research project from Salesforce Research. Foundation exposes a Gym-compatible API—reset and step—so any multi-agent RL library can drive the simulation without modification.

The AI Economist research

Foundation was created to support research into AI-driven economic policy design. The framework has been used in three published papers:

Architecture overview

The simulation lives in ai_economist/foundation/ and is organized into five cooperating layers:
LayerDescription
ScenariosCompose Components to define the full world dynamics, compute rewards, and expose states for visualization. A Scenario is the top-level environment object you interact with.
ComponentsModular building blocks that add specific dynamics and action subspaces to a Scenario (e.g., Build, Gather, ContinuousDoubleAuction, PeriodicBracketTax).
AgentsRepresent economic actors. Mobile agents act as workers; the planner agent acts as a social planner or government.
EntitiesEndogenous variables (e.g., Labor), landmarks (e.g., Water, House), and collectible resources (e.g., Wood, Stone) that populate the world.
Base classesBaseEnvironment and BaseComponent define the extension contracts that custom Scenarios and Components must implement.
All classes are accessed through registries:
from ai_economist import foundation

foundation.scenarios   # Scenario class registry
foundation.components  # Component class registry
foundation.agents      # Agent class registry
foundation.resources   # Resource class registry
foundation.landmarks   # Landmark class registry
foundation.endogenous  # Endogenous variable registry

Gym-style API

Every Scenario instance exposes the standard two-method loop:
obs                        = env.reset()
obs, rew, done, info  = env.step(actions)
obs, rew, and done are dictionaries keyed by agent index (and "p" for the planner). This makes Foundation easy to integrate with RLlib, WarpDrive, or any other multi-agent training framework.

Included scenarios

Four scenarios ship with the package:
Scenario nameDescription
uniform/simple_wood_and_stone2D grid world with Wood and Stone resources; agents gather, trade, and build houses. Layout generated procedurally.
layout_from_file/simple_wood_and_stoneSame dynamics as above, but the world layout is loaded from a .txt map file.
multi_zone/simple_wood_and_stoneMulti-zone variant of the Wood and Stone world.
quadrant/simple_wood_and_stoneQuadrant layout variant.
split_layout/simple_wood_and_stoneSplit-layout variant.
one-step-economyMinimal one-step economy for rapid prototyping.
CovidAndEconomySimulationEpidemiological + economic simulation fitted to real COVID-19 data.

Installation

Install Foundation via pip or from source, and verify your setup.

Quickstart

Create your first environment, run a reset/step loop, and inspect observations.

GitHub

Browse the source code, file issues, and read the contribution guide.

Slack community

Join the AI Economist Slack to discuss research and get help.

License and ethics

Foundation is released under the BSD-3-Clause License. The authors have published Simulation Cards that cover the intended use and ethical review of the framework and its COVID-19 extension.

Build docs developers (and LLMs) love