NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning to Play Pong Video Game via Deep Reinforcement Learning

Ilya Makarov, Andrej Kashin, Alisa Korinevskaya

Introduction

Modern Deep Reinforcement Learning (DRL) has demonstrated remarkable success in classic arcade environments. However, applying these techniques to sophisticated game engines like Unreal Engine 4 (UE4) presents unique technical challenges, particularly in bridging the gap between high-performance C++ backends and Python-based machine learning libraries. This study explores the feasibility of training a pixel-based agent in a custom UE4 Pong environment, comparing the performance of Deep Q-Networks (DQN) against Model-Free Episodic Control (EC).

The Unreal Engine 4 Environment

To facilitate training, the researchers developed a physics-based implementation of Pong within Unreal Engine 4. The integration was achieved using the UnrealEnginePython plugin, which allows a TensorFlow-based controller to interact directly with the UE4 environment.

Screenshot of the custom Pong environment in Unreal Engine 4.

The agent receives raw game screenshots as input, which are binarized and downscaled to an 80x80 resolution. The action space is discrete, consisting of three commands: Move Up, Move Down, or Idle.

Methodology

The study investigates two primary RL approaches:

  1. Deep Q-Networks (DQN): A gradient-based method that learns a generalized strategy by mapping visual inputs to action-values.
  2. Model-Free Episodic Control (EC): A method inspired by episodic memory that stores successful state-action sequences in a table ($Q^{EC}$) and uses nearest-neighbor search for decision-making. To handle high-dimensional image data, the EC model employs random projections for dimensionality reduction.

Key Insights: The "Euclidean Trap"

A significant finding of this research was the failure of the Episodic Control agent when using Euclidean distance on binary images. In a binary pixel space, Euclidean distance measures the total sum of differing pixels rather than their spatial relationship. Consequently, the agent could not distinguish between a ball moving slightly and a ball disappearing and reappearing elsewhere, preventing it from understanding the ball's trajectory. In contrast, the DQN's gradient-based optimization allowed it to generalize effectively from raw pixels despite these high-dimensional challenges.

Results and Performance

The DQN agent demonstrated robust learning capabilities, eventually outperforming the built-in scripted AI. Training was conducted on a modern GPU and took approximately six hours.

Training curve showing the DQN agent's score over 35 million iterations.

As illustrated in the training curve, the model required approximately 10 million iterations to reach peak performance, eventually achieving a stable average score difference of +20. This indicates near-perfect play, as the game concludes when a player reaches 21 points.

Conclusion and Future Work

This research proves the viability of a real-time training pipeline between TensorFlow and Unreal Engine 4. While the DQN agent succeeded, the limitations of Episodic Control highlight the need for better state representations. Future work will focus on utilizing Variational Auto-Encoders (VAEs) to learn a latent space where distance correlates more accurately with game-state similarity. Additionally, the authors plan to scale these methods to complex 3D simulations, leveraging the full potential of the UE4 engine.

Summary updated

BibTeX
@inproceedings{makarov2017learning,
  author = {Ilya Makarov and Andrej Kashin and Alisa Korinevskaya},
  title = {{Learning to Play Pong Video Game via Deep Reinforcement Learning}},
  booktitle = {AIST (Supplement)},
  year = {2017},
}
Figure