Skip to content

Releases: JosefAlbers/moulinet

`moulinet`: Large Language Model Game Engine

29 Jun 19:01
3ac6e64
Compare
Choose a tag to compare

moulinet: Large Language Model Game Engine

This repository contains a game engine that utilizes Large Language Models (LLMs) to generate games. The engine provides a flexible and efficient framework for creating text-based or visual games by leveraging the power of LLMs.

Features

  • LLM Integration: The engine seamlessly integrates with Large Language Models, enabling natural language processing and generation for interactive storytelling, dialogue, and gameplay mechanics. By default, it uses the Mistral-7B-Instruct-v0.3 model (mistralai/Mistral-7B-Instruct-v0.3), but you can easily swap this with your preferred LLM.
  • Modular Design: The engine is designed with a modular architecture, allowing developers to easily create and extend game systems, mechanics, and content.
  • Visual and Text-based Games: Support for both text-based and visual games, including 2D tile-based games, is provided by the engine.
  • Dialogue and Storytelling: It provides tools and frameworks for creating engaging narratives and interactive dialogues, leveraging the power of LLMs.
  • Game Loop and Event Handling: A robust game loop and event handling system are provided by the engine, allowing for real-time or turn-based gameplay.
  • Asset Management: It includes an asset management system for loading and managing game assets such as images, sounds, and data files.
  • Cross-Platform: The engine is designed to work seamlessly on Windows, macOS, and Linux operating systems, providing a broad reach for your games.

Getting Started

To get started with the LLM Game Engine, follow these steps:

  1. Clone the Repository:
git clone https://github.com/JosefAlbers/moulinet.git
  1. Install Dependencies:

Install the required dependencies by following the instructions in the requirements.txt file.

  1. Create Your Own Game:

Utilize the engine's modular design and tools to create your own unique games. The engine provides a flexible framework that allows you to focus on your game's design, story, and mechanics.

from moulinet import GameEngine

foreground = [
    [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
    [-1, -1,  0,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2, -1, -1],
    [-1,  0, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12,  2, -1],
    [-1, 10, 10, 11, 11, 11, 21, 21, 21, 21, 11, 11, 11, 12, 12, -1],
    [-1, 10, 20, 21, 21, 22, -2, -2, -2, -2, 20, 21, 21, 22, 12, -1],
    [-1, 10, -1, -1, -1, -1, 11, 11, 11, 11, -1, -1, -1, -1, 12, -1],
    [-1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, -1],
    [-1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, -1],
    [-1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, -1],
    [-1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, -1],
    [-1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, -1],
    [-1, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, -1],
    [-1, 10, 11, 11, 11, 21, 21, 21, 21, 21, 21, 11, 11, 11, 12, -1],
    [-1, 20, 21, 21, 22, -2, -2, -2, -2, -2, -2, 20, 21, 21, 22, -1]
]

dict_objects = {
    'player': {'positions': [(8, 14)]},
    'castle': {'positions': [(8, 0)]},
    'tower': {'positions': [(4, 1), (12, 1)]},
    'house': {
        'positions': [(4, 6), (4, 9), (12, 7)],
        'npc_names': ["Alice", "Bob", "Charlie"]
    }
}

game = GameEngine(foreground)
game.run(dict_objects)

Alt text
Alt text
Alt text

Click to expand output
pygame 2.5.2 (SDL 2.28.3, Python 3.12.3)
Hello from the pygame community. https://www.pygame.org/contribute.html
No existing memory file found. Starting with empty memories for all NPCs.
All NPC memories saved to npc_memories.json
### Prompt ###
[INST] You are Bob, an NPC in a 2D RPG game. You're having a brief conversation with Charlie.  Start a short, casual conversation (max 10 words). You may choose to share gossip or not. [/INST] Bob: Hey Charlie, heard the dragon's lair is easier these days? Worth a try?
### Output ###
Hey Charlie, heard the dragon's lair is easier these days? Worth a try?
### Prompt ###
[INST] You are Charlie, responding to Bob's comment: 'Bob: Hey Charlie, heard the dragon's lair is easier these days? Worth a try?'.  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Charlie: Nah, mate, still fiery! Better stick to gardening, eh?
### Output ###
Nah, mate, still fiery! Better stick to gardening, eh?
### Prompt ###
[INST] You are Charlie, responding to Bob's comment: 'Bob: Hey Charlie, heard the dragon's lair is easier these days? Worth a try?'.  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Charlie: Nah, mate, still fiery! Better stick to gardening, eh? [INST] Summarize the conversation so far between Charlie and Bob in 1 sentence, highlighting key points and any important information shared. [/INST] Charlie tells Bob that the dragon's lair is still difficult, advising him to avoid it and stick to gardening instead.
### Output ###
Charlie tells Bob that the dragon's lair is still difficult, advising him to avoid it and stick to gardening instead.
### Prompt ###
[INST] You are Alice, an NPC in a 2D RPG game. You're having a brief conversation with Charlie.  Start a short, casual conversation (max 10 words). You may choose to share gossip or not. [/INST] Alice: Hey Charlie, heard the blacksmith's been making some impressive new weapons lately! Ever tried them?
### Output ###
Hey Charlie, heard the blacksmith's been making some impressive new weapons lately! Ever tried them?
### Prompt ###
[INST] You are Charlie, responding to Bob's comment: 'Bob: Hey Charlie, heard the dragon's lair is easier these days? Worth a try?'.  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Charlie: Nah, mate, still fiery! Better stick to gardening, eh? [INST] You are Charlie, responding to Alice's comment: 'Alice: Hey Charlie, heard the blacksmith's been making some impressive new weapons lately! Ever tried them?'. You have some information you could potentially share: Charlie tells Bob that the dragon's lair is still difficult, advising him to avoid it and stick to gardening instead..  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Charlie: Nah, mate, dragon's lair ain't worth it. Try the blacksmith's new weapons instead!
### Output ###
Nah, mate, dragon's lair ain't worth it. Try the blacksmith's new weapons instead!
### Prompt ###
[INST] You are Charlie, responding to Bob's comment: 'Bob: Hey Charlie, heard the dragon's lair is easier these days? Worth a try?'.  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Charlie: Nah, mate, still fiery! Better stick to gardening, eh? [INST] You are Charlie, responding to Alice's comment: 'Alice: Hey Charlie, heard the blacksmith's been making some impressive new weapons lately! Ever tried them?'. You have some information you could potentially share: Charlie tells Bob that the dragon's lair is still difficult, advising him to avoid it and stick to gardening instead..  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Charlie: Nah, mate, dragon's lair ain't worth it. Try the blacksmith's new weapons instead! [INST] Summarize the conversation so far between Charlie and Alice in 1 sentence, highlighting key points and any important information shared. [/INST] Charlie advised Alice to try the blacksmith's new weapons instead of attempting the dragon's lair, suggesting that the latter is still challenging and not worth the risk.
### Output ###
Charlie advised Alice to try the blacksmith's new weapons instead of attempting the dragon's lair, suggesting that the latter is still challenging and not worth the risk.
### Prompt ###
[INST] You are Bob, an NPC in a 2D RPG game. You're having a brief conversation with Charlie.  Start a short, casual conversation (max 10 words). You may choose to share gossip or not. [/INST] Bob: Hey Charlie, heard the dragon's lair is easier these days? Worth a try? [INST] You are Bob, an NPC in a 2D RPG game. You're having a brief conversation with Alice.  Start a short, casual conversation (max 10 words). You may choose to share gossip or not. [/INST] Bob: Alice, have you tried the new potion recipe? It's a game-changer!
### Output ###
Alice, have you tried the new potion recipe? It's a game-changer!
### Prompt ###
[INST] You are Alice, an NPC in a 2D RPG game. You're having a brief conversation with Charlie.  Start a short, casual conversation (max 10 words). You may choose to share gossip or not. [/INST] Alice: Hey Charlie, heard the blacksmith's been making some impressive new weapons lately! Ever tried them? [INST] You are Alice, responding to Bob's comment: 'Bob: Alice, have you tried the new potion recipe? It's a game-changer!'.  Give a brief, casual response (max 10 words). You may choose to respond to their gossip or share your own. [/INST] Alice: Thanks for the tip! I can't wait to give it a shot in my next battle!
### Output ###
Thanks for the tip! I can't wait to give it a shot in my next battle!
### Prompt ###
[INST] You are Alice, an NPC in a 2D RPG game. You're having a brief conversation with Charlie.  Start a short, c...
Read more