Keys.gg

Kingdom.py

Offers

Trailers & screenshots

1 / 13

About Kingdom.py

Kingdom.py is a town-building game where you write Python scripts to direct your hero and manage the town. You begin on a small island with one hero, a town hall and a main.py file. Run your code to send the hero to build; the editor highlights each line as it runs and explains errors in plain language.

Build and manage your town

The economy runs on scripts and linked resources. Houses pay taxes when someone collects them, lumberyards stop when their groves are depleted, and fields must be sown and harvested before the grain rots. Bakeries use grain and wood to make bread, mines consume bread, and smithies turn iron into tools. Bandits arrive by boat to rob homes unless a guard reaches them first, while merchant ships leave if your goods are not on the pier in time.

The story teaches Python as you build, introducing variables, while loops, if statements, for loops, lists and dictionaries, functions and modules. Programs grow from simple collection commands into loops, stock checks and functions. Later, four heroes can run separate programs that divide the work through a shared database.

Shape life in the town

Townsfolk take jobs, earn wages, shop at the market and pay taxes. They talk on street corners, fall in love, marry, have children and grow old. Some steal, and some watch members take bribes; the dead roam as friendly ghosts until you build a graveyard.

You can write programs for their work shifts, including where farmers help, when they carry goods and when they rest. Run different versions on alternating shifts and compare the reports. The town.people() function reads information about the whole town, and you can arrest suspects, arrange matches with town.match() or issue decrees.

Each person's personality is made up of six Python functions: love, work, hands, conscience, warmth and temper. Children inherit each trait from either parent, with occasional new traits appearing. You can write your own rule, have the Ministry of Propaganda announce it and observe how it spreads through generations.

Trade across six islands

Build the Trade Guild to trade with six neighbouring islands at live prices. Storms, strikes and festivals affect the market. You can sell goods manually with commands such as market.sell(Wood, 50), or write a trading bot that reads the news wire. The islands also send commissions and, if you enable git, pull requests for your scripts, which you can review before merging.

Coding tools

The game includes floating or tiled code windows with syntax highlighting, autocomplete, snippets and a Python console that answers questions about the town. The console also has ps, top, kill and cron; every program in the kingdom, including the crabs' programs, runs as a process.

Git supports commits, branches, merges and tests that run before each commit. You can use the real numpy, pandas, matplotlib and requests libraries, with requests carried by pigeons. An algorithms room lets you watch ten algorithms run step by step alongside your own version. Scripts are plain .py files, which you can edit in VS Code for the game to pick up.

Learning and projects

Short story chapters, a Code School with runnable examples, hints and a reference solution for every chapter guide newcomers through the coding. The story takes about eight hours. Afterward, you can take on large projects: a lighthouse, an observatory, a great granary, a cathedral and a royal palace, each costing a small fortune.

Frequently asked questions

Steam lets publishers create keys to sell in other shops. Once you activate a key, the game is yours to keep, just like a store purchase.

Disclaimer: CD keys have an inherent 1–2% average failure rate. Check the shop terms for buyer protection info. Steam offers no buyer protection for keys bought in other shops and doesn't refund them.

Similar games