Hands-On Reinforcement Learning for Games
eBook - ePub

Hands-On Reinforcement Learning for Games

Implementing self-learning agents in games using artificial intelligence techniques

Micheal Lanham

  1. 432 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Hands-On Reinforcement Learning for Games

Implementing self-learning agents in games using artificial intelligence techniques

Micheal Lanham

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

À propos de ce livre

Explore reinforcement learning (RL) techniques to build cutting-edge games using Python libraries such as PyTorch, OpenAI Gym, and TensorFlow

Key Features

  • Get to grips with the different reinforcement and DRL algorithms for game development
  • Learn how to implement components such as artificial agents, map and level generation, and audio generation
  • Gain insights into cutting-edge RL research and understand how it is similar to artificial general research

Book Description

With the increased presence of AI in the gaming industry, developers are challenged to create highly responsive and adaptive games by integrating artificial intelligence into their projects. This book is your guide to learning how various reinforcement learning techniques and algorithms play an important role in game development with Python.

Starting with the basics, this book will help you build a strong foundation in reinforcement learning for game development. Each chapter will assist you in implementing different reinforcement learning techniques, such as Markov decision processes (MDPs), Q-learning, actor-critic methods, SARSA, and deterministic policy gradient algorithms, to build logical self-learning agents. Learning these techniques will enhance your game development skills and add a variety of features to improve your game agent's productivity. As you advance, you'll understand how deep reinforcement learning (DRL) techniques can be used to devise strategies to help agents learn from their actions and build engaging games.

By the end of this book, you'll be ready to apply reinforcement learning techniques to build a variety of projects and contribute to open source applications.

What you will learn

  • Understand how deep learning can be integrated into an RL agent
  • Explore basic to advanced algorithms commonly used in game development
  • Build agents that can learn and solve problems in all types of environments
  • Train a Deep Q-Network (DQN) agent to solve the CartPole balancing problem
  • Develop game AI agents by understanding the mechanism behind complex AI
  • Integrate all the concepts learned into new projects or gaming agents

Who this book is for

If you're a game developer looking to implement AI techniques to build next-generation games from scratch, this book is for you. Machine learning and deep learning practitioners, and RL researchers who want to understand how to use self-learning agents in the game domain will also find this book useful. Knowledge of game development and Python programming experience are required.

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Hands-On Reinforcement Learning for Games est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Hands-On Reinforcement Learning for Games par Micheal Lanham en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Ciencia de la computaciĂłn et Redes neuronales. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
2020
ISBN
9781839216770

Section 1: Exploring the Environment

Reinforcement Learning (RL) is a complex topic comprising of terminology and concepts that all seem to blend together. In this section, we uncover the terminology and basics of RL for the novice or more advanced user.
This section contains the following chapters:
  • Chapter 1, Understanding Rewards-Based Learning
  • Chapter 2, Monte Carlo Methods
  • Chapter 3, Dynamic Programming and the Bellman Equation
  • Chapter 4, Temporal Difference Learning
  • Chapter 5, Exploring SARSA

Understanding Rewards-Based Learning

The world is consumed with the machine learning revolution and, in particular, the search for a functional artificial general intelligence or AGI. Not to be confused with a conscious AI, AGI is a broader definition of machine intelligence that seeks to apply generalized methods of learning and knowledge to a broad range of tasks, much like the ability we have with our brains—or even small rodents have, for that matter. Rewards-based learning and, in particular, reinforcement learning (RL) are seen as the next steps to a more generalized intelligence.
"Short-term AGI is a serious possibility."
– OpenAI Co-founder and Chief Scientist, Ilya Sutskever
In this book, we start from the beginning of rewards-based learning and RL with its history to modern inception and its use in gaming and simulation. RL and, specifically, deep RL are gaining popularity in both research and use. In just a few years, the advances in RL have been dramatic, which have made it both impressive but, at the same time, difficult to keep up with and make sense of. With this book, we will unravel the abstract terminology that plagues this multi-branch and complicated topic in detail. By the end of this book, you should be able to consider yourself a confident practitioner of RL and deep RL.
For this first chapter, we will start with an overview of RL and look at the terminology, history, and basic concepts. In this chapter, the high-level topics we will cover are as follows:
  • Understanding rewards-based learning
  • Introducing the Markov decision process
  • Using value learning with multi-armed bandits
  • Exploring Q-learning with contextual bandits
We want to mention some important technical requirements before continuing in the next section.

Technical requirements

This book is a hands-on one, which means there are plenty of code examples to work through and discover on your own. The code for this book can be found in the following GitHub repository: https://github.com/PacktPublishing/Hands-On-Reinforcement-Learning-for-Games.
As such, be sure to have a working Python coding environment set up. Anaconda, which is a cross-platform wrapper framework for both Python and R, is the recommended platform to use for this book. We also recommend Visual Studio Code or Visual Studio Professional with the Python tools as good Integrated development editors, or IDEs.
Anaconda, recommended for this book, can be downloaded from https://www.anaconda.com/distribution/.
With that out of the way, we can move on to learning the basics of RL and, in the next section, look at why rewards-based learning works.

Understanding rewards-based learning

Machine learning is quickly becoming a broad and growing category, with many forms of learning systems addressed. We categorize learning based on the form of a problem and how we need to prepare it for a machine to process. In the case of supervised machine learning, data is first labeled before it is fed into the machine. Examples of this type of learning are simple image classification systems that are trained to recognize a cat or dog from a prelabeled set of cat and dog images. Supervised learning is the most popular and intuitive type of learning system. Other forms of learning that are becoming increasingly powerful are unsupervised and semi-supervised learning. Both of these methods eliminate the need for labels or, in the case of semi-supervised learning, require the labels to be defined more abstractly. The following diagram shows these learning methods and how they process data:
Variations of supervised learning
A couple of recent papers on arXiv.org (pronounced archive.org) suggest the use of semi-supervised learning to solve RL tasks. While the papers suggest no use of external rewards, they do talk about internal updates or feedback signals. This suggests a method of using internal reward RL, which, as we mentioned before, is a thing.
While this family of supervised learning methods has made impressive progress in just the last few years, they still lack the necessary planning and intelligence we expect from a truly intelligent machine. This is where RL picks up and differentiates itself. RL systems learn from interacting and making selections in the environment the agent resides in. The classic diagram of an RL system is shown here:


An RL system
In the preceding diagram, you can identify the main components of an RL system: the Agent and Environment, where the Agent represents the RL system, and the Environment could be representative of a game board, game screen, and/or possibly streaming data. Connecting these components are three primary signals, the State, Reward, and Action. The State signal is essentially a snapshot of the current state of Environment. The Reward signal may be externally provided by the Environment and provides feedback to the agent, either bad or good. Finally, the Action signal is the action the Agent selects at each time step in the environment. An action could be as simple as jump or a more complex set of controls operating servos. Either way, another key difference in RL is the ability for the agent to interact with, and change, the Environment.
Now, don't worry if this all seems a little muddled still—early researchers often encountered trouble differentiating between supervised learning and RL.
In the next section, we look at more RL terminology and explore the basic elements of an RL agent.

The elements of RL

Every RL agent is comprised of four main elements. These are policy, reward function, value function, and, optionally, model. Let's now explore what each of these terms means in more detail:
  • The policy: A policy represents the decision and planning process of the agent. The policy is what decides the actions the agent will take during a step.
  • The reward function: The reward function determines what amount of reward an agent receives after completing a series of actions or an action. Generally, a reward is given to an agent externally but, as we will see, there are internal reward systems as well.
  • The value function: A value function determines the value of a state over the long term. Determining the value of a state is fundamental to RL and our first exercise will be determining state values.
  • The model: A model represents the environment in full. In the case of a game...

Table des matiĂšres

  1. Title Page
  2. Copyright and Credits
  3. Dedication
  4. About Packt
  5. Contributors
  6. Preface
  7. Section 1: Exploring the Environment
  8. Understanding Rewards-Based Learning
  9. Dynamic Programming and the Bellman Equation
  10. Monte Carlo Methods
  11. Temporal Difference Learning
  12. Exploring SARSA
  13. Section 2: Exploiting the Knowledge
  14. Going Deep with DQN
  15. Going Deeper with DDQN
  16. Policy Gradient Methods
  17. Optimizing for Continuous Control
  18. All about Rainbow DQN
  19. Exploiting ML-Agents
  20. DRL Frameworks
  21. Section 3: Reward Yourself
  22. 3D Worlds
  23. From DRL to AGI
  24. Other Books You May Enjoy
Normes de citation pour Hands-On Reinforcement Learning for Games

APA 6 Citation

Lanham, M. (2020). Hands-On Reinforcement Learning for Games (1st ed.). Packt Publishing. Retrieved from https://www.perlego.com/book/1343370/handson-reinforcement-learning-for-games-implementing-selflearning-agents-in-games-using-artificial-intelligence-techniques-pdf (Original work published 2020)

Chicago Citation

Lanham, Micheal. (2020) 2020. Hands-On Reinforcement Learning for Games. 1st ed. Packt Publishing. https://www.perlego.com/book/1343370/handson-reinforcement-learning-for-games-implementing-selflearning-agents-in-games-using-artificial-intelligence-techniques-pdf.

Harvard Citation

Lanham, M. (2020) Hands-On Reinforcement Learning for Games. 1st edn. Packt Publishing. Available at: https://www.perlego.com/book/1343370/handson-reinforcement-learning-for-games-implementing-selflearning-agents-in-games-using-artificial-intelligence-techniques-pdf (Accessed: 14 October 2022).

MLA 7 Citation

Lanham, Micheal. Hands-On Reinforcement Learning for Games. 1st ed. Packt Publishing, 2020. Web. 14 Oct. 2022.