Skip to main content

A Collection of Competitive Text-Based Games for Language Model Evaluation and Reinforcement Learning

Project description

TextArena logo

A suite of 80+ Single-/Two-/Multi-Player texted based games for benchmarking and training of LLMs.

Play | Leaderboard | Games | Examples

GitHub Repo stars PyPI Downloads Discord PyPI version

Updates

  • 14/07/2025 Announcing MindGames a NeurIPS2025 competition for training LLMs on various TextArena games that require theory of mind.
  • 01/07/2025 Release of v0.6.9 with 100 games and simplified states, new observation wrappers for training and default wrappers for environments.
  • 01/07/2025 Release of SPIRAL: Self-Play on Zero-Sum Games Incentivizes Reasoning via Multi-Agent Multi-Turn Reinforcement Learning introducing RL via self-play on TextArena games as a potential new training paradigm.
  • 22/06/2025 Release of UnstableBaselines a light weight async online RL library for training LLMs on TextArena games.
  • 16/04/2025 Release of the TextArena paper
  • 14/02/2025 Release of the new, stable version for both pip and the website
  • 31/01/2025 Initial demo release highlighted by Andrej Karpathy (crashing all our servers)

Introduction

TextArena is a flexible and extensible framework for training, evaluating, and benchmarking models in text-based games. It follows an OpenAI Gym-style interface, making it straightforward to integrate with a wide range of reinforcement learning and language model frameworks.

Getting Started

Installation

Install TextArena directly from PyPI:

pip install textarena

Offline Play

The only requirement Agents need to fulfill is having a call function that accepts string observations and returns string action. We have implemented a number of basic agents that you can find [here](TODO link). In this example, we show how you can let GPT-4o-mini play against anthropic/claude-3.5-haiku in a game of TicTacToe.

We will be using the OpenRouterAgent, so first you need to set you OpenRouter API key:

export OPENROUTER_API_KEY="YOUR_OPENROUTER_API_KEY"

Now we can build the models and let them play:

import textarena as ta

# Initialize agents
agents = {
    0: ta.agents.OpenRouterAgent(model_name="GPT-4o-mini"),
    1: ta.agents.OpenRouterAgent(model_name="anthropic/claude-3.5-haiku"),
}

# Initialize the environment
env = ta.make(env_id="TicTacToe-v0")

# wrap it for additional visualizations
env = ta.wrappers.SimpleRenderWrapper(env=env) 

env.reset(num_players=len(agents))

done = False
while not done:
    player_id, observation = env.get_observation()
    action = agents[player_id](observation)
    done, step_info = env.step(action=action)

rewards, game_info = env.close()

Citation arXiv

If you use TextArena in your research, please cite:

@misc{guertler2025textarena,
    title={TextArena}, 
    author={Leon Guertler and Bobby Cheng and Simon Yu and Bo Liu and Leshem Choshen and Cheston Tan},
    year={2025},
    eprint={2504.11442},
    archivePrefix={arXiv},
    primaryClass={cs.CL},
    url={https://arxiv.org/abs/2504.11442}, 
}

How to Contribute:

If you have any questions at all, feel free to reach out on discord. The below issues are great starting points if you want to contribute:

  • Transfer the 'How to Contribute' from here to individual issues
  • Make RushHour board generation algorithmic
  • extend 2048 to arbitrary board sizes (should be very straight forward)
  • extend Fifteenpuzzel to arbitrary sizes
  • Add a nice end-of-game screen to the SimpleRenderWrapper visualizations

Project details


Download files

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

Source Distribution

textarena-0.6.16.tar.gz (857.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textarena-0.6.16-py3-none-any.whl (954.9 kB view details)

Uploaded Python 3

File details

Details for the file textarena-0.6.16.tar.gz.

File metadata

  • Download URL: textarena-0.6.16.tar.gz
  • Upload date:
  • Size: 857.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for textarena-0.6.16.tar.gz
Algorithm Hash digest
SHA256 10800c65cefa921c604e8c06479f0abe7ad34d32cc77c37f20bf25c4577e9bfc
MD5 c976c703bdcd0a347c22d0d30463bacd
BLAKE2b-256 8e8cf31337cb3102709bffd62082b15b2dec980ccf122a683f52078da8439f7c

See more details on using hashes here.

File details

Details for the file textarena-0.6.16-py3-none-any.whl.

File metadata

  • Download URL: textarena-0.6.16-py3-none-any.whl
  • Upload date:
  • Size: 954.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for textarena-0.6.16-py3-none-any.whl
Algorithm Hash digest
SHA256 26aace55ca11e7103c4605acbc4e5d1d165ee495e67245bd7444d1f2ae14dad9
MD5 9067b2a96ecb64e5ffe0065f8131a0f9
BLAKE2b-256 6510e8073461890c3b7a775e24e00443988aee08cf6b506c66f3c788a7fdbb01

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page