Skip to content

MichiTheCat-RedStar/TheAlchemist-Ollama

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Telegram GitHub Itch.io

Alchemy Game with Ollama

A simple text-based alchemy game where you combine two elements to create new ones.
The result is generated by a local LLM (via Ollama), making each combination potentially unique.

Description

The game starts with a basic set of elements (depending on your language setting).
You pick two elements from your current list, and the AI suggests a new element that results from their combination.
The new element is added to your collection and saved to a file, so you can continue your alchemical journey later.

Requirements

  • Python 3.7+
  • Ollama installed and running
  • An Ollama model pulled (e.g., gemma3:12b)

Installation

  1. Install the Ollama Python library:
    pip install ollama
  2. Pull the model you want to use (adjust the name if you change it in the script):
    ollama pull gemma3:12b
  3. Download or copy the script (main.py) to your local machine.

Configuration

Open main.py and adjust the following settings at the top of the file:

  • MODEL: the name of the Ollama model you want to use (e.g., 'gemma3:12b').
    Run ollama list in your terminal to see available models.
  • LANGUAGE: choose 'en' (English), 'ru' (Russian), or 'ua' (Ukrainian).
    This affects the initial elements and the prompts.

The script automatically creates a file named Elements in the same directory.
This file stores all discovered elements, separated by ;% .
If the file is empty when the script starts, it will be populated with the default elements for your chosen language:

  • English: Water, Earth, Fire
  • Russian: Вода, Земля, Огонь
  • Ukrainian: Вода, Земля, Вогонь

Usage

Run the script:

python main.py

You will see your current list of elements.
Enter two element names (exactly as they appear in the list) when prompted.
The script will ask the AI what they combine into and add the result to your collection.

Example session (in English):

You have: ['Water', 'Earth', 'Fire']
Select two elements from this and they will connect:
1> Water
2> Earth

You now have a new Mud element!

The new element Mud is appended to the list and saved to the Elements file.

How It Works

  1. The script reads the Elements file. If empty, it initialises the list with default elements.
  2. It displays the current elements and asks the user to pick two.
  3. The input is validated (must be in the list).
  4. A request is sent to Ollama with a system prompt that instructs the model to act as an alchemist and return only the resulting element.
  5. The model’s response is stripped and added to the element list.
  6. The updated list is written back to the Elements file (separated by ;% ).

Notes

  • The AI’s creativity can lead to unexpected results – that’s part of the fun!
  • If the model returns a multi‑word answer, it will be saved as one element (e.g., Mud, Fire Water).
  • The Elements file is plain text; you can edit it manually if you wish (e.g., to remove duplicates or add your own elements).
  • Make sure Ollama is running in the background (ollama serve) before executing the script.

Enjoy your alchemical experiments!