π Visit the Live Demo | π Explore Documentation
MountainCar is a classic reinforcement learning environment from OpenAI Gym designed to challenge agents to master the task of driving an underpowered car up a steep mountain. This repository includes:
- MountainCar.py: A script for rendering and evaluating a trained Q-learning agent.
- MountainCarAlgorithm.py: The Q-learning implementation for training the agent.
- Visualize_q_table.py: Tools for analyzing and visualizing the trained Q-table.
- ModelData/: A folder containing the pre-trained Q-table (
q_table.pkl
) and training metrics (training_metrics.pkl
).
"Conquer the MountainCar challenge and understand the power of Q-learning!"
- β¨ Features
- π οΈ Tech Stack
- πΈ Screenshots
- βοΈ Setup Instructions
- π― Target Audience
- π€ Contributing
- π License
- π Custom Q-Learning Algorithm: Train agents with hyperparameters like learning rate, discount factor, and epsilon decay.
- π Q-Table Visualization: Gain insights into the training process with histograms of Q-values.
- π» Modular Codebase: Separate scripts for training, evaluation, and visualization.
- ποΈ Enhanced Reward System: Custom rewards for better learning outcomes.
- π₯οΈ Rendering Script: Visualize the trained agent in action with real-time rendering.
- Reinforcement Learning: OpenAI Gym
- Visualization: Matplotlib, NumPy
- Code Management: Pickle for saving Q-tables and metrics
- MountainCar/: Folder containing:
MountainCar.py
: Script for rendering the trained agent and observing its performance.MountainCarAlgorithm.py
: Core Q-learning algorithm for training the agent.Visualize_q_table.py
: Scripts to visualize training metrics and analyze the Q-table.
- ModelData/: Folder containing:
q_table.pkl
: Pre-trained Q-table.training_metrics.pkl
: Saved training metrics for analysis.
Here are visualizations showcasing the training process, Q-table analysis, and the agent in action:
-
Total Rewards Per Episode
Visualizes the total rewards collected by the agent over episodes, showing trends and improvement over time.
-
Epsilon Decay Over Episodes
Highlights how the epsilon value decreases during training, balancing exploration and exploitation.
-
Distribution of Maximum Q-Values
Demonstrates the distribution of maximum Q-values across the state space, providing insights into the agent's decision-making quality.
-
MountainCar Agent in Action
Watch the trained agent perform in the MountainCar environment as it attempts to reach the goal.
- Clone the Repository
git clone https://github.com/alienx5499/MountainCar.git
- Navigate to the Project Directory
cd MountainCar
- Install Dependencies
pip install -r requirements.txt
- Run Training Script
python MountainCarAlgorithm.py
- Visualize Training Metrics
python Visualize_q_table.py
- Render the Trained Agent
python MountainCar.py
- Reinforcement Learning Enthusiasts: Dive deep into Q-learning and OpenAI Gym.
- AI Researchers: Analyze and build upon the classic MountainCar environment.
- Students and Educators: Use as a learning tool for understanding reinforcement learning.
- Developers: Expand the repository with new algorithms and features.
We β€οΈ open source! Contributions are welcome to make this project even better.
- Fork the repository.
- Create your feature branch.
git checkout -b feature/new-feature
- Commit your changes.
git commit -m "Add a new feature"
- Push to the branch and open a pull request.
Refer to our CONTRIBUTING.md for detailed contribution guidelines.
This project is licensed under the MIT License. See the LICENSE file for details.
We value your input! Share your thoughts through GitHub Issues.
π Visit the Live Demo | π Explore Documentation
π‘ Let's conquer the MountainCar challenge together!