Elara S. Novikova
Iskra-226

HAMURABI

Хаммурапи

Doug Dyment 1968, David Ahl 1973

Ten years of ancient Sumer, a population, a granary, and a land price that moves every year. Buy, feed, sow, and find out in the fall what the harvest and the rats left you. Doug Dyment wrote it in 1968, David Ahl put the BASIC version in front of everybody in 1973, and every city builder since owes it the loop.

sectors
20-24
source lines
87
reign
10 years
start
95 people, 2800 bushels, 1000 hectares
The second year of the reign: a hectare costs 22, the year asks its three questions, the harvest comes in at 4 to the hectare and 55 people are dead of hunger.
The second year of the reign: a hectare costs 22, the year asks its three questions, the harvest comes in at 4 to the hectare and 55 people are dead of hunger.

Run this disk · The image, 256,256 bytes

Why this one matters

This is the first resource game and the ancestor of every building simulation that came after it. Doug Dyment wrote THE SUMER GAME in FOCAL at Digital in 1968; David Ahl translated it to BASIC and printed it, and that is the step that turned a curiosity into something running in every school with a terminal. There is no map, no picture and no clock. There are three numbers you divide up each year and a fourth that decides, afterwards, how well you divided them.

What it taught people is that a program can put you in a position instead of setting you a task. Nothing here is a puzzle with an answer at the back. You feed the people or you buy land, you cannot do both, and the harvest that would have settled the question is not announced until after you have committed. Everyone who has since built a game about a granary, a treasury or a supply line has rebuilt these ten turns without knowing it. A printed listing crossed borders that a tape or a floppy did not, which is how it reached machines nobody in Boston was thinking about.

Ten years, on a planning machine

Ten years, starting with the three numbers Ahl's version starts with: 95 people, 2800 bushels, 1000 hectares. Each year opens with a fresh land price between 17 and 26, then asks how many hectares to buy, how much grain to hand out at twenty a head, and how many hectares to sow, which costs half a bushel of seed each. The yield comes back between 1 and 5 per hectare. On a bad roll the rats take a tenth of the store, anyone you could not feed starves, and a worse roll brings plague and halves the population. Finish under thirty people and the last line reads НАРОД ВАС ПРОКЛИНАЕТ.

The joke arrives first and then stops being one. The application disks recovered from this family of machines carry a planning and reporting suite from the Gosplan institute of the Latvian SSR in Riga, developed further in Leningrad: classifiers, indicators, a form designer. The same interpreter now runs a game about allocating grain badly and being cursed for it, in Russian, counting in hectares rather than Ahl's acres, because hectares are what this machine's own paperwork would have used. Nothing about the hardware objects. It has no opinion about what it is being asked to compute.

What it cost the interpreter

HAMURABI cost the most of any title here to get working. It needs random numbers, and RND appears nowhere in the recovered software, because accounting has no use for chance and so the dialect never gave the atom up. The generator is therefore written out in plain BASIC: multiply the seed by 21, add 13, subtract 100 until it fits again. Those constants give the full period of 100. The obvious choice, 13 and 7, would have started repeating after twenty draws, which over ten years of harvests you would notice.

A truncation routine had to be built alongside it, because INT is unattested as well. It counts its input down to zero and counts the steps, and in the first version the input was whatever variable the caller passed in. In HAMURABI that variable was the population. People vanished in years with no famine and no plague, and only sitting through ten years in a row made it visible; a smoke test that starts a program and stops would have passed. The fix is a convention rather than a clever line. One variable goes in, a different one comes out, and every program on these disks obeys it now.

The payroll software could not have found that. It calls its helpers on quantities it then prints, so an overwrite would have shown up as a wrong figure on a wage slip, not as a slow leak in a running total nobody reconciles. Playing a game for ten simulated years is a different kind of test from checking one number against a printout, and this is the place where the games did something for the interpreter that the recovered originals never could.

What this disk is not

This disk was written in 2026. The mechanics of Hamurabi are common property and have been reimplemented on nearly every machine ever sold, but the code in this image is mine, written this year against a dialect reconstructed from the recovered disks. Nothing here was excavated. No Soviet games disk has ever surfaced, from this machine or any of its siblings, and if one ever does it will look nothing like this. I would rather repeat that on every page than have one reader file the image away as a document.

What I checked

Land prices vary across the years (26, 22, 19, 25), yields run 1 to 5 per hectare, famine deaths compute correctly.

What this does not show

What is tested is the emulator, not the hardware. The seed is fixed at 37, because no clock or timer function is attested, so the same ten years come up every time. Historically that is authentic, and it is why so many early BASIC games ask you to type a number first. This is also a compact Hamurabi: Ahl's version limits how much land one person can work and throws you out of office for starving too many in a single year, and neither rule is here.

Where to read more

The source

HAMURABI.bas, 87 lines, assembled onto the image with iskra_asm.py

87 lines of BASIC
10 REM HAMURABI
20 PRINT "*** ХАММУРАПИ ***"
30 PRINT "ПРАВЬТЕ ДРЕВНИМ ШУМЕРОМ 10 ЛЕТ."
40 V01 = 95
50 V02 = 28
51 V02 = V02 * 100
60 V03 = 10
61 V03 = V03 * 100
70 V04 = 0
75 V50 = 37
100 V04 = V04 + 1
105 IF V04 > 10 GOTO 800
110 GOSUB 900
115 V61 = V50 / 10
116 GOSUB 950
117 V05 = V60 + 17
120 PRINT "--- ГОД";V04
130 PRINT "НАСЕЛЕНИЕ";V01;" ЗЕРНО";V02;" ЗЕМЛЯ";V03
140 PRINT "ЦЕНА ГЕКТАРА";V05
150 PRINT "ГЕКТАРОВ КУПИТЬ"
160 INPUT V06
170 V07 = V06 * V05
180 IF V07 > V02 GOTO 150
190 V03 = V03 + V06
200 V02 = V02 - V07
210 PRINT "ЗЕРНА ЛЮДЯМ (20 НА ЧЕЛОВЕКА)"
220 INPUT V08
230 IF V08 > V02 GOTO 210
240 V02 = V02 - V08
250 PRINT "ГЕКТАРОВ ЗАСЕЯТЬ"
260 INPUT V09
270 IF V09 > V03 GOTO 250
280 V10 = V09 / 2
290 IF V10 > V02 GOTO 250
300 V02 = V02 - V10
310 GOSUB 900
315 V61 = V50 / 20
316 GOSUB 950
317 V11 = V60 + 1
320 V12 = V09 * V11
330 V02 = V02 + V12
340 PRINT "УРОЖАЙ С ГЕКТАРА";V11
350 GOSUB 900
355 IF V50 > 80 GOTO 380
360 GOTO 400
380 V61 = V02 / 10
381 GOSUB 950
382 V02 = V02 - V60
395 PRINT "КРЫСЫ СЪЕЛИ";V60
400 V61 = V08 / 20
405 GOSUB 950
410 V14 = V60
420 IF V14 > V01 GOTO 450
430 V15 = V01 - V14
440 PRINT "УМЕРЛО ОТ ГОЛОДА";V15
445 V01 = V14
450 GOSUB 900
455 IF V50 > 90 GOTO 470
460 GOTO 500
470 V61 = V01 / 2
471 GOSUB 950
475 V01 = V60
480 PRINT "*** ЧУМА! ***"
500 GOSUB 900
505 V61 = V50 / 10
506 GOSUB 950
510 V01 = V01 + V60
520 GOTO 100
800 PRINT "*** КОНЕЦ ПРАВЛЕНИЯ ***"
810 PRINT "НАСЕЛЕНИЕ";V01;" ЗЕМЛЯ";V03;" ЗЕРНО";V02
840 IF V01 < 30 GOTO 870
850 PRINT "ВЫ ПРАВИЛИ ДОСТОЙНО."
860 GOTO 880
870 PRINT "НАРОД ВАС ПРОКЛИНАЕТ."
880 END
900 V50 = V50 * 21
910 V50 = V50 + 13
920 IF V50 < 100 GOTO 940
930 V50 = V50 - 100
935 GOTO 920
940 RETURN
950 V60 = 0
960 IF V61 < 1 GOTO 990
970 V60 = V60 + 1
980 V61 = V61 - 1
985 GOTO 960
990 RETURN

Back to Iskra-226