LLM Adventure Game
A simple text‑based adventure game that uses OpenAI's GPT‑3.5 to generate the story. The game runs in a terminal and accepts free‑form player commands. The LLM keeps the narrative and responds to the player.
Features
- LLM powered narration – GPT‑3.5 generates vivid scenes and dialogue.
- Interrupt / pause – Type
pauseto view the current game state and resume later. - State persistence – The game automatically saves the conversation history to
game_state.jsonso you can quit and resume. - Simple command interface –
help,pause,resume,exit.
Requirements
- Python 3.8+.
openailibrary.- 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
pauseto pause the game. The current state will be printed. - While paused you can type
resumeto continue orexitto 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 runningpython main.pyagain.
License
MIT License.