This is how to teach a bot to walk on two feet.
Bipedal Walker is an OpenAI Gym environment where an agent learns to control a bipedal 2D character to reach the end of an obstacle course. What makes this challenging is that the agent only receives limbs coordinates along with the Lidar information. The agent has to learn to balance, walk, run, jump on its own without any human intervention.
There are two versions:
-
Normal, with slightly uneven terrain.
-
Hardcore, with ladders, stumps, pitfalls.
To solve the normal version, you need to get 300 points in 1600 time steps. To solve the hardcore version, you need 300 points in 2000 time steps.
The code in this repo solves Bipedal Walker V3 in normal mode (hardcore=False
).
- Conda installed on your system
- Visual Studio Code
Follow the steps below to set up your environment and install the necessary dependencies.
First, create a new Conda environment with Python 3.11:
conda create -n gym-env python=3.11 -y
conda activate gym-env
conda install \
swig gymnasium-box2d \
stable-baselines3 tensorboard \
plotly scikit-learn optuna -y
Once the environment is set up and dependencies are installed, you can proceed to train the agent and evaluate its performance.
bipedal_train.py
: Train the agent with PPO default parameters.bipedal_eval.py
: Evaluate the agent using a previously saved model.optuna_ppo.py
: Auto-tune PPO using OPTUNA.optuna_ddpg.py
: Auto-tune DDPG using OPTUNA.bipedal_wandb_ppo.py
: Train / evaluate the agent with tuned hyper-parameters + W&B integration.bipedal_wandb_ddpg.py
: Train / evaluate the agent with tuned hyper-parameters + W&B integration.record_video.py
: Record a video of the trained agent.
tensorboard --logdir=./training/logs
This project is licensed under the MIT License.