Hammurabi — 1 of 1

Jim Lai

Release 1

"Hammurabi" by "Jim Lai".

The story description is "Try your hand at governing Ancient Sumeria for a ten-year term of office."

The story headline is "An Inform 7 port of a well-known game".

Use full-length room descriptions. Use the serial comma. Use no scoring. Use undo prevention.

Include 6M62 Patches by Friends Of I7.

Release along with cover art, an interpreter, and source text.

Acreage is a kind of value. 1 acre (singular) specifies acreage. 3 acres (plural) specifies acreage.

Population is a kind of value. 1 person (singular) specifies population. 3 people (plural) specifies population.

Granary is a kind of value. 1 bushel (singular) specifies granary. 3 bushels (plural) specifies granary.

Grain per land is a kind of value. 1 bushel per acre (singular) specifies grain per land. 3 bushels per acre (plural) specifies grain per land.

Acreage times grain per land specifies a granary.

Seeding rate is a kind of value. 1 acre per bushel (singular) specifies seeding rate. 3 acres per bushel (plural) specifies seeding rate.

Seeding rate times a granary specifies an acreage.

Area per capita is a kind of value. 1 acre per person (singular) specifies area per capita. 3 acres per person (plural) specifies area per capita.

Area per capita times population specifies an acreage.

Consumption per capita is a kind of value. 1 bushel per person (singular) specifies consumption per capita. 3 bushels per person (plural) specifies consumption per capita.

Consumption per capita times population specifies a granary.

A kingdom is a kind of room.

A kingdom has a number called regnal year.

A kingdom has a number called starvation resentment.

A kingdom has a number called term length. The term length of a kingdom is usually 10.

A kingdom has population.

A kingdom has acreage.

A kingdom has granary.

A kingdom has area per capita. The area per capita of a kingdom is usually 10 acres per person.

A kingdom has area per capita called land rating.

A kingdom has a number called starvation rating.

Rats have a granary.

Annual starvation has a population.

Peak starvation has a population.

Total starvation has a population.

Plague victims has a population.

Annual immigration has a population.

Total immigration has a population.

Land price has grain per land.

Harvest yield has grain per land.

Acres planted has an acreage.

Food rations has a granary.

Land trade has an acreage.

Fields sowed has an acreage.

Fields sowed has a granary.

The underworld has population.

Ration has a granary.

Cultivation has an acreage.

Verdict is a thing. A verdict can be glowing, ambivalent, hateful, or national fink.

Ancient Sumeria is a kingdom. "Hammurabi, I beg to report to you:[line break]In year [regnal year of Ancient Sumeria], [population of annual starvation] starved and [population of annual immigration] came to the city. [if the population of plague victims > 0 people]A horrible plague struck! Half the people died! [end if]The population is now [population of Ancient Sumeria].[line break]The city now owns [acreage of Ancient Sumeria]. You harvested [grain per land of harvest yield] last year. Rats ate [granary of rats]. You now have [granary of Ancient Sumeria] in store.[line break]Land is trading at [grain per land of land price].[if granary of food rations > 0 bushels][line break]You have ordered that [granary of food rations] be set aside to feed the people.[end if][if acreage of fields sowed > 0 acres][line break]You have ordered that [acreage of fields sowed] be planted; [granary of fields sowed] will be required.[end if]".

The term length of Ancient Sumeria is 10.

Land valuation rules is a rulebook.

A land valuation rule: now the grain per land of land price is a random grain per land between 17 bushels per acre and 26 bushels per acre.

Yield flux rules is a rulebook.

A yield flux rule: now the grain per land of harvest yield is a random grain per land between 1 bushel per acre and 5 bushels per acre.

New order rules is a rulebook.

A new order rule: now the granary of food rations is 0 bushels.

A new order rule: now the acreage of fields sowed is 0 acres.

Rat infestation rules is a rulebook.

A rat infestation rule: now the granary of rats is the granary of Ancient Sumeria.

A rat infestation rule: let severity be a random number from 1 to 3; if severity is 2, now the granary of rats is (the granary of Ancient Sumeria divided by 3); if severity is 3, now the granary of rats is (the granary of Ancient Sumeria divided by 5).

A rat infestation rule: decrease the granary of Ancient Sumeria by the granary of rats.

Agricultural rules is a rulebook.

An agricultural rule: follow yield flux rules.

An agricultural rule: decrease the granary of Ancient Sumeria by granary of fields sowed; now the granary of fields sowed is 0 bushels.

An agricultural rule: if acreage of fields sowed > acreage of Ancient Sumeria, now the acreage of fields sowed is the acreage of Ancient Sumeria;

An agricultural rule: let harvest be the grain per land of harvest yield times acreage of fields sowed; increase the granary of Ancient Sumeria by harvest.

An agricultural rule: let percentage be a random number from 1 to 100; if percentage <= 60, follow rat infestation rules; otherwise now the granary of rats is 0 bushels.

Plague rules is a rulebook.

A plague rule: now the population of plague victims is 0 people.

A plague rule: let percentage be a random number between 1 and 100; if percentage <= 15, now the population of plague victims is (the population of Ancient Sumeria divided by 2 to the nearest 1 person).

A plague rule: decrease the population of Ancient Sumeria by the population of plague victims.

Finkdom rules is a rulebook.

A finkdom rule: say "You starved [population of peak starvation] in one year!!![line break]Due to this extreme mismanagement you have not only been impeached and thrown out of office, but you have also been declared 'national fink'!!"

A finkdom rule: follow signoff rules.

Vital statistics rules is a rulebook.

A vital statistics rule: now the population of annual starvation is 0 people.

A vital statistics rule: decrease the granary of Ancient Sumeria by the granary of food rations.

A vital statistics rule: let fed be the granary of food rations divided by 20 bushels per person; if (fed < population of Ancient Sumeria), now the population of annual starvation is (population of Ancient Sumeria - fed).

A vital statistics rule: if (population of annual starvation > population of peak starvation), now the population of peak starvation is the population of annual starvation.

A vital statistics rule: if ((population of Ancient Sumeria * 45) < (population of annual starvation * 100)), follow the finkdom rules.

A vital statistics rule: increase the starvation resentment of Ancient Sumeria by (100 * population of annual starvation) / population of Ancient Sumeria.

A vital statistics rule: decrease the population of Ancient Sumeria by the population of annual starvation.

A vital statistics rule: increase the population of total starvation by the population of annual starvation.

A vital statistics rule: increase the population of the underworld by the population of annual starvation.

A vital statistics rule: now the population of annual immigration is 1 person.

A vital statistics rule: increase the population of annual immigration by 1 person times ((a random number from 1 to 5) times ((20 * acreage of Ancient Sumeria / 1 acre) + (granary of Ancient Sumeria / 1 bushel)) / (population of Ancient Sumeria / 1 person)) / 100.

A vital statistics rule: if the population of annual immigration < 0 people, now the population of annual immigration is 0 people.

A vital statistics rule: increase the population of Ancient Sumeria by the population of annual immigration.

A vital statistics rule: increase the population of total immigration by the population of annual immigration.

A vital statistics rule: follow plague rules.

Annual rules is a rulebook.

An annual rule: follow vital statistics rules.

An annual rule: follow agricultural rules.

An annual rule: follow new order rules.

An annual rule: follow land valuation rules.

An annual rule: increase the regnal year of Ancient Sumeria by 1.

When play begins:

now the regnal year of Ancient Sumeria is 1;

now the starvation resentment of Ancient Sumeria is 0;

now the acreage of Ancient Sumeria is 1000 acres;

now the population of Ancient Sumeria is 100 people;

now the granary of Ancient Sumeria is 2800 bushels;

now the population of annual starvation is 0 people;

now the population of peak starvation is 0 people;

now the population of total starvation is 0 people;

now the population of plague victims is 0 people;

now the population of the underworld is 0 people;

now the population of annual immigration is 5 people;

now the population of total immigration is 5 people;

now the grain per land of harvest yield is 3 bushels per acre;

now the granary of rats is 200 bushels;

now the right hand status line is "Year [regnal year of Ancient Sumeria]";

now a verdict is glowing;

follow land valuation rules;

follow new order rules;

say "[story description][line break]".

Understand "buy [an acreage]" as land purchasing.

Land purchasing is an action out of world applying to one acreage.

Carry out land purchasing:

let payment be the acreage understood times the grain per land of land price;

if payment is greater than the granary of Ancient Sumeria, say "The city lacks the required [payment]! You have but [granary of Ancient Sumeria] at your disposal." instead;

if payment is greater than (granary of Ancient Sumeria - granary of food rations - granary of fields sowed), say "The city lacks the required [payment]! There are [granary of Ancient Sumeria] in storage. You have ordered [granary of food rations] to be distributed to feed the people. Ordered plantings will require [granary of fields sowed]." instead;

increase the acreage of Ancient Sumeria by the acreage understood;

say "The city has been expanded to [acreage of Ancient Sumeria].";

decrease the granary of Ancient Sumeria by payment;

say "The granary has been decreased by [payment] to [granary of Ancient Sumeria]."

Understand "sell [an acreage]" as land disbursal.

Land disbursal is an action out of world applying to one acreage.

Carry out land disbursal:

if the acreage understood is greater than the acreage of Ancient Sumeria, say "The city is comprised of but [acreage of Ancient Sumeria]!" instead;

decrease the acreage of Ancient Sumeria by the acreage understood;

say "The city has been reduced to [acreage of Ancient Sumeria].";

let payment be the acreage understood times the grain per land of land price;

increase the granary of Ancient Sumeria by payment;

say "The granary has been increased by [payment] to [granary of Ancient Sumeria]."

Understand "ration [a granary]" as rationing.

Understand "feed [a granary]" as rationing.

Rationing is an action out of world applying to one granary.

Carry out rationing:

if the granary understood is greater than the granary of Ancient Sumeria, say "The city does not have [granary understood]! The city has but [granary of Ancient Sumeria]." instead;

now the granary of food rations is granary understood;

say "It shall be so."

Understand "feed [population]" as feeding.

Feeding is an action out of world applying to one population.

Carry out feeding:

if the population understood is greater than the population of Ancient Sumeria, say "There are but [population of Ancient Sumeria] in the city!" instead;

now the granary of food rations is the population understood times 20 bushels per person;

say "[granary of food rations] shall be set aside for the task."

Understand "feed everyone" as feeding populace.

Feeding populace is an action out of world applying to nothing.

Carry out feeding populace:

now the granary of food rations is the population of Ancient Sumeria times 20 bushels per person;

say "[granary of food rations] shall be set aside for the task."

Understand "sow [an acreage]" as sowing.

Understand "plant [an acreage]" as sowing.

Understand "cultivate [an acreage]" as sowing.

Sowing is an action out of world applying to one acreage.

Carry out sowing:

if the acreage understood is greater than the acreage of Ancient Sumeria, say "The city has but [acreage of Ancient Sumeria]!" instead;

let reach be the population of Ancient Sumeria times area per capita of Ancient Sumeria;

if the acreage understood > reach, say "You have only [population of Ancient Sumeria] to tend the fields! No more than [reach] can be cultivated." instead;

now the acreage of fields sowed is the acreage understood;

let seed required be (acreage of fields sowed + 1 acre) divided by (2 acres per bushel);

now the granary of fields sowed is seed required;

say "It shall be so. [seed required] will be set aside."

Understand "carry on" as annual progression.

Understand "carry out orders" as annual progression.

Understand "make it so" as annual progression.

Annual progression is an action applying to nothing.

Carry out annual progression:

if (granary of fields sowed + granary of food rations) > granary of Ancient Sumeria, say "Please reconsider your orders, as the city does has insufficient grain to carry them out!" instead;

follow the annual rules;

say "[description of Ancient Sumeria][line break]".

Narrative history is an action out of world applying to nothing.

Carry out narrative history:

say "This is an Inform 7 port of a BASIC program titled [italic type]Hamurabi[roman type](sic), which was in turn ported from a FOCAL program titled [italic type]King of Sumeria[roman type], which was in turn recreated from a description of a FORTRAN program written in the 1960s titled [italic type]The Sumerian Game[roman type]. Wikipedia has more details."

Understand "history" as narrative history.

Every turn: if regnal year of Ancient Sumeria > term length of Ancient Sumeria, follow judgment rules.

Judgment rules is a rulebook.

A judgment rule: say "In your [term length of Ancient Sumeria]-year term of office, [starvation resentment of Ancient Sumeria / term length of Ancient Sumeria] percent of the population starved per year on average; i.e., a total of [population of total starvation] died!!"

A judgment rule: say "You started with 10 acres per person and ended with [acreage of Ancient Sumeria divided by population of Ancient Sumeria to the nearest 1 acre per person]."

A judgment rule: now the land rating of Ancient Sumeria is acreage of Ancient Sumeria divided by population of Ancient Sumeria to the nearest 1 acre per person.

A judgment rule: now the starvation rating of Ancient Sumeria is starvation resentment of Ancient Sumeria / term length of Ancient Sumeria.

A judgment rule: if the land rating of Ancient Sumeria < 10 acres per person, now the verdict is ambivalent.

A judgment rule: if the starvation rating of Ancient Sumeria > 3, now the verdict is ambivalent.

A judgment rule: if the land rating of Ancient Sumeria < 9 acres per person, now the verdict is hateful.

A judgment rule: if the starvation rating of Ancient Sumeria > 10, now the verdict is hateful.

A judgment rule: if the land rating of Ancient Sumeria < 7 acres per person, now the verdict is national fink.

A judgment rule: if the starvation rating of Ancient Sumeria > 33, now the verdict is national fink.

A judgment rule: if verdict is glowing, say "A fantastic performance!!! Charlemagne, Disraeli, and Jefferson combined could not have done better!".

A judgment rule: if verdict is hateful, say "Your heavy-handed performance smacks of Nero and Ivan IV. The people (remaining) find you an unpleasant ruler, and, frankly, hate your guts!".

A judgment rule: if verdict is ambivalent, say "Your performance could have been somewhat better, but really wasn't too bad at all. [a random population between 1 person and the population of Ancient Sumeria] would dearly like to see you assassinated, but we all have our trivial problems.".

A judgment rule: if verdict is national fink, say "Due to this extreme mismanagement you have not only been impeached and thrown out of office, but you have also been declared 'national fink'!!".

A judgment rule: follow the signoff rules.

Signoff rules is a rulebook.

A signoff rule: now the description of Ancient Sumeria is "So long for now.".

A signoff rule: end the story.

Understand "help" as help request.

Help request is an action out of world applying to nothing.

Carry out help request:

say "You can buy and sell land at any time:[line break]";

say " [italic type]buy 3 acres[roman type][line break]";

say " [italic type]sell 1 acre[roman type][line break]";

say "You can order food to be set aside to feed the people:[line break]";

say " [italic type]feed 1000 bushels[roman type][line break]";

say " [italic type]feed 50 people[roman type][line break]";

say " [italic type]feed everyone[roman type][line break]";

say "You can order fields to be planted:[line break]";

say " [italic type]plant 1000 acres[roman type][line break]";

say "You can survey the state of the city and review your current orders:[line break]";

say " [italic type]look[roman type][line break]";

say "To continue to the next year:[line break]";

say " [italic type]make it so[roman type][line break]";

say "To see a brief history of this game:[line break]";

say " [italic type]history[roman type][line break]".