Codified Finite-state Machines for Role-playing
Not on the map. Why?
Abstract (arXiv)
Modeling latent character states is crucial for consistent and engaging role-playing (RP) with large language models (LLMs). Yet, existing prompting-based approaches mainly capture surface actions, often failing to track the latent states that drive interaction. We revisit finite-state machines (FSMs), long used in game design to model state transitions. While effective in small, well-specified state spaces, traditional hand-crafted, rule-based FSMs struggle to adapt to the open-ended semantic space of RP. To address this, we introduce Codified Finite-State Machines (CFSMs), a framework that automatically codifies textual character profiles into FSMs using LLM-based coding. CFSMs extract key states and transitions directly from the profile, producing interpretable structures that enforce character consistency. To further capture uncertainty and variability, we extend CFSMs into Codified Probabilistic Finite-State Machines (CPFSMs), where transitions are modeled as probability distributions over states. Through both synthetic evaluations and real-world RP scenarios in established artifacts, we demonstrate that CFSM and CPFSM outperform generally applied baselines, verifying effectiveness not only in structured tasks but also in open-ended stochastic state exploration.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 32 of its 40 references that are in the map. First posted on arXiv 5 Feb 2026.
Builds on
32 of 40 references.
References · 32
- 2023GPT-4 Technical Reportcited by 18,396
- 2024The Llama 3 Herd of Modelscited by 14,715
- 2022ReAct: Synergizing Reasoning and Acting in Language Modelscited by 8,695
- 2023Reflexion: Language Agents with Verbal Reinforcement Learningcited by 4,276
- 2023Self-Refine: Iterative Refinement with Self-Feedbackcited by 3,442
- 2022Competition-Level Code Generation with AlphaCodecited by 1,462
- 2021DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharingcited by 1,254
- 2022Code as Policies: Language Model Programs for Embodied Controlcited by 1,210
- 2023Teaching Large Language Models to Self-Debugcited by 988
- 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 733
- 2024A Survey on Large Language Models for Code Generationcited by 658
- 2022PAL: Program-aided Language Modelscited by 652
20 more
- 2023Character-LLM: A Trainable Agent for Role-Playingcited by 339
- 2023TidyBot: Personalized Robot Assistance with Large Language Modelscited by 221
- 2024From Persona to Personalization: A Survey on Role-Playing Language Agentscited by 212
- 2023Large Language Models for Generative Information Extraction: A Surveycited by 185
- 2023InCharacter: Evaluating Personality Fidelity in Role-Playing Agents through Psychological Interviewscited by 179
- 2023RoleLLM: Benchmarking, Eliciting, and Enhancing Role-Playing Abilities of Large Language Modelscited by 175
- 2024Debug like a Human: A Large Language Model Debugger via Verifying Runtime Execution Step-by-stepcited by 127
- 2024Neeko: Leveraging Dynamic LoRA for Efficient Multi-Character Role-Playing Agentcited by 52
- 2024GraphReader: Building Graph-based Agent to Enhance Long-Context Abilities of Large Language Modelscited by 43
- 2023Statler: State-Maintaining Language Models for Embodied Reasoningcited by 40
- 2024CharacterBox: Evaluating the Role-Playing Capabilities of LLMs in Text-Based Virtual Worldscited by 38
- 2023LARP: Language-Agent Role Play for Open-World Gamescited by 24
- 2024Identity-Driven Hierarchical Role-Playing Agentscited by 18
- 2025Thinking in Character: Advancing Role-Playing Agents with Role-Aware Reasoningcited by 14
- 2023Recurrent Neural Language Models as Probabilistic Finite-state Automatacited by 6
- 2024FSM: A Finite State Machine Based Zero-Shot Prompting Paradigm for Multi-Hop Question Answeringcited by 6
- 2024Can Large Language Models Help Developers with Robotic Finite State Machine Modification?cited by 5
- 2025Codifying Character Logic in Role-Playingcited by 5
- 2025PsyMem: Fine-grained psychological alignment and Explicit Memory Control for Advanced Role-Playing LLMscited by 5
- 2024SG-FSM: A Self-Guiding Zero-Shot Prompting Paradigm for Multi-Hop Question Answering Based on Finite State Machinecited by 2
Built on by
Citing papers per year: 2026: 1.
1 paper.