Files
llm-adventure-game-2/llm-adventure-game-2
2026-05-26 08:48:03 +00:00
..
2026-05-26 08:48:03 +00:00

LLM Adventure Game

A simple textbased adventure game that uses OpenAI's GPT3.5 to generate the story. The game runs in a terminal and accepts freeform player commands. The LLM keeps the narrative and responds to the player.

Features

  • LLM powered narration GPT3.5 generates vivid scenes and dialogue.
  • Interrupt / pause Type pause to view the current game state and resume later.
  • State persistence The game automatically saves the conversation history to game_state.json so you can quit and resume.
  • Simple command interface help, pause, resume, exit.

Requirements

  • Python 3.8+.
  • openai library.
  • An OpenAI API key.

Installation

# Clone the repo
git clone https://git.brojs.ru/RK-A/llm-adventure-game-2.git
cd llm-adventure-game-2

# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate   # On Windows use `venv\Scripts\activate`

# Install dependencies
pip install -r requirements.txt

Usage

# Set your OpenAI API key
export OPENAI_API_KEY=sk-...   # On Windows use `set` instead of `export`

# Run the game
python main.py

Once the game starts, type any action or command and the LLM will generate the next part of the story.

Pausing and Resuming

  • Type pause to pause the game. The current state will be printed.
  • While paused you can type resume to continue or exit to quit.
  • If you exit the game, the state is cleared. If you close the terminal or hit Ctrl+C, the state is saved and you can resume by running python main.py again.

License

MIT License.