mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-12 07:40:50 -08:00
Added MiniScript version of 43_Hammurabi.
This commit is contained in:
16
00_Alternate_Languages/43_Hammurabi/MiniScript/README.md
Normal file
16
00_Alternate_Languages/43_Hammurabi/MiniScript/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
Original source downloaded from [Vintage Basic](http://www.vintage-basic.net/games.html).
|
||||
|
||||
Conversion to [MiniScript](https://miniscript.org).
|
||||
|
||||
Ways to play:
|
||||
|
||||
1. Command-Line MiniScript:
|
||||
Download for your system from https://miniscript.org/cmdline/, install, and then run the program with a command such as:
|
||||
|
||||
miniscript hammurabi.ms
|
||||
|
||||
2. Mini Micro:
|
||||
Download Mini Micro from https://miniscript.org/MiniMicro/, launch, and then click the top disk slot and chose "Mount Folder..." Select the folder containing the MiniScript program and this README file. Then, at the Mini Micro command prompt, enter:
|
||||
|
||||
load "hammurabi"
|
||||
run
|
||||
190
00_Alternate_Languages/43_Hammurabi/MiniScript/hammurabi.ms
Normal file
190
00_Alternate_Languages/43_Hammurabi/MiniScript/hammurabi.ms
Normal file
@@ -0,0 +1,190 @@
|
||||
print " "*32 + "Hamurabi"
|
||||
print " "*15 + "Creative Computing Morristown, New Jersey"
|
||||
print; print; print
|
||||
print "Try your hand at governing ancient Sumeria"
|
||||
print "for a ten-year term of office."; print
|
||||
|
||||
eol = char(10)
|
||||
|
||||
game = {}
|
||||
game.z = 0 // year
|
||||
game.p = 95
|
||||
game.s = 2800 // bushels in store
|
||||
game.h = 3000
|
||||
game.e = game.h - game.s // bushels eaten by rats
|
||||
game.food = 0 // bushels given to people to eat
|
||||
game.y = 3 // value (in bushels) per acre
|
||||
game.a = game.h / game.y // acres owned
|
||||
game.i = 5 // immigration/births
|
||||
game.d = 0 // how many starved this year
|
||||
game.d1 = 0 // total starved over the whole game
|
||||
game.p1 = 0 // average % of population starved per year
|
||||
game.q = 1 // if negative, then a plague strikes
|
||||
|
||||
startYear = function
|
||||
print; print; print "Hamurabi: I beg to report to you,"
|
||||
game.z += 1
|
||||
print "In year " + game.z + ", " +
|
||||
game.d + " people starved, " +
|
||||
game.i + " came to the city,"
|
||||
game.p += game.i
|
||||
if game.q < 0 then
|
||||
game.p = floor(game.p / 2)
|
||||
print "A horrible plague struck! Half the people died."
|
||||
end if
|
||||
print "Population is now " + game.p + "."
|
||||
print "The city now owns " + game.a + " acres."
|
||||
print "You harvested " + game.y + " bushels per acre."
|
||||
print "The rats ate " + game.e + " bushels."
|
||||
print "You now have " + game.s + " bushels in store."; print
|
||||
end function
|
||||
|
||||
exitGame = function
|
||||
print; print char(7)*10
|
||||
print "So long for now."; print
|
||||
exit
|
||||
end function
|
||||
|
||||
impeach = function
|
||||
print "Due to this extreme mismanagement you have not only"
|
||||
print "been impeached and thrown out of office but you have"
|
||||
print "also been declared national fink!!!!"
|
||||
exitGame
|
||||
end function
|
||||
|
||||
getNumber = function(prompt, max, maxMsg)
|
||||
while true
|
||||
value = input(prompt + "? ").val
|
||||
if value < 0 then
|
||||
print; print "Hamurabi: I cannot do what you wish."
|
||||
print "Get yourself another steward!"
|
||||
exitGame
|
||||
end if
|
||||
if value <= max then return value
|
||||
print "Hamurabi: Think again. " + maxMsg + " Now then,"
|
||||
end while
|
||||
end function
|
||||
|
||||
hint = function(msg)
|
||||
// This was not in the original program. But if you want to make
|
||||
// the game easier, uncomment this line:
|
||||
print msg
|
||||
end function
|
||||
|
||||
min = function(a, b, c)
|
||||
m = [a, b, c]
|
||||
m.sort
|
||||
return m[0]
|
||||
end function
|
||||
|
||||
getDecisions = function
|
||||
// buy/sell land
|
||||
c = floor(10 * rnd); game.y = c + 17
|
||||
print "Land is trading at " + game.y + " bushels per acre."
|
||||
qty = getNumber("How many acres do you wish to buy",
|
||||
floor(game.s / game.y), "You have only" + eol + game.s + " bushels of grain.")
|
||||
if qty > 0 then
|
||||
game.a += qty
|
||||
game.s -= game.y * qty
|
||||
else
|
||||
qty = getNumber("How many acres do you wish to sell",
|
||||
game.a, "You own only" + eol + game.a + " acres.")
|
||||
game.a -= qty
|
||||
game.s += game.y * qty
|
||||
end if
|
||||
|
||||
// feed the people
|
||||
hint "Your people want " + (game.p * 20) + " bushels of food."
|
||||
game.food = getNumber("How many bushels do you wish to feed your people",
|
||||
game.s, "You have only" + eol + game.s + " bushels of grain.")
|
||||
game.s -= game.food
|
||||
|
||||
// planting (a little more complicate because there are THREE limits)
|
||||
hint "You can plant up to " +
|
||||
min(game.a, floor(game.s * 2), floor(game.p*10-1)) + " acres."
|
||||
game.d = 0
|
||||
while game.a > 0 and game.s > 2
|
||||
game.d = getNumber("How many acres do you wish to plant with seed",
|
||||
game.a, "You own only " + game.a + " acres.")
|
||||
// enough grain for seed? (each bushel can plant 2 acres)
|
||||
if floor(game.d / 2) > game.s then
|
||||
print "Hamurabi: Think again. You have only" + eol + game.s +
|
||||
" bushels of grain. Now then,"
|
||||
continue
|
||||
end if
|
||||
// enough people to tend the crops? (each person can tend 10 acres)
|
||||
if game.d >= game.p * 10 then
|
||||
print "But you have only " + game.p + " people to tend the fields! Now then,"
|
||||
continue
|
||||
end if
|
||||
break
|
||||
end while
|
||||
game.s -= floor(game.d / 2)
|
||||
end function
|
||||
|
||||
simulateYear = function
|
||||
// A bountiful harvest!
|
||||
c = floor(rnd * 5) + 1
|
||||
game.y = c; game.h = game.d * game.y; game.e = 0
|
||||
c = floor(rnd * 5) + 1
|
||||
if c % 2 == 0 then
|
||||
// rats are running wild!!
|
||||
game.e = floor(game.s / c)
|
||||
end if
|
||||
game.s += game.h - game.e
|
||||
|
||||
// Let's have some babies
|
||||
c = floor(rnd * 5) + 1
|
||||
game.i = floor(c * (20 * game.a + game.s) / game.p / 100 + 1)
|
||||
// How many people had full tummies?
|
||||
c = floor(game.food / 20)
|
||||
// Horros, a 15% chance of plague
|
||||
game.q = floor(10 * (2 * rnd - 0.3))
|
||||
|
||||
if game.p < c then
|
||||
game.d = 0
|
||||
else
|
||||
// starve enough for impeachment?
|
||||
game.d = game.p - c
|
||||
if game.d > 0.45 * game.p then
|
||||
print; print "You starved " + game.d + " people in one year!!!"
|
||||
impeach
|
||||
end if
|
||||
game.p1 = ((game.z - 1) * game.p1 + game.d * 100 / game.p) / game.z
|
||||
game.p = c
|
||||
game.d1 += game.d
|
||||
end if
|
||||
end function
|
||||
|
||||
printFinalResult = function
|
||||
print "In your 10-year term of office, " + game.p1 + " percent of the"
|
||||
print "population starved per year on the average, i.e., a total of"
|
||||
print game.d1 + " people died!!"
|
||||
acresPer = game.a / game.p
|
||||
print "You started with 10 acres per person and ended with"
|
||||
print acresPer + " acres per person."; print
|
||||
if game.p1 > 33 or acresPer < 7 then impeach
|
||||
if game.p1 > 10 or acresPer < 9 then
|
||||
print "Your heavy-handed performance smacks of Nero and Ivan IV."
|
||||
print "The people (remaining) find you an unpleasant ruler, and,"
|
||||
print "frankly, hate your guts!!"
|
||||
else if game.p1 > 3 or acresPer < 10 then
|
||||
print "Your performance could have been somewhat better, but"
|
||||
print "really wasn't too bad at all. " + floor(game.p * 0.8 * rnd) + " people"
|
||||
print "would dearly like to see you assassinated but we all have our"
|
||||
print "trivial problems."
|
||||
else
|
||||
print "A fantastic performance!! Charlemange, Disraeli, and"
|
||||
print "Jefferson combined could not have done better!"
|
||||
end if
|
||||
end function
|
||||
|
||||
// Main loop
|
||||
while true
|
||||
startYear
|
||||
if game.z == 11 then break
|
||||
getDecisions
|
||||
simulateYear
|
||||
end while
|
||||
printFinalResult
|
||||
exitGame
|
||||
@@ -1,119 +1,119 @@
|
||||
10 PRINT TAB(32);"HAMURABI"
|
||||
20 PRINT TAB(15);"CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
30 PRINT:PRINT:PRINT
|
||||
10 PRINT TAB(32); "HAMURABI"
|
||||
20 PRINT TAB(15); "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
|
||||
30 PRINT : PRINT : PRINT
|
||||
80 PRINT "TRY YOUR HAND AT GOVERNING ANCIENT SUMERIA"
|
||||
90 PRINT "FOR A TEN-YEAR TERM OF OFFICE.":PRINT
|
||||
95 D1=0: P1=0
|
||||
100 Z=0: P=95:S=2800: H=3000: E=H-S
|
||||
110 Y=3: A=H/Y: I=5: Q=1
|
||||
210 D=0
|
||||
215 PRINT:PRINT:PRINT "HAMURABI: I BEG TO REPORT TO YOU,": Z=Z+1
|
||||
217 PRINT "IN YEAR";Z;",";D;"PEOPLE STARVED,";I;"CAME TO THE CITY,"
|
||||
218 P=P+I
|
||||
227 IF Q>0 THEN 230
|
||||
228 P=INT(P/2)
|
||||
90 PRINT "FOR A TEN-YEAR TERM OF OFFICE." : PRINT
|
||||
95 D1 = 0 : P1 = 0
|
||||
100 Z = 0 : P = 95 : S = 2800 : H = 3000 : E = H - S
|
||||
110 Y = 3 : A = H / Y : I = 5 : Q = 1
|
||||
210 D = 0
|
||||
215 PRINT : PRINT : PRINT "HAMURABI: I BEG TO REPORT TO YOU," : Z = Z + 1
|
||||
217 PRINT "IN YEAR "; Z; ","; D; " PEOPLE STARVED, "; I; " CAME TO THE CITY,"
|
||||
218 P = P + I
|
||||
227 IF Q > 0 THEN 230
|
||||
228 P = INT(P / 2)
|
||||
229 PRINT "A HORRIBLE PLAGUE STRUCK! HALF THE PEOPLE DIED."
|
||||
230 PRINT "POPULATION IS NOW";P
|
||||
232 PRINT "THE CITY NOW OWNS ";A;"ACRES."
|
||||
235 PRINT "YOU HARVESTED";Y;"BUSHELS PER ACRE."
|
||||
250 PRINT "THE RATS ATE";E;"BUSHELS."
|
||||
260 PRINT "YOU NOW HAVE ";S;"BUSHELS IN STORE.": PRINT
|
||||
270 IF Z=11 THEN 860
|
||||
310 C=INT(10*RND(1)): Y=C+17
|
||||
312 PRINT "LAND IS TRADING AT";Y;"BUSHELS PER ACRE."
|
||||
230 PRINT "POPULATION IS NOW "; P
|
||||
232 PRINT "THE CITY NOW OWNS "; A; " ACRES."
|
||||
235 PRINT "YOU HARVESTED "; Y; " BUSHELS PER ACRE."
|
||||
250 PRINT "THE RATS ATE "; E; " BUSHELS."
|
||||
260 PRINT "YOU NOW HAVE "; S; " BUSHELS IN STORE." : PRINT
|
||||
270 IF Z = 11 THEN 860
|
||||
310 C = INT(10 * RND(1)) : Y = C + 17
|
||||
312 PRINT "LAND IS TRADING AT "; Y; " BUSHELS PER ACRE."
|
||||
320 PRINT "HOW MANY ACRES DO YOU WISH TO BUY";
|
||||
321 INPUT Q: IF Q<0 THEN 850
|
||||
322 IF Y*Q<=S THEN 330
|
||||
321 INPUT Q : IF Q < 0 THEN 850
|
||||
322 IF Y * Q <= S THEN 330
|
||||
323 GOSUB 710
|
||||
324 GOTO 320
|
||||
330 IF Q=0 THEN 340
|
||||
331 A=A+Q: S=S-Y*Q: C=0
|
||||
330 IF Q = 0 THEN 340
|
||||
331 A = A + Q : S = S - Y * Q : C = 0
|
||||
334 GOTO 400
|
||||
340 PRINT "HOW MANY ACRES DO YOU WISH TO SELL";
|
||||
341 INPUT Q: IF Q<0 THEN 850
|
||||
342 IF Q<A THEN 350
|
||||
341 INPUT Q : IF Q < 0 THEN 850
|
||||
342 IF Q < A THEN 350
|
||||
343 GOSUB 720
|
||||
344 GOTO 340
|
||||
350 A=A-Q: S=S+Y*Q: C=0
|
||||
400 PRINT
|
||||
350 A = A - Q : S = S + Y * Q : C = 0
|
||||
400 PRINT
|
||||
410 PRINT "HOW MANY BUSHELS DO YOU WISH TO FEED YOUR PEOPLE";
|
||||
411 INPUT Q
|
||||
412 IF Q<0 THEN 850
|
||||
412 IF Q < 0 THEN 850
|
||||
418 REM *** TRYING TO USE MORE GRAIN THAN IS IN SILOS?
|
||||
420 IF Q<=S THEN 430
|
||||
420 IF Q <= S THEN 430
|
||||
421 GOSUB 710
|
||||
422 GOTO 410
|
||||
430 S=S-Q: C=1: PRINT
|
||||
430 S = S - Q : C = 1 : PRINT
|
||||
440 PRINT "HOW MANY ACRES DO YOU WISH TO PLANT WITH SEED";
|
||||
441 INPUT D: IF D=0 THEN 511
|
||||
442 IF D<0 THEN 850
|
||||
441 INPUT D : IF D = 0 THEN 511
|
||||
442 IF D < 0 THEN 850
|
||||
444 REM *** TRYING TO PLANT MORE ACRES THAN YOU OWN?
|
||||
445 IF D<=A THEN 450
|
||||
445 IF D <= A THEN 450
|
||||
446 GOSUB 720
|
||||
447 GOTO 440
|
||||
449 REM *** ENOUGH GRAIN FOR SEED?
|
||||
450 IF INT(D/2)<=S THEN 455
|
||||
450 IF INT(D / 2) <= S THEN 455
|
||||
452 GOSUB 710
|
||||
453 GOTO 440
|
||||
454 REM *** ENOUGH PEOPLE TO TEND THE CROPS?
|
||||
455 IF D<10*P THEN 510
|
||||
460 PRINT "BUT YOU HAVE ONLY";P;"PEOPLE TO TEND THE FIELDS! NOW THEN,"
|
||||
455 IF D < 10 * P THEN 510
|
||||
460 PRINT "BUT YOU HAVE ONLY "; P; " PEOPLE TO TEND THE FIELDS! NOW THEN,"
|
||||
470 GOTO 440
|
||||
510 S=S-INT(D/2)
|
||||
510 S = S - INT(D / 2)
|
||||
511 GOSUB 800
|
||||
512 REM *** A BOUNTIFUL HARVEST!
|
||||
515 Y=C: H=D*Y: E=0
|
||||
515 Y = C : H = D * Y : E = 0
|
||||
521 GOSUB 800
|
||||
522 IF INT(C/2)<>C/2 THEN 530
|
||||
522 IF INT(C / 2) <> C / 2 THEN 530
|
||||
523 REM *** RATS ARE RUNNING WILD!!
|
||||
525 E=INT(S/C)
|
||||
530 S=S-E+H
|
||||
525 E = INT(S / C)
|
||||
530 S = S - E + H
|
||||
531 GOSUB 800
|
||||
532 REM *** LET'S HAVE SOME BABIES
|
||||
533 I=INT(C*(20*A+S)/P/100+1)
|
||||
533 I = INT(C *(20 * A + S) / P / 100 + 1)
|
||||
539 REM *** HOW MANY PEOPLE HAD FULL TUMMIES?
|
||||
540 C=INT(Q/20)
|
||||
540 C = INT(Q / 20)
|
||||
541 REM *** HORROS, A 15% CHANCE OF PLAGUE
|
||||
542 Q=INT(10*(2*RND(1)-.3))
|
||||
550 IF P<C THEN 210
|
||||
542 Q = INT(10 *(2 * RND(1) - 0.3))
|
||||
550 IF P < C THEN 210
|
||||
551 REM *** STARVE ENOUGH FOR IMPEACHMENT?
|
||||
552 D=P-C: IF D>.45*P THEN 560
|
||||
553 P1=((Z-1)*P1+D*100/P)/Z
|
||||
555 P=C: D1=D1+D: GOTO 215
|
||||
560 PRINT: PRINT "YOU STARVED";D;"PEOPLE IN ONE YEAR!!!"
|
||||
552 D = P - C : IF D > 0.45 * P THEN 560
|
||||
553 P1 =((Z - 1) * P1 + D * 100 / P) / Z
|
||||
555 P = C : D1 = D1 + D : GOTO 215
|
||||
560 PRINT : PRINT "YOU STARVED "; D; " PEOPLE IN ONE YEAR!!!"
|
||||
565 PRINT "DUE TO THIS EXTREME MISMANAGEMENT YOU HAVE NOT ONLY"
|
||||
566 PRINT "BEEN IMPEACHED AND THROWN OUT OF OFFICE BUT YOU HAVE"
|
||||
567 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!": GOTO 990
|
||||
567 PRINT "ALSO BEEN DECLARED NATIONAL FINK!!!!" : GOTO 990
|
||||
710 PRINT "HAMURABI: THINK AGAIN. YOU HAVE ONLY"
|
||||
711 PRINT S;"BUSHELS OF GRAIN. NOW THEN,"
|
||||
712 RETURN
|
||||
720 PRINT "HAMURABI: THINK AGAIN. YOU OWN ONLY";A;"ACRES. NOW THEN,"
|
||||
730 RETURN
|
||||
800 C=INT(RND(1)*5)+1
|
||||
801 RETURN
|
||||
850 PRINT: PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH."
|
||||
711 PRINT S; "BUSHELS OF GRAIN. NOW THEN,"
|
||||
712 RETURN
|
||||
720 PRINT "HAMURABI: THINK AGAIN. YOU OWN ONLY "; A; " ACRES. NOW THEN,"
|
||||
730 RETURN
|
||||
800 C = INT(RND(1) * 5) + 1
|
||||
801 RETURN
|
||||
850 PRINT : PRINT "HAMURABI: I CANNOT DO WHAT YOU WISH."
|
||||
855 PRINT "GET YOURSELF ANOTHER STEWARD!!!!!"
|
||||
857 GOTO 990
|
||||
860 PRINT "IN YOUR 10-YEAR TERM OF OFFICE,";P1;"PERCENT OF THE"
|
||||
860 PRINT "IN YOUR 10-YEAR TERM OF OFFICE,"; P1; "PERCENT OF THE"
|
||||
862 PRINT "POPULATION STARVED PER YEAR ON THE AVERAGE, I.E. A TOTAL OF"
|
||||
865 PRINT D1;"PEOPLE DIED!!": L=A/P
|
||||
865 PRINT D1; "PEOPLE DIED!!" : L = A / P
|
||||
870 PRINT "YOU STARTED WITH 10 ACRES PER PERSON AND ENDED WITH"
|
||||
875 PRINT L;"ACRES PER PERSON.": PRINT
|
||||
880 IF P1>33 THEN 565
|
||||
885 IF L<7 THEN 565
|
||||
890 IF P1>10 THEN 940
|
||||
892 IF L<9 THEN 940
|
||||
895 IF P1>3 THEN 960
|
||||
896 IF L<10 THEN 960
|
||||
875 PRINT L; "ACRES PER PERSON." : PRINT
|
||||
880 IF P1 > 33 THEN 565
|
||||
885 IF L < 7 THEN 565
|
||||
890 IF P1 > 10 THEN 940
|
||||
892 IF L < 9 THEN 940
|
||||
895 IF P1 > 3 THEN 960
|
||||
896 IF L < 10 THEN 960
|
||||
900 PRINT "A FANTASTIC PERFORMANCE!!! CHARLEMANGE, DISRAELI, AND"
|
||||
905 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!":GOTO 990
|
||||
905 PRINT "JEFFERSON COMBINED COULD NOT HAVE DONE BETTER!" : GOTO 990
|
||||
940 PRINT "YOUR HEAVY-HANDED PERFORMANCE SMACKS OF NERO AND IVAN IV."
|
||||
945 PRINT "THE PEOPLE (REMAINING) FIND YOU AN UNPLEASANT RULER, AND,"
|
||||
950 PRINT "FRANKLY, HATE YOUR GUTS!!":GOTO 990
|
||||
950 PRINT "FRANKLY, HATE YOUR GUTS!!" : GOTO 990
|
||||
960 PRINT "YOUR PERFORMANCE COULD HAVE BEEN SOMEWHAT BETTER, BUT"
|
||||
965 PRINT "REALLY WASN'T TOO BAD AT ALL. ";INT(P*.8*RND(1));"PEOPLE"
|
||||
965 PRINT "REALLY WASN'T TOO BAD AT ALL. "; INT(P * 0.8 * RND(1)); "PEOPLE"
|
||||
970 PRINT "WOULD DEARLY LIKE TO SEE YOU ASSASSINATED BUT WE ALL HAVE OUR"
|
||||
975 PRINT "TRIVIAL PROBLEMS."
|
||||
990 PRINT: FOR N=1 TO 10: PRINT CHR$(7);: NEXT N
|
||||
995 PRINT "SO LONG FOR NOW.": PRINT
|
||||
999 END
|
||||
990 PRINT : FOR N = 1 TO 10 : PRINT CHR$(7); : NEXT N
|
||||
995 PRINT "SO LONG FOR NOW." : PRINT
|
||||
999 END
|
||||
@@ -23,8 +23,7 @@ http://www.vintage-basic.net/games.html
|
||||
|
||||
#### Porting Notes
|
||||
|
||||
(please note any difficulties or challenges in porting here)
|
||||
|
||||
- Though the file name and README both spell "Hammurabi" with two M's, the program itself consistently uses only one M.
|
||||
|
||||
#### External Links
|
||||
- C: https://github.com/beyonddream/hamurabi
|
||||
|
||||
Reference in New Issue
Block a user