Skip to content
Smartdude400Public

About

An Ollama-driven god game - every villager's decisions come from a local LLM

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

GENESIS — an Ollama-driven god game

You are a god watching over a small island. Humans are born, grow hungry, wander, find food, bond, have children, build huts, grow old and die — and each one's decisions are driven by a local Ollama LLM. You shape their world with divine powers: feed them, bless them, smite them, send rain, or raise and sink the land itself.

it runs in a window · local · offline · no API keys


The refined prompt (what this build is)

Your original idea —

"a civilization game in python where i am the god and i simulate life, humans controlled by an Ollama AI"

— rewritten as a concrete spec:

Build a real-time god-game / life simulation in Python (pygame) on a procedurally generated tile world. The player is a non-embodied god who observes and intervenes with divine powers (spawn food, create/bless/smite humans, send rain, raise & lower terrain) by clicking the map.

The world is populated by autonomous human agents, each with needs (hunger, energy, health), an age and lifecycle (birth → adulthood → reproduction → old age → death), and a lineage colour. Each human's decisions are made by a local LLM served through Ollama: the agent perceives its surroundings (nearby food, people, terrain, its own body state) and the model returns a structured action + a short spoken line + a mood.

Because LLM calls are slow (~1–3 s), the AI runs on a threaded, periodic, cached schedule — each human asks the model for a fresh plan every few ticks and follows it with lightweight logic in between — and degrades gracefully to a survival heuristic if Ollama is unavailable, so the simulation never stalls. Emergent goals: survive, gather, bond, reproduce, and slowly build the beginnings of a civilisation.

That spec is exactly what the code in this folder implements.


Requirements

  • Python 3.10+ (tested on 3.14)
  • pygame-ce (or pygame): pip install -r requirements.txt
  • Ollama running locally with a model pulled — this build defaults to mistral. Get it with ollama pull mistral.
    • On Windows the Ollama server idles down and relaunches on demand. Keep the Ollama app open (or run ollama serve) so the humans can "think". If it's not reachable, the game still runs on the built-in heuristic.

Run

python main.py                 # mistral drives the humans
python main.py --model qwen2.5-coder:7b-instruct-q4_K_M
python main.py --pop 16        # bigger starting tribe
python main.py --no-llm        # pure heuristic, no Ollama needed

Headless self-check (no window, no Ollama):

python smoke_test.py

Controls — your divine powers

Select a power with the number keys (or click it in the right panel), then click the world.

Key Power Effect
1 Inspect Click a human to follow their stats, mood & thoughts
2 Spawn Food Scatter food on fertile tiles
3 Create Human Breathe life into a new adult
4 Smite Lightning — heavy damage in a small area
5 Bless Heal, feed and energise everyone nearby
6 Rain Make food bloom across a wide area
7 Raise Land Push the terrain up (sea → sand → grass → mountain)
8 Lower Land Sink the terrain (drowns land into water)
Key Action
SPACE Pause / resume
+ / - Faster / slower simulation
R Remake the world from nothing
H Toggle the help line
ESC / Q Quit

Food-, rain- and terrain-tools paint while you hold the mouse button.

What the humans track

Each human has health, energy and hunger bars, an age in "years", a mood, a lineage colour (children inherit a mutated tint of their parents), and a small speech bubble showing what the LLM had them say. A gold dot means they're currently "thinking" (waiting on Ollama).

How the AI works

brain.py runs a small pool of worker threads. When a human's plan expires it submits a compact text perception to Ollama (/api/chat, format: json, low num_predict for speed) and the model returns:

{ "action": "seek_food", "dir": "NE", "say": "Food is near", "mood": "hungry" }

action is one of seek_food, eat, rest, wander, socialize, reproduce, build, flee. The game executes that intent with deterministic logic (pathfinding to the nearest food, stepping toward a mate, etc.) until the next thought arrives. If Ollama is slow or offline, the same human falls back to a hand-written survival heuristic — motion never freezes.

Tuning

Almost every knob lives in config.py: world size, tile size, starting population, population cap, how fast hunger rises, food regrowth rate, fertility window, lifespan, plan refresh rate, and the colour palette.

Files

File Role
main.py Window, god powers, rendering, the simulation loop
world.py Procedural island, terrain, food, terraforming
agent.py The Human data model
brain.py Threaded Ollama client + graceful fallback
config.py All the tunable numbers and colours
smoke_test.py Headless validation of the sim + every god power

Ideas to extend

  • Thirst & water: make humans seek shorelines to drink.
  • Tribes & conflict: let the LLM decide to share, trade or raid.
  • Tech tree: huts → farms → fire → tools as population/age milestones.
  • Memory: give each human a short rolling memory fed back into the prompt so personalities persist.
  • Vision model: you already have llava — feed it a screenshot so the god (you) can ask the model to narrate the world's history.

About

An Ollama-driven god game - every villager's decisions come from a local LLM

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages