An experimental text-based adventure game driven by a large language model (LLM).
Go to file
projectmoon b301eaa476 Limit event_name to the actual list of valid event names 2024-03-27 12:12:44 +01:00
game Limit event_name to the actual list of valid event names 2024-03-27 12:12:44 +01:00
gbnf Remove boxed dyn requirement on GBNF Limits. 2024-03-27 11:10:59 +01:00
gbnf_derive Remove boxed dyn requirement on GBNF Limits. 2024-03-27 11:10:59 +01:00
.gitignore Implement derive macro to convert structs to GBNF rules. 2024-02-05 16:12:05 +01:00
COPYING Add readme and license 2024-01-15 09:35:01 +01:00
Cargo.lock Allow limiting of values on derive(Gbnf) structs. 2024-03-05 20:28:00 +01:00
Cargo.toml Implement derive macro to convert structs to GBNF rules. 2024-02-05 16:12:05 +01:00
README.md Add GitHub mirror 2024-01-15 09:40:52 +01:00
agplv3.png Add readme and license 2024-01-15 09:35:01 +01:00

README.md

AI Game

title work in progress

This repository is mirrored at GitHub

This is an experimental text-based adventure game that uses a locally-hosted large language model (LLM) to:

  • Create the game world
  • Parse commands
  • Determine the result of executing commands.

The purpose of this game is to learn more about large language models and the challenges involved with working with them, learn new technologies, and update my knowledge on Rust and NoSQL solutions. And of course, also play a game.

This codebase is currently under heavy work, and the game is not really playable. Exploration of the world in a (mostly?) coherent manner is possible. Running the application requires a bunch of manual setup, which I aim to eventually resolve.

Differences Compared to Other AI-driven RPGs/Fiction Software

Unlike existing AI-based roleplaying/fiction writing software, this game aims to keep as much state out of the LLM as possible. The LLM is used as a creative driving force to develop the world, while interacting with the game world is still mostly handled through programmed logic like a traditional text-based adventure.

General Roadmap

A very high level of things I want to accomplish.

  • Implementation of all events to allow for basic gameplay.
  • Addition of a game mechanics system (levels, classes, combat, etc).
  • Bundle the application and all its dependencies in a one-click executable.
  • Swap out Kobold API for OpenAI API, to allow for greater compatibility with existing LLM solutions.
  • Make a GUI (low priority).

Technical Documentation

Short technical documentation. To be improved.

Technologies/Dependencies

These technologies are used:

Building and Running

The application is built using cargo, the Rust build tool and dependency manager. Running the application requires running instances of both ArangoDB and KoboldCPP. See the websites of these projects for how to run them. Additionally, this application currently expects Kobold to use the Mistral 7B Instruct model to generate content. Using other models will possibly lead to unexpected or incoherent results.

Better instructions will follow as the application becomes more usable.

How Does It Work?

The game loop is based on a fairly simple concept: enter command, ask LLM to "parse" command, then ask the LLM to "execute" the command. The game is being built on an architecture similar to the event sourcing pattern: the LLM generates a list of events that apply to the player, NPCs, or game world.

The entire game world is stored in the ArangoDB graph database. The eventual aim is to store generated events and a mutable copy of the world in the database alongside the unaltered version, so that the game state can be recreated, restarted, and saved easily.

Most of the complexity in the code revolves around making sure that the information coming from the LLM is coherent. While the Mistral 7b Instruct model is very good at following instructions, it sometimes generates nonsensical data.

License

AGPLv3

The game is licensed under the AGPLv3. The game is free software, that you can run, redistribute, modify, study, and learn from as you see fit, as long as you extend that same freedom to others.