This bachelor thesis investigates the challenges of stability and convergence in Multi-Agent Reinforcement Learning (MARL) within cooperative environments. The study evaluates three algorithmic extensions to Independent Q-Learning (IQL): Joint Action Learning with Agent Modelling (JAL-AM), variance-based Active Exploration (AE), and Q-learning with Behavior Managing (QBM). Where AE and QBM are novel contributions.
GO to the folder "tabular_marl". This folder contains implementations of tabular multi-agent reinforcement learning algorithms for various environments.
This codebase supports three main training paradigms:
- Self-Play: Agents of the same algorithm learn together
- Mixed-Play: Two different algorithms learn together
- Multiple Runs: Run the same configuration multiple times for robust evaluation
Use this script for Self-Play purposes, where agents of the same algorithm learn together.
Usage:
python run.pyConfiguration:
- Edit the
CONFIGdictionary inrun.pyto customize:- Algorithm (e.g., "IQL")
- Environment (e.g., "cf" for custom foraging, "f" for foraging, "m" for matrix game)
- Training parameters (episodes, episode length, learning rate, etc.)
Outputs:
- Saved to
output/{ALGORITHM}/{runname}/ - Includes evaluation returns CSV, visualizations, and videos (if enabled)
Use this script for Mixed-Play, where two different algorithms learn together.
Usage:
python run_mixed.pyConfiguration:
- Edit the
CONFIGdictionary inrun_mixed.pyto customize:algorithm_1andalgorithm_2: Choose from available algorithms (IQL, IQLAE, JalAM, JalAE, Random, pRandom)algorithm_1_kwargsandalgorithm_2_kwargs: Additional parameters for each algorithm- Environment and training parameters
Available Algorithms:
IQL: Independent Q-LearningIQLAE: IQL with uncertaintyJalAM: Joint Action Learning with opponent modelingJalAE: JAL with uncertaintyQBM: IQL with behaviour managingRandom: Random agentpRandom: Probabilistic random agent
Outputs:
- Saved to
output/MixedPlay/{runname}/ - Includes evaluation returns CSV, visualizations, and videos (if enabled)
Use this script to run the same configuration of algorithms multiple times for robust evaluation.
Usage:
python run_multiple.pyConfiguration:
- Edit the
CONFIGdictionary inrun_multiple.pyto customize:repetitions: Number of independent runs (e.g., 2, 30)algorithm_1andalgorithm_2: Algorithms to compareeval_spread: Evaluation strategy ("last10", "full", or "both")- Environment and training parameters
Features:
- Runs multiple independent training repetitions
- Aggregates results across repetitions
- Provides statistical summaries (mean ± std)
- Generates learning curves and repetition comparison plots
Outputs:
- Saved to
output/Multiple/{runname}/(oroutput/Final/{runname}/if 30 repetitions) - Includes:
eval_returns.csv(oreval_returns_full.csvandeval_returns_last10.csvifeval_spread="both"){runname}_repetition_returns.png: Comparison across repetitions{runname}_learning_curve.png: Learning curve visualization- Videos (if enabled)
tabular_marl/
├── agent/ # Agent implementations
│ ├── iql.py # Independent Q-Learning
│ ├── iql_unc.py # IQL with uncertainty
│ ├── jal.py # Joint Action Learning
│ ├── jal_unc.py # JAL with uncertainty
│ ├── random_agent.py # Random agent
│ ├── p_random.py # Probabilistic random agent
│ ├── iql_behave_managing.py # Q-learning with behavior management
│ └── mixed_play_wrapper.py # Wrapper for mixed-play scenarios
│
├── envs/ # Environment implementations
│ ├── custom_foraging_env.py # Custom foraging environment
│ ├── custom_foraging_oneFood.py # Custom foraging with one food
│ ├── matrix_game.py # Matrix game environment
│ ├── move_game.py # Move chair game
│ ├── move_chair_simple.py # Simple move chair game
│ └── move_game_coor.py # Move chair coordination game
│
├── utils/ # Utility functions
│ ├── visualizations.py # Plotting and visualization functions
│ ├── video.py # Video recording utilities
│ ├── eval.py # Evaluation functions
│ ├── post_stats.py # Post-processing statistics
│ └── post_visualizations.py # Post-processing visualizations
│
├── output/ # All outputs are saved here
│ ├── IQL/ # Self-play results for IQL
│ ├── MixedPlay/ # Mixed-play results
│ ├── Multiple/ # Multiple repetition results
│ └── Final/ # Final results (30 repetitions)
│
├── run.py # Self-Play training script
├── run_mixed.py # Mixed-Play training script
├── run_multiple.py # Multiple repetitions script
├── train.py # Core training functions
└── requirements.txt # Python dependencies
All outputs are saved in the output/ directory:
-
Self-Play results:
output/{ALGORITHM}/{runname}/- Example:
output/IQL/10000eps_100epL_16dec2025_IQL/
- Example:
-
Mixed-Play results:
output/MixedPlay/{runname}/- Example:
output/MixedPlay/300eps_50epL_15dec2025_IQLAE_vs_IQLAE/
- Example:
-
Multiple repetition results:
output/Multiple/{runname}/(for < 30 repetitions)output/Final/{runname}/(for 30 repetitions)
Each output directory typically contains:
eval_returns.csv: Evaluation performance dataeval_image.pngor similar: Visualization plotsvideo/: Directory with evaluation videos (if enabled)
The following environment types are supported:
"cf": Custom foraging environment"cf1f": Custom foraging with one food"f": Standard foraging environment (lbforaging)"m": Matrix game"mc": Move chair game"mcs": Move chair simple"mcc": Move chair coordination
-
Install dependencies:
pip install -r requirements.txt
-
For Self-Play:
- Edit
CONFIGinrun.py - Run:
python run.py
- Edit
-
For Mixed-Play:
- Edit
CONFIGinrun_mixed.py - Run:
python run_mixed.py
- Edit
-
For Multiple Repetitions:
- Edit
CONFIGinrun_multiple.py - Run:
python run_multiple.py
- Edit
- All scripts use configuration dictionaries (
CONFIG) that can be modified directly in the script files - Seeds can be set for reproducibility (set
"seed"in CONFIG) - Videos are automatically generated for foraging environments when
"visualise": True - Evaluation frequency and episodes can be adjusted in the CONFIG