10

Reinforcement Learning with Genetic Algorithms

In this chapter, we will demonstrate how genetic algorithms can be applied to reinforcement learning – a fast-developing branch of machine learning that is capable of tackling complex tasks. We will do this by solving two benchmark environments from the Gymnasium (formerly OpenAI Gym) toolkit. We will start by providing an overview of reinforcement learning, followed by a brief introduction to Gymnasium, a toolkit that can be used to compare and develop reinforcement learning algorithms, as well as a description of its Python-based interface. Then, we will explore two Gymnasium environments, MountainCar and CartPole, and develop genetic algorithm-based programs to solve the challenges they present. ...

Get Hands-On Genetic Algorithms with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.