This folder contains the main source code of the GAMA-PettingZoo package.
src/
└── gama_pettingzoo/ # Main package
├── __init__.py # Package initialization
├── gama_parallel_env.py # PettingZoo parallel environment
├── gama_aec_env.py # AEC (Agent Environment Cycle) environment
└── utils/ # Utilities and helpers
├── __init__.py
├── connection.py # GAMA connection management
├── spaces.py # Action/observation space definitions
└── converters.py # GAMA/PettingZoo data converters
Implementation of PettingZoo parallel environment that enables:
- Simultaneous execution of all agents
- Communication with GAMA via sockets
- Multi-agent action and observation space management
- Simulation cycle synchronization
AEC (Agent Environment Cycle) environment for:
- Sequential agent execution
- Fine-grained execution order control
- Compatibility with algorithms requiring turn-based execution
Utility modules for:
connection.py: TCP/IP communication management with GAMAspaces.py: GAMA to PettingZoo space conversionconverters.py: Data transformation between formats
from gama_pettingzoo.gama_parallel_env import GamaParallelEnv
env = GamaParallelEnv(
gaml_experiment_path='model.gaml',
gaml_experiment_name='main',
gama_ip_address='localhost',
gama_port=1001
)from gama_pettingzoo.gama_aec_env import GamaAECEnv
env = GamaAECEnv(
gaml_experiment_path='model.gaml',
gaml_experiment_name='main',
gama_ip_address='localhost',
gama_port=1001
)- Initialization : Connect to GAMA and retrieve spaces
- Reset : Initialize simulation and agents
- Step : Execute actions and retrieve observations
- Close : Clean GAMA connection closure
Corresponding tests are located in the tests/ folder at the project root.
To contribute to development:
- Code structure : Follow PEP 8 and Python conventions
- Tests : Add tests for any new functionality
- Documentation : Documenter public APIs with docstrings
- Type hints : Use type annotations for better readability
pettingzoo>=1.22.0: Multi-agent frameworkgama_gymnasium>=0.1.0: GAMA integration for Gymnasiumnumpy>=1.21.0: Numerical computationstyping: Type annotations (Python < 3.9)