Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Hands-On Deep Learning for Games

You're reading from   Hands-On Deep Learning for Games Leverage the power of neural networks and reinforcement learning to build intelligent games

Arrow left icon
Product type Paperback
Published in Mar 2019
Publisher Packt
ISBN-13 9781788994071
Length 392 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Micheal Lanham Micheal Lanham
Author Profile Icon Micheal Lanham
Micheal Lanham
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Section 1: The Basics
2. Deep Learning for Games FREE CHAPTER 3. Convolutional and Recurrent Networks 4. GAN for Games 5. Building a Deep Learning Gaming Chatbot 6. Section 2: Deep Reinforcement Learning
7. Introducing DRL 8. Unity ML-Agents 9. Agent and the Environment 10. Understanding PPO 11. Rewards and Reinforcement Learning 12. Imitation and Transfer Learning 13. Building Multi-Agent Environments 14. Section 3: Building Games
15. Debugging/Testing a Game with DRL 16. Obstacle Tower Challenge and Beyond 17. Other Books You May Enjoy

Playing Rock, Paper, Scissors with LSTMs

Remembering sequences of data have huge applications in many areas, not the least of which includes gaming. Of course, producing a simple, clean example is another matter. Fortunately, examples abound on the internet and Chapter_2_5.py shows an example of using an LSTM to play Rock, Paper, Scissors.

Open up that sample file and follow these steps:

This example was pulled from https://github.com/hjpulkki/RPS, but the code needed to be tweaked in several places to get it to work for us.
  1. Let's start as we normally do with the imports. For this sample, be sure to have Keras installed as we did for the last set of exercises:
import numpy as np
from keras.utils import np_utils
from keras.models import Sequential
from keras.layers import Dense, LSTM
  1. Then, we set some constants as shown:
EPOCH_NP = 100
INPUT_SHAPE = (1, -1, 1)
OUTPUT_SHAPE...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image