This is a little experimental adventure game that features rooms, items, and characters generated on
the fly by Llama, running locally via
llama.cpp. It renders with curses
in the terminal.
The game is functional but unfinished. Many features, for example player stats and combat, remembering the map or storyline, have not been implemented. Also, the model may generate subpar experiences, like repeated scenes or rooms without exits. It may take a few restarts to get a good experience.
Also, model outputs are evaluated in Python in a not-totally-safe way. Do not use in production or with untrusted models. Basic efforts are taken to avoid accidental unintended code evaluation, but it's not hardened against attacks.
To play, you will need to clone and build llama.cpp:
$ git clone https://github.com/ggerganov/llama.cpp /some/path/llama.cpp
$ cd /some/path/llama.cpp
$ make
Then, make sure you have the Llama model weights in llama.cpp's GGUF format. If you have the original model weights from Meta, follow the directions from llama.cpp:
$ cd /path/to/llama.cpp
$ python3 -m pip install -r requirements.txt
$ python3 convert.py /path/to/llama-2-13b # etc
$ ./quantize /path/to/llama-2-13b/ggml-model-f16.gguf /path/to/llama-2/13b/ggml-model-q4_k_m.gguf Q4_K_M
Then run game.py
in this repository with the main
binary from llama.cpp
along with the model
weights in GGUF format:
python3 game.py /path/to/llama.cpp/main /path/to/llama-2-13b/ggml-model-q4_k_m.gguf prompt.txt
The game was primarily tested on a Mac M2 Max with Llama 2 13B quantized at Q4_K_M.
Once you get the game running, try ordering an ale from the bartender:
- Up to move close to the bartender
- 1 to equip pence
- g to give the pence
Depending on the reaction, ask for an ale:
- t to talk
- type "one ale please" Enter
- explore the world by walking out a door and hitting Enter
- generate a new world by using the game console:
- ~ to activate console
- type "newgame Deep Space" (or whatever) then Enter
- If Llama generates an empty room, you can use the console to generate doors or people (or just
restart):
- ~ to activate console
- type, e.g., "newdoor cellar_door <description>" or "newperson amy <description>" then Enter
Copyright © 2023 Evan Jones