Reinforcement Learning: Neural Policy Optimization in CartPole
In this project, I implemented the REINFORCE algorithm, a Monte Carlo policy gradient method in reinforcement learning, to solve the CartPole-v1 environment from OpenAI Gym. The CartPole task involves balancing an inverted pendulum by applying left or right forces to a cart, with the goal of maximizing the duration before failure. Using a neural network to model the stochastic policy, REINFORCE updates the policy parameters based on full episodes, computing gradients using the log-likelihood of actions weighted by discounted returns. My implementation included action sampling, reward discounting, and parameter updates, enabling the agent to learn a successful balancing strategy through gradient-based policy optimization.