--- tags: - reinforcement-learning - q-learning - gymnasium - cliffwalking library_name: gymnasium license: apache-2.0 --- # CliffWalking Q-Learning Agent This repository contains a Q-learning agent trained on the **CliffWalking-v0** environment from **Gymnasium**. The agent learns to navigate the cliff, avoiding falling into the cliff zone while reaching the goal with minimal penalties. The Q-learning algorithm is implemented with epsilon-greedy exploration and updates the Q-table based on state-action-reward transitions. ## Files: - `train.py`: The main script that trains the Q-learning agent. - `cliffWalking_qtable.npy`: The saved Q-table after training. - `replay.mp4`: A video of the agent's performance after training. ## Training Details: - **Environment**: `CliffWalking-v0` (Gymnasium) - **Episodes**: 30,000 - **Learning Rate (α)**: 0.2 - **Discount Factor (γ)**: 0.97 - **Epsilon (ε)**: 0.2 (exploration vs exploitation trade-off) The agent starts by exploring the environment randomly and gradually learns the optimal path to avoid falling off the cliff while reaching the goal. ## How to Run: ### 1. Install Dependencies: Make sure you have the required packages installed: ```bash pip install gymnasium numpy imageio[ffmpeg] ``` ### 2. Training the Agent: To train the agent, run the script train.py: ```bash python train.py ```