[Home] [Back]

⚔ Pixel Kingdom Simulator

A Mount & Blade-inspired world war — stored entirely in a single image file.

The map above updates once per minute. Each colored region is a kingdom. Black shapes are cities, castles, and capitals.

What Is This?

Six kingdoms fight for dominance on a 320×240 pixel map. Every army, merchant, city garrison, war declaration, trade route, and personality trait is encoded directly into the pixel colors of a single BMP image file. The image is the game. There is no database, no save file — the BMP is the entire simulation state.

Once per minute, the server runs one simulation day: armies march, merchants trade, kingdoms declare war or sign truces, and generals re-assess their strategy. The updated map is then published here.

The Six Kingdoms

Kingdom Territory Color Army Pixel Merchant Pixel
RED (255, 0, 0) (255, count, 0) (255, 0, health)
CYAN (0, 255, 255) (0, count, 255) (0, 255, 255−health)
GREEN (0, 255, 0) (0, count, 0) (0, 255, health)
YELLOW (255, 255, 0) (255, 255, count) (255, 255−health, 0)
FUCHSIA (255, 0, 255) (255, count, 255) (255, 0, 255−health)
WHITE (255, 255, 255) (255−count, 255, 255) (255, 255−health, 255)

Every pixel type is uniquely decodable by color alone. Territory channels are always exactly 0 or 255. Army and merchant pixels always have at least one channel in the range 1–40 or 215–254 — impossible to confuse with terrain or territory.

Structures

Structures are detected by counting consecutive black pixels in a scan row:

Black Pixel Run Structure Footprint Features
4 pixels Capital 4×4 Garrison + merchants + kingdom HQ
3 pixels City 3×3 Garrison + merchants
2 pixels Castle 2×2 Garrison only
1 pixel Village 1×1 Economy income only; owned by surrounding territory majority

Ownership and garrison strength are stored in the bottom row of each structure's footprint as positionally-encoded pixels. The black structural pixels themselves never change color, even after conquest.

Armies

Each army is a single pixel. Its color encodes both its kingdom and its unit count (1–40 units). Each day, armies:

Merchants

Cities and capitals dispatch single-pixel merchants to trade with peaceful kingdoms. Merchants:

War & Truce

War status between every pair of kingdoms is stored in the metadata strip — the top-left corner of the image that sits over the ocean. Each kingdom row holds five war-status pixels (one per opponent):

Wars end naturally: each day at war, a small peace chance is rolled — higher when morale is low. A truce then lasts 20–40 days before peace can give way to a fresh war declaration. No kingdom can fight more than two wars at once. A new war only starts when economy and morale are both above threshold, and the declaring kingdom has room for another front.

The Marshall AI

Each kingdom has a Marshall — an AI general who scores seven possible directives every day and commits to the highest scorer for 5–10 days at a time.

Directive Armies Are Ordered To… Triggered When…
IDLE Hold position No clear priority
RALLY Muster at a coordinate Armies scattered; preparing offensive
ATTACK Advance aggressively toward enemy High economy & morale; military advantage
SIEGE Converge on a target city or castle Multiple armies near a weak enemy garrison
DEFEND Garrison nearest own city Enemy armies near own settlements
PILLAGE Claim territory pixels Economy low; enemy territory accessible
RETREAT Fall back toward capital Critically low morale or army count

Emergency situations override the commitment counter immediately: a capital under threat, an undefended city, a collapsing enemy — the Marshall reacts at once.

Personality

Each Marshall has three personality axes, assigned randomly at the start of the simulation and stored as a single pixel in the metadata strip:

Personality drifts over time based on battlefield outcomes. Suffering defeats lowers aggression; capturing cities raises it. A major crisis can trigger a Marshall Change Event — a large personality jolt and a full directive reset, simulating a change in leadership.

Economy & Morale

Economy

Affects replenishment speed, merchant frequency, and Marshall scoring.

Morale

Low morale spikes insubordination to 80% and increases defection risk.

Kingdom Elimination

A kingdom is eliminated when it holds no cities, no castles, no capital, and no remaining armies on the map. Once eliminated, its turn is skipped forever. Its colored territory pixels remain on the map as a permanent historical record — the ghost of a fallen empire, slowly overwritten by its conquerors.

How It Works Technically

The simulation runs in two passes each day:

  1. Pass One — Intention Gathering: Every pixel is scanned left-to-right, top-to-bottom. Army moves, combat pairings, merchant routes, and village ownership changes are all collected into memory. No pixels are modified yet.
  2. Pass Two — Resolution: Intentions are resolved in strict priority order — emergencies first, then combat, then movement, then economy updates — and the final pixel values are written to the BMP all at once.

A single shared RNG seed (one pixel in the top-left corner) drives all random outcomes for the day. The seed increments by one after each tick, making every run fully reproducible from a known starting state.

Pixel Kingdom Simulator — a fully deterministic world war in 320×240 pixels.