This project implements a Q-learning algorithm to train an agent to play the game of Blackjack optimally. The agent learns through interaction with the environment, improving its strategy over time by updating a Q-table based on the rewards received from different actions.
- Environment: Utilizes the
gymnasiumlibrary to simulate the Blackjack environment. - Q-Learning Algorithm: Implements a Q-learning algorithm with adjustable hyperparameters such as learning rate, discount factor, and exploration rate.
- Performance Tracking: Tracks the mean return over episodes to monitor the learning progress.
- Visualization: Includes a plot of the mean return over time to visualize the agent's learning process.
To run this project, you need to have Python installed along with the following packages:
gymnasiumnumpymatplotlib
You can install these packages using pip:
pip install gymnasium numpy matplotlib- Clone the repository.
- Open the
black_jack_rl.ipynbnotebook. - Run the cells to train the agent and visualize the results.
The learning process is visualized in the black_jack_rl_graph.png image, which shows the mean return over time as the agent learns to play Blackjack.
This project is licensed under the MIT License.
- The
gymnasiumlibrary for providing the Blackjack environment. - The Q-learning algorithm for reinforcement learning.
