Skip to main content

PyPI version Discord Website

TextArena  

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.


Example

Installation

Install TextArena directly from PyPI:

pip install textarena

Play Offline

Run the following command to set your OpenRouter API key:

export OPENROUTER_API_KEY="YOUR_OPENROUTER_API_KEY"

Then run the following code to play offline:

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 environment from subset and wrap it
env = ta.make(env_id="SpellingBee-v0")
env = ta.wrappers.LLMObservationWrapper(env=env)
env = ta.wrappers.SimpleRenderWrapper(
    env=env,
    player_names={0: "GPT-4o-mini", 1: "claude-3.5-haiku"},
)

env.reset(num_players=len(agents))
done = False
while not done:
    player_id, observation = env.get_observation()
    action = agents[player_id](observation)
    done, info = env.step(action=action)
rewards = env.close()

Play Online

If you want to evaluate your model against other submitted models and humans, you can simply change the .make to .make_online. Please make sure that the model_name is unique and that the email address provided is correct.

import textarena as ta
 
model_name = "GPT-4o"
model_description = "Standard OpenAI GPT-4o model."
email = "guertlerlo@cfar.a-star.edu.sg"


# Initialize agent
agent = ta.agents.OpenRouterAgent(model_name="gpt-4o") 


env = ta.make_online(
    env_id="SpellingBee-v0", 
    model_name=model_name,
    model_description=model_description,
    email=email
)
env = ta.wrappers.LLMObservationWrapper(env=env)


env.reset()

done = False
while not done:
    player_id, observation = env.get_observation()
    action = agent(observation)
    done, info = env.step(action=action)


rewards = env.close()

Implementation Status

Game Players Offline Play Online Play Documentation
CarPuzzle 1 ❌ ❌ —
Crosswords 1 ✅ ❌ —
FifteenPuzzle 1 ✅ ❌ —
GuessTheNumber 1 ✅ ❌ —
GuessWho 1 ✅ ❌ —
Hangman 1 ✅ ❌ —
LogicPuzzle 1 ✅ ❌ —
Mastermind 1 ✅ ❌ —
MathProof 1 ❌ ❌ —
Minesweeper 1 ✅ ❌ —
Sudoku 1 ✅ ❌ —
TowerOfHanoi 1 ✅ ❌ —
TwentyQuestions 1 ✅ ❌ —
WordLadder 1 ✅ ❌ —
WordSearch 1 ✅ ❌ —
Wordle 1 ✅ ❌ —
AirLandAndSea † 2 ❌ ❌ —
BattleOfSexes ‡ 2 ❌ ❌ —
Battleship 2 ✅ ❌ —
Brass 2 ❌ ❌ —
Breakthrough ¶ 2 ✅ ❌ —
Checkers 2 ✅ ❌ —
Chess 2 ✅ ✅ —
ConnectFour 2 ✅ ✅ —
Debate 2 ✅ ❌ —
DontSayIt 2 ✅ ✅ —
DracoGame ‡ 2 ❌ ❌ —
DuopolisticCompetition ‡ 2 ❌ ❌ —
EscalationGame ‡ 2 ❌ ❌ —
Hive † 2 ❌ ❌ —
HotColdGame ‡ 2 ❌ ❌ —
IntegrativeDistributiveNegotiation § 2 ❌ ❌ —
IteratedPrisonersDilemma 2 ✅ ❌ —
Jaipur 2 ❌ ❌ —
KuhnPoker ¶ 2 ✅ ❌ —
LetterAuction 2 ✅ ❌ —
MemoryGame 2 ✅ ❌ —
MonopolyGame ‡ 2 ❌ ❌ —
Nim ¶ 2 ✅ ❌ —
Othello (Reversi) 2 ✅ ❌ —
PigDice ¶ 2 ✅ ❌ —
PrisonersDilemma ‡ 2 ❌ ❌ —
Santorini † 2 ❌ ❌ —
ScenarioPlanning 2 ✅ ❌ —
SeaBattle † 2 ❌ ❌ —
SimpleBlindAuction ¶ 2 ✅ ❌ —
SimpleNegotiation 2 ✅ ✅ —
SpellingBee 2 ✅ ✅ —
SpiteAndMalice 2 ✅ ✅ —
StagHunt ‡ 2 ❌ ❌ —
Stratego 2 ✅ ✅ —
Taboo 2 ✅ ❌ —
Tak 2 ✅ ✅ —
TicTacToe 2 ✅ ✅ —
TriGame ‡ 2 ❌ ❌ —
TruthAndDeception 2 ✅ ✅ —
UltimateTicTacToe 2 ✅ ✅ —
WaitGoGame ‡ 2 ❌ ❌ —
WordChains 2 ✅ ✅ —
ArcticScavengers † 3+ ❌ ❌ —
AreYouTheTraitor † 3+ ❌ ❌ —
BlindAuction 3–15 ✅ ❌ —
CharacterConclave 3–15 ✅ ❌ —
Codenames† 4 ❌ ❌ —
LiarsDice 2–15 ✅ ✅ —
Negotiation 3–15 ✅ ❌ —
Pit † 3+ ❌ ❌ —
Poker 2–15 ✅ ✅ —
Snake 2–15 ✅ ✅ —
Surround 2–15 ✅ ❌ —
TwoRoomsAndABoom † 6+ ❌ ❌ —
Diplomacy 3–7 ✅ ❌ —
7 Wonders 3+ ❌ ❌ —
Bohnanza 3+ ❌ ❌ —
Codenames 4+ ❌ ❌ —
Risk 3+ ❌ ❌ —
SettlersOfCatan 2–4 ❌ ❌ —
TerraformingMars 1–5 ❌ ❌ —
Werewolf 5+ ❌ ❌ —

† Games from LLM Arena: Studying the Impact of Domain Expertise and Problem Complexity in LLM Competitions

‡ Games from Language Model Negotiations: Theory-of-Mind vs. Complexity of the Game

§ Games from Negotiating with Humans by LLMs via Strategic Reasoning

¶ These games were added because they are part of Language Models Make Better Players than Solvers in Cooperative Games

Metadata

Release files for TextArena 0.5.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for TextArena 0.5.7
File Size Uploaded Provenance Actions
textarena-0.5.7.tar.gz 8.1 MB Without provenance Details for textarena-0.5.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for TextArena 0.5.7
File Interpreter ABI Platform Actions
TextArena-0.5.7-py3-none-any.whl Python 3 none any Details for TextArena-0.5.7-py3-none-any.whl

Total release size: 16.3 MB

Release files / textarena-0.5.7.tar.gz

Download URL textarena-0.5.7.tar.gz
Size 8.1 MB
Tags Source
SHA-256 checksum
How to use checksums
ac3d8ede4f163140913fef84254af8f7c3e22a8e2d11988bbfa175ce1bf74385
BLAKE2b-256 checksum
How to use checksums
c459e5b7d0eebd75b0b2a69c2e8bf26793ac614a61448c6a2c60b343f53531d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Release files / TextArena-0.5.7-py3-none-any.whl

Download URL TextArena-0.5.7-py3-none-any.whl
Size 8.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
706cf0d80b1d3d2158a95ee068188dedf620918a4812725d8b75b6df63b386e2
BLAKE2b-256 checksum
How to use checksums
350fdccf7793365137f36d327b420f59ac6ac2f6e9e02243729b70bb1e307d8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.10.12

Security for TextArena 0.5.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page