Nim is an environment for evaluating agents on the classic mathematical strategy game where players remove objects from piles. This environment wraps the Nim implementation from TextArena, a framework for text-based game environments.
- Mathematical strategy and game theory
- Optimal play discovery through combinatorial reasoning
- Sequential decision-making with perfect information
- Two-player competitive gameplay against an LLM opponent
Nim does not require a sandbox. It has minimal compute requirements.
MIT.
There are two splits: train (50 tasks) and test (50 tasks). Each split contains 50 tasks across each of 1 variants:
- Nim-v0
Each task is seeded for reproducibility.
This is a sparse reward environment. Rewards are mapped from TextArena's native range of {-1, 0, 1} to {0.0, 0.5, 1.0} via (raw + 1) / 2.
We do not use LLM graders for this environment; reward is determined programmatically.
Game state is generated procedurally by the TextArena engine using seeded randomness. No external data files are required.
Agents are given a single tool:
remove_objects(pile, quantity): Remove objects from a pile. Specify the pile number and quantity to remove.
Nim is a multi-turn environment.
Moderate. Nim has a well-known optimal strategy based on binary XOR (nim-sum), requiring mathematical insight or strategic reasoning to play well.
This environment requires an OpenAI API key (passed via secrets) to power the LLM opponent.
Agents in Nim interact only with a mathematical game and have no access to external systems, the internet, or sensitive data. The environment does not present safety risks.
@software{textarena2024,
author = {Guertler, Leon and Banting, Wilfried and Pignatelli, Eduardo},
title = {TextArena},
year = {2024},
publisher = {GitHub},
url = {https://github.com/LeonGuertler/TextArena}
}