For this project, you will work with the Tennis environment.
In this environment, two agents control rackets to bounce a ball over a net. If an agent hits the ball over the net, it receives a reward of +0.1. If an agent lets a ball hit the ground or hits the ball out of bounds, it receives a reward of -0.01. Thus, the goal of each agent is to keep the ball in play.
The observation space consists of 8 variables corresponding to the position and velocity of the ball and racket. Each agent receives its own, local observation. Two continuous actions are available, corresponding to movement toward (or away from) the net, and jumping.
The task is episodic, and in order to solve the environment, your agents must get an average score of +0.5 (over 100 consecutive episodes, after taking the maximum over both agents). Specifically,
- After each episode, we add up the rewards that each agent received (without discounting), to get a score for each agent. This yields 2 (potentially different) scores. We then take the maximum of these 2 scores.
- This yields a single score for each episode.
The environment is considered solved, when the average (over 100 episodes) of those scores is at least +0.5.
Follow the instructions in Tennis.ipynb
to get started with training your own agent!
- Download the Unity environment:
bash download_env.sh
- I made a few changes Python package dependencies, compared to Project I, Project II, in which
protobuf==3.20.3
to be compatible withwandb
. - Run
python3 -m pip install .
in the terminal - Before running the notebook, the environment in the
.env
file should be modified w.r.t to your ownwandb
project and username. - Re-run every cells in Tennis.ipynb
Below is my solution for the Tennis task, applying Multi-Agent Deep Deterministic Policy Gradient (MA-DDPG) [1].
There will be 2 agents playing tennis, competing against each other.
Both of them are trained using DDPG paradigm [2], involving the usage of 2 neural networks: actor who outputs action based on observations and a critic that rates the actions of actor.
The observation space and action space are the same for both actors, with each state vector has a shape of [1,24]
and an action vector of size [1,2]
.
- I use the MA-DDPG base pipeline from Anh-BK's work [3]. The original code used TensorboardX for visualization. As promised in the 2 last projects, this time, I tried integrate wandb into the training flow.
- The project is structured as follows:
- The agents folder is used to store the implementations of
DDPG
andMA-DDPG
- Each
DDPGAgent
comprises of 2 neural networks: an actor and a critic, with their hyper parameters could be easily configured during initialization. - The MA-DDPG trains a group of agents to perform a cooperative task in hich the number of agents in the group could be vary by modifying the attribute
num_agents
, which equals 2 for this task.
- I try another experiment but with the actors of both agents increasing their hidden layers to 3.
- The training took longer to converge (20' compared to the previous 15').
- The actor losses are smoother, but the average scores took more iterations to reach the task 0.5-point requirement. .
- After 1575 episodes, the last checkpoint is saved in
checkpoints/episode-1575.pt
More details about the metrics logged during training the 2 exps could be found here
I want to scale this work over the Football
challenge, in which the number of agents in the environment increase significantly. That will be my chance to experiment with more sophisticated algorithm such as TarMAC [4]