Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

pyfiction, a universal API for text-based games

Project Description

Python API for all kinds of text-based games.


Text-based games, more commonly known as interactive fiction (IF), come in various formats and use different interpreters that aren’t often compatible with each other.

The goal of pyfiction is to wrap the functionality of different IF simulators and to provide a universal API for text games for research purposes.

Pyfiction also includes sample agents that can learn to play the supplied text games.


  • Python 3.6 (older version might work but they aren’t tested, Python 3.5 tested briefly)
  • text-games submodule for games ‘Saving John’ and ‘Machine of Death’
  • keras, tensorflow and their dependencies for launching the example agents
  • selenium and chromedriver for running the HTML-based games
  • h5py for saving and loading models
  • pydot for visualising model graphs


To install the latest published version, simply run:

pip install pyfiction

To install the bleeding-edge version from this repository, run:

git clone --recursive
cd pyfiction
pip install -e .


pyfiction provides a simple agent-environment interface for text-game environments.

Simple RL interface [4]. In pyfiction, the agent calls the corresponding functions of the game environment:

  • state, actions, rewards = (left branch),
  • game.write(action) (right branch).


To run any example (from the game list below or from this list), simply run:


on these files:

or on one of the supported games below.

Currently supported games

The following links lead to training experiments of the SSAQN agent on the supported games:

Additionally, the plan is to integrate the individual games to the OpenAI Gym, see the pull request and the text_games branch for details.

Adding new games



Version 0.1.2, Alpha

Release History

This version
History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(8.1 MB) Copy SHA256 Hash SHA256
Wheel py2.py3 Jul 30, 2017
(8.1 MB) Copy SHA256 Hash SHA256
Source None Jul 30, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting