This repository contains the code for the PAYADOR approach, presented in the ICCC'24 paper “PAYADOR: A Minimalist Approach to Grounding Language Models on Structured Data for Interactive Storytelling and Role-playing Games”.
TL;DR: The PAYADOR approach to the world-update problem in Interactive Storytelling consists of grounding Large Language Models to structured data to predict world-state transformations resulting from the player input.
Authors: Santiago Góngora, Luis Chiruzzo, Gonzalo Méndez and Pablo Gervás.
The PAYADOR approach is intended to be easily adaptable for other research problems in Interactive Storytelling. Here we will briefly describe each module.
app.pyimplements the main loop of the PAYADOR system.ui.pyimplements a Gradio-based web interface.world.pyimplements the three components of the world model (Items, Characters and Locations) as well as the world itself. This module also implements the world state rendering in natural language and the update of the world state, key steps for the PAYADOR approach.config_loader.pyloads configuration settings fromconfig.iniand initializes the LLM models.world_serializer.pyhandles JSON serialization and deserialization of world states.models.pyloads and prompts the Gemini model.prompts.pycontains the prompts for world-state transformation prediction and narrative generation.
data/directory contains all data-related files and artifacts:data/premade_worlds/contains pre-configured world scenarios in JSON format (available in English and Spanish)data/playthroughs/stores game playthroughs and logs from player sessions
data/premade_worlds.pyprovides utilities to load pre-configured worlds from JSON files.data/playthroughs_processing.pyprovides utilities for analyzing and processing game playthroughs saved in JSON format.
Please follow these steps to get this code running.
To install the dependencies using conda, just run
conda env create -f environment.ymland then activate the environment
conda activate payadorThe system uses a config.ini file to set some preferences. Here are the available configuration options:
[Options]
Language: Game language (esfor Spanish,enfor English)WorldID: ID of the pre-made world to load (available worlds: 0-3)
[UI]
ShowDebugInfo: Display the debug information panel with transformation predictions and world state (true/false)
[Models]
NarrativeModel: LLM model used for narrative generationReasoningModel: LLM model used for world-state transformation reasoning
The default implementation uses the Gemini API. Get your API key and store it in a .env file (in the project root) with the appropriate environment variable name. The system will automatically load it.
...or modify models.py to use a different LLM!
Finally, run app.py. This will launch a Gradio web interface where you can interact with the storytelling system.
python app.pyThis work is documented in the ICCC'24 conference paper and the Master's thesis:
- ICCC'24 Proceedings: PAYADOR: A Minimalist Approach to Grounding Language Models on Structured Data for Interactive Storytelling and Role-playing Games
- Master's Thesis: Approaches to interactive and improvisational storytelling
If you use some part of this work in your research, please cite:
@inproceedings{gongora2024payador,
title={PAYADOR: A Minimalist Approach to Grounding Language Models on Structured Data for Interactive Storytelling and Role-playing Games},
author={G{\'o}ngora, Santiago and Chiruzzo, Luis and M{\'e}ndez, Gonzalo and Gerv{\'a}s, Pablo},
booktitle={Proceedings of The 15th International Conference on Computational Creativity},
year={2024}
}
@mastersthesis{gongora2025approaches,
title={Approaches to interactive and improvisational storytelling},
author={G{\'o}ngora, Santiago},
year={2025},
school={Universidad de la Rep{\'u}blica, Facultad de Ingenier{\'i}a},
url={https://hdl.handle.net/20.500.12008/51156}
}