API Reference¶
Auto-generated from source code docstrings.
- Core —
Engine,RunResults,Scenario,Action,Observation,RoundResult - Brains —
BrainABC, RL brains, rule-based strategies - Metrics — cooperation rate, Nash distance, social welfare, entropy, Gini, regret, reciprocity, adaptation speed
- IO — config loading, Pydantic schemas, Parquet reader/writer
Top-level API¶
policy_arena
¶
PolicyArena — cross-paradigm agent simulation engine.
Run game-theoretic simulations with rule-based, reinforcement learning, and LLM-powered agents.
Quick start::
import policy_arena as pa
# Run from a YAML config
results = pa.run("scenarios/pd_rl_vs_rulebased.yaml")
# Access results
print(results.model_metrics.tail())
print(results.agent_metrics.tail())
run(config, *, seed=None, rounds=None)
¶
Run a simulation and return results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
str | Path | ScenarioConfig
|
Path to a YAML config file, or a |
required |
seed
|
int | None
|
Override the random seed from the config. |
None
|
rounds
|
int | None
|
Override the number of rounds from the config. |
None
|
Returns:
| Type | Description |
|---|---|
RunResults
|
Contains |
Source code in src/policy_arena/__init__.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
list_games()
¶
Return sorted list of available game IDs.
Source code in src/policy_arena/__init__.py
94 95 96 | |
list_scenarios()
¶
Return sorted list of built-in scenario names.
Source code in src/policy_arena/__init__.py
57 58 59 60 | |
get_scenario_path(name)
¶
Return the path to a built-in scenario YAML file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Scenario name (without .yaml extension).
Use |
required |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no built-in scenario matches the name. |
Source code in src/policy_arena/__init__.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
load_config(path)
¶
Load and validate a YAML scenario config file.
Source code in src/policy_arena/__init__.py
87 88 89 90 91 | |
get_registry()
¶
Return the global game registry, discovering games on first call.
Source code in src/policy_arena/registration.py
83 84 85 86 87 88 89 90 | |
configure_logging(level='INFO')
¶
Configure PolicyArena logging with a console handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
str | int
|
Logging level name (e.g. |
'INFO'
|
Source code in src/policy_arena/_logging.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |