Comprehensible Context-driven Text Game Playing

Xusen Yin, Jonathan May

Abstract

Text-based games, or Interactive Fiction, present a significant challenge for reinforcement learning due to their massive state-action spaces and the computational inefficiency of traditional sequence models. This paper introduces a highly efficient framework that replaces standard LSTM encoders with a specialized Convolutional Neural Network (CNN) architecture. By incorporating position embeddings and utilizing dependency parsing to reorder game text, the proposed model achieves state-of-the-art scores on the classic game Zork I in just 10 hours of training. This represents a substantial speedup over previous methods while maintaining high performance and providing interpretability through max-pooling visualization.

Introduction

Interactive Fiction (IF) requires agents to navigate complex environments described through natural language and generate text-based commands. Unlike Atari games with discrete, low-dimensional action spaces, text games involve theoretically infinite command possibilities and variable-length prose descriptions. Historically, agents have relied on Long Short-Term Memory (LSTM) networks to process these sequences. However, LSTMs are inherently slow to train, often requiring millions of steps to converge, which makes reaching human-level performance on sophisticated games like Zork I functionally impossible within reasonable timeframes.

This research addresses these hurdles by optimizing the training process and enhancing the agent's contextual understanding. The core contribution is a framework that prioritizes computational speed and linguistic structure, enabling rapid convergence and state-of-the-art results.

Methodology

The researchers implemented several key modifications to the standard Deep Q-Learning Network (DQN) framework to improve efficiency and performance.

CNN-based Encoder and Max-Pooling

Instead of an LSTM, the framework utilizes a Convolutional Neural Network (CNN) to encode game descriptions into hidden states. CNNs offer a significant advantage in speed because they process blocks of text in parallel rather than sequentially. To maintain the relative order of tokens—preventing the model from treating text as a simple "bag of words"—position embeddings are integrated into the input layer.

A critical component of this architecture is the max-pooling layer. Beyond its role in dimensionality reduction, the authors argue that max-pooling acts as a natural attention mechanism. By selecting the most salient features from the text, it identifies the specific words (e.g., "north," "sword," "troll") that drive the agent's decision-making process.

Architecture of the CNN-based encoder with max-pooling for action selection.

Linguistic Enhancements: Dependency Parser Reordering

The most novel linguistic contribution is the use of a dependency parser to reorder input sentences. Standard CNN filters have a limited local receptive field. By using a Stanford dependency parser, the system reorders text so that syntactically related words—such as a verb and its distant object—are placed adjacent to one another. This "syntactic shortcut" allows the CNN's local filters to capture long-distance relationships that would otherwise be missed, effectively halving the time required for convergence.

Reward Shaping and Experience Sampling

To stabilize the learning curve, the authors implemented "repeated bad try" penalties, discouraging the agent from getting stuck in repetitive, unproductive loops. Additionally, small negative rewards were assigned for "negative masters" (e.g., feedback like "You can't do that"). The framework also employs priority experience sampling, which focuses training on rare, high-reward events, a necessity in the sparse reward environments typical of text games.

Experimental Results

The primary benchmark for evaluation was the 1979 classic Zork I. The game was analyzed through specific sub-tasks, including the "Egg Quest" and the "Troll Quest," as well as the full game constrained to 130 valid actions.

Performance and Convergence

The CNN-DQN with dependency reordering reached convergence in approximately 1.2 million steps. On the full version of Zork I, the agent achieved state-of-the-art scores within just 10 hours of training on a standard GPU setup. This is a massive improvement over previous LSTM-based methods that often required days or weeks of computation.

Comparison of game scores over time for LSTM, mean pooling, and max pooling architectures.

Ablation Studies

Ablation experiments highlighted the importance of each architectural choice. As shown in the performance plots, position embeddings were critical; without them, the CNN-DQN struggled to match the peak scores of the LSTM baseline. Furthermore, the max-pooling architecture significantly outperformed mean-pooling, validating its effectiveness as an "auto-attention" mechanism.

Conclusion

This paper demonstrates that speed is a vital feature in reinforcement learning for text games. By shifting from LSTMs to a CNN-based architecture enhanced with linguistic priors, the authors achieved a significant reduction in training time without sacrificing performance. While the current model operates within a constrained action space, future work will explore "action elimination" techniques to handle the even more complex, open-ended environments of modern interactive fiction. The ability to visualize agent attention through max-pooling also opens doors for more interpretable AI in natural language tasks.

Summary updated

BibTeX
@inproceedings{yin2019comprehensible,
  author = {Xusen Yin and Jonathan May},
  title = {{Comprehensible Context-driven Text Game Playing}},
  booktitle = {CoG},
  year = {2019},
  url = {https://openreview.net/forum?id=qVT9FdWpaN},
}
Figure