Can AI learn to play text-based games like a human? That’s the question applied scientists at Uber’s AI research division set out to answer in a recent study. Their exploration and imitation-learning-based system — which builds upon an earlier framework called Go-Explore — taps policies to solve a game by following paths (or trajectories) with high rewards.

“Text-based computer games describe their world to the player through natural language and expect the player to interact with the game using text. These games are of interest as they can be seen as a testbed for language understanding, problem-solving, and language generation by artificial agents,” wrote the coauthors of a paper describing the work. “Moreover, they provide a learning environment in which these skills can be acquired through interactions with an environment rather than using fixed corpora … [That’s why] existing methods for solving text-based games are limited to games that are either very simple or have an action space restricted to a predetermined set of admissible actions.”

As the researchers explain, a challenge in developing text-game-playing AI is contending with large action spaces (i.e., the range of decisions facing a player). With a vocabulary of 20,00 words and the possibility of producing sentences with at most 7 words, for example, the total number of actions is a whopping 1.28e^30.

The modified Go-Explore, then, maps observations to actions while keeping track of under-explored areas in the game space. In the first of two phases — the “exploration” phase — Go-Explore explores the environment and records visited places to archival “cells.” These cells contain sets of observations mapped to the same representation by some mathematical function, and each  is associated with metadata including the trajectory towards that cell, the length of that trajectory, and the cumulative reward of that trajectory.

Uber AI text games

In every game session, Go-Explore selects a cell based on its metadata and starts to randomly explore from the end of the trajectory associated with the cell. This is the beginning of phase two — the “robustification” phase — the rest of which involves training a policy using the trajectories in phase one. The goal here is to turn a “fragile” sequence of actions into a policy that can be applied across different games, or even one that can generalize to unseen games.

In a series of experiments, the researchers set Go-Explore loose in two games where multiple words are required to win and the reward is particularly sparse (i.e., actions where feedback isn’t available). The first was CoinCollector, a class of text-based games where the objective is to find and collect a coin from a location given a set of rooms, and the second was CookingWorld, a collection of over 4,440 games with 222 different difficulty levels and 20 games per level of difficulty (each with different entities and maps). While CoinCollector only parses five commands in total, CookingWorld accepts 18 verbs and 51 entities with predefined grammar with a total vocabulary size of 20,000, and it requires many actions (at least 30 on hard games) to find a reward.

For CookingWorld, the team devised three different scenarios in total: Single, where one agent was trained and tested for one game; joint, where a single policy was trained and tested on all 4,440 games; and zero-shot, where games were split into training, validation, and test sets and the policy was trained on the training games and tested on unseen test games. In all games, including CoinCollector, the maximum number of steps was set to 50 for simplicity’s sake.

The team reports this flavor of Go-Explore found an optimal strategy in CoinCollector with approximately half the actions compared with the previous state-of-the-art system, and with a trajectory
length of 30 steps compared with the previous best average of 38. In CookingWorld, Go-Explore attained a total score of 19,530 over games (close to the maximum score of 19,882) with 47,562 steps and found a winning trajectory in 4,279 out of the total of 4,440 games.

It’s not a flawless approach by any stretch, the researchers note. There’s a large overlap in the descriptions of games, leading to a situation where a policy receives similar observations but is expected to take two different actions. And Go-Explore would have a hard time finding good trajectories in games with larger action sizes, like Zork I. That said, the team believes their modified Go-Explore system shows “promising results” in the text game arena.