10 rem HAMM21.BAS - HAMMURABI game from Creative Computing
  20 rem Program refactored by David Meyer <papa@twenex.org>
  30 rem   January 2012.
  40 print
  50 print tab(27);"H A M M U R A B I"
  60 print
  70 print tab(15);"Creative Computing, Morristown, New Jersey"
  80 print
  90 print
 100 print tab(4);"Try your hand at governing ancient Sumeria ";
 110 print "for a ten year reign."
 120 print
 130 D1=0
 140 P1=0
 150 Z=0
 160 P=95
 170 S=2800
 180 H=3000
 190 E=H-S
 200 Y=3
 210 A=H/Y
 220 I=5
 230 Q=1
 240 D=0
 250 print
 260 print
 270 print "HAMURABI: I BEG TO REPORT TO YOU,"
 280 Z=Z+1
 290 rem 217-218 ==> 221-222
 300 print "IN YEAR";Z;",";D;" PEOPLE STARVED,";I;" CAME TO THE CITY,"
 310 P=P+I
 320 if Q>0 then goto 350
 330 P=INT(P/2)
 340 print "A HORRIBLE PLAGUE STRUCK!  HALF THE PEOPLE DIED."
 350 print "POPULATION IS NOW";P
 360 print "THE CITY NOW OWNS ";A;" ACRES."
 370 print "YOU HARVESTED";Y;" BUSHELS PER ACRE."
 380 print "THE RATS ATE";E;" BUSHELS."
 390 print "YOU NOW HAVE ";S;"  BUSHELS IN STORE."
 400 print
 410 if Z=11 then goto 1410
 420 C=INT(10*RND(1))
 430 Y=C+17
 440 print "LAND IS TRADING AT";Y;"  BUSHELS PER ACRE."
 450 print "HOW MANY ACRES DO YOU WISH TO BUY";
 460 input Q
 470 if Q<0 then goto 1370
 480 rem 322-324 ==> 324-326
 490 if Y*Q<=S then goto 520
 500 gosub 1280
 510 goto 450
 520 if Q=0 then goto 570
 530 A=A+Q
 540 S=S-Y*Q
 550 C=0
 560 goto 670
 570 print "HOW MANY ACRES DO YOU WISH TO SELL";
 580 input Q
 590 if Q<0 then goto 1370
 600 rem 342-344 ==> 344-346
 610 if Q<A then goto 640
 620 gosub 1320
 630 goto 570
 640 A=A-Q
 650 S=S+Y*Q
 660 C=0
 670 print
 680 print "HOW MANY BUSHELS DO YOU WISH TO FEED YOUR PEOPLE";
 690 input Q
 700 if Q<0 then goto 1370
 710 rem *** TRYING TO USE MORE GRAIN THAN IS IN SILOS?
 720 if Q<=S then goto 750
 730 gosub 1280
 740 goto 680
 750 S=S-Q
 760 C=1
 770 print
 780 print "HOW MANY ACRES DO YOU WISH TO PLANT WITH SEED";
 790 input D
 800 if D=0 then goto 960
 810 rem 442,444-447 ==> 444-448
 820 if D<0 then goto 1370
 830 rem *** TRYING TO PLANT MORE ACRES THAN YOU OWN?
 840 if D<=A then goto 880
 850 gosub 1320
 860 goto 780
 870 rem *** ENOUGH GRAIN FOR SEED?
 880 if INT(D/2)<=S then goto 920
 890 gosub 1280
 900 goto 780
 910 rem *** ENOUGH PEOPLE TO TEND THE CROPS?
 920 if D<10*P then goto 950
 930 print "BUT YOU HAVE ONLY";P;"  PEOPLE TO TEND THE FIELDS!  NOW THEN,"
 940 goto 780
 950 S=S-INT(D/2)
 960 gosub 1350
 970 rem *** A BOUNTIFUL HARVEST!
 980 Y=C
 990 H=D*Y
1000 E=0
1010 gosub 1350
1020 if INT(C/2)<>C/2 then goto 1050
1030 rem *** RATS ARE RUNNING WILD!!
1040 E=INT(S/C)
1050 S=S-E+H
1060 gosub 1350
1070 rem *** LET'S HAVE SOME BABIES
1080 I=INT(C*(20*A+S)/P/100+1)
1090 rem *** HOW MANY PEOPLE HAD FULL TUMMIES?
1100 C=INT(Q/20)
1110 rem *** HORROS, A 15% CHANCE OF PLAGUE
1120 Q=INT(10*(2*RND(1)-0.3))
1130 if P<C then goto 240
1140 rem *** STARVE ENOUGH FOR IMPEACHMENT?
1150 D=P-C
1160 if D>0.45*P then goto 1220
1170 rem 553,555 ==> 555-556
1180 P1=((Z-1)*P1+D*100/P)/Z
1190 P=C
1200 D1=D1+D
1210 goto 250
1220 print
1230 print "YOU STARVED";D;"  PEOPLE IN ONE YEAR!!!"
1240 print "DUE TO THIS EXTREME MISMANAGEMENT YOU HAVE NOT ONLY"
1250 print "BEEN IMPEACHED AND THROWN OUT OF OFFICE BUT YOU HAVE"
1260 print "ALSO BEEN DECLARED NATIONAL FINK!!!!"
1270 goto 1650
1280 print "HAMURABI: THINK AGAIN.  YOU HAVE ONLY"
1290 rem 711-712 ==> 713-714
1300 print S;"  BUSHELS OF GRAIN.  NOW THEN,"
1310 return
1320 print "Hammurabi, think again. You own only";A;"acres. Now then,"
1330 
1340 return
1350 C=INT(RND(1)*5)+1
1360 return
1370 print
1380 print "HAMURABI: I CANNOT DO WHAT YOU WISH."
1390 print "GET YOURSELF ANOTHER STEWARD!!!!!"
1400 goto 1650
1410 print "IN YOUR 10-YEAR TERM OF OFFICE,";P1;" PERCENT OF THE"
1420 print "POPULATION STARVED PER YEAR ON THE AVERAGE, I.E. A TOTAL OF"
1430 print D1;"  PEOPLE DIED!!"
1440 L=A/P
1450 print "YOU STARTED WITH 10 ACRES PER PERSON AND ENDED WITH"
1460 print L;"  ACRES PER PERSON."
1470 print
1480 if P1>33 then goto 1240
1490 if L<7 then goto 1240
1500 if P1>10 then goto 1570
1510 if L<9 then goto 1570
1520 if P1>3 then goto 1610
1530 if L<10 then goto 1610
1540 print "A FANTASTIC PERFORMANCE!!!  CHARLEMANGE, DISRAELI, AND"
1550 print "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!"
1560 goto 1650
1570 print "YOUR HEAVY-HANDED PERFORMANCE SMACKS OF NERO AND IVAN IV."
1580 print "THE PEOPLE (REMIANING) FIND YOU AN UNPLEASANT RULER, AND,"
1590 print "FRANKLY, HATE YOUR GUTS!!"
1600 goto 1650
1610 print "YOUR PERFORMANCE COULD HAVE BEEN SOMEWHAT BETTER, BUT"
1620 print "REALLY WASN'T TOO BAD AT ALL. ";INT(P*0.8*RND(1));"PEOPLE"
1630 print "WOULD DEARLY LIKE TO SEE YOU ASSASSINATED BUT WE ALL HAVE OUR"
1640 print "TRIVIAL PROBLEMS."
1650 print
1660 for N=1 to 10
1670   print CHR$(7);
1680   rem 991 ==> 994
1690 next N
1700 print "SO LONG FOR NOW."
1710 print
1720 end