Language Understanding for Text-based Games using Deep Reinforcement Learning

Karthik Narasimhan, Tejas D. Kulkarni, Regina Barzilay

Abstract

In this paper, we consider the task of learning control policies for text-based games. In these games, all interactions in the virtual world are through text and the underlying state is not observed. The resulting language barrier makes such environments challenging for automatic game players. We employ a deep reinforcement learning framework to jointly learn state representations and action policies using game rewards as feedback. This framework enables us to map text descriptions into vector representations that capture the semantics of the game states. We evaluate our approach on two game worlds, comparing against baselines using bag-of-words and bag-of-bigrams for state representations. Our algorithm outperforms the baselines on both worlds demonstrating the importance of learning expressive representations.

Introduction

Traditional reinforcement learning (RL) agents typically operate on structured inputs like pixel grids or feature vectors. However, text-based games—such as Multi-User Dungeons (MUDs)—present a "language barrier" where the environment state is conveyed entirely through natural language descriptions. To succeed, an agent must ground this language, understanding that a description like "the bridge sways in the wind" implies a specific, potentially dangerous state.

Previous attempts often utilized Bag-of-Words (BoW) models, which fail to capture word order and logical nuances (e.g., "not hungry but sleepy" vs. "not sleepy but hungry"). This research addresses these limitations by proposing a framework that learns expressive, sequence-aware state representations directly from raw text.

Methodology: The LSTM-DQN

The core contribution is the LSTM-DQN, a two-part architecture designed to jointly learn language representations and action policies.

  1. Representation Generator ($\phi_R$): This module uses a Long Short-Term Memory (LSTM) network to process the sequence of words in a room description. The hidden states are then passed through a mean pooling layer to produce a fixed-length vector representation ($v_s$) of the game state.
  2. Action Scorer ($\phi_A$): This component takes the state vector $v_s$ and employs a multi-layered neural network to predict Q-values—the expected future rewards—for both actions (e.g., "go") and objects (e.g., "east").
The LSTM-DQN architecture jointly learns state representations and action policies.

The model is trained end-to-end using Q-Learning, enhanced by Experience Replay to stabilize training and Prioritized Sampling to accelerate learning in environments where positive rewards are sparse.

Experimental Setup

The approach was evaluated on two environments built with the Evennia engine:

  • Home World: A 16-state "adversarial" environment designed with quests involving negations and conjunctions to test logical parsing.
  • Fantasy World: A larger, stochastic world with a 1,340-word vocabulary. It features complex navigation, "death" states, and over 100 unique descriptions per room.

Results and Discussion

The LSTM-DQN significantly outperformed baseline models (BoW-DQN and Bigram-DQN) across both test environments.

Performance comparison across Home and Fantasy worlds, including transfer learning and prioritized sampling results.

Key Findings

  • Logical Understanding: In Home World, the LSTM-DQN achieved 100% quest completion, while BoW-based models plateaued below 50%, failing to grasp the logic of complex instructions.
  • Scalability: In the Fantasy World, the agent completed 96% of quests, demonstrating robust performance in larger state spaces.
  • Transfer Learning: Weights learned by the LSTM on one map could be transferred to another, allowing the agent to reach optimal policies much faster than starting from scratch.
  • Semantic Grounding: t-SNE visualizations of the learned embeddings showed that the agent naturally grouped semantically related words (e.g., "apple" and "hungry") together in the vector space.

Conclusion

While the LSTM-DQN excels at navigation and basic interaction, challenges remain in high-level strategic planning and handling more complex command syntaxes beyond "Action + Object" pairs. Future work will explore hierarchical RL and more advanced NLP architectures to bridge these gaps. This study nonetheless establishes that joint learning of language and policy is a powerful paradigm for agents operating in text-rich environments.

Summary updated

BibTeX
@inproceedings{narasimhan2015language,
  author = {Karthik Narasimhan and Tejas D. Kulkarni and Regina Barzilay},
  title = {{Language Understanding for Text-based Games using Deep Reinforcement Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2015},
  url = {https://openreview.net/forum?id=r1WfjzzOZH},
}
Figure