Играем в Hammurabi
2023-07-10 20:37Буду постепенно выкладывать примеры игр из упомянутой книжки.
Hammurabi это повторение на языке Питон исторически первой текстовой игры The Sumerian Game 1962 года. У древних игр обычно есть много реализаций, но я собираюсь искать и показывать опенсорсные версии.
Скачиваем, запускаем:
Hammurabi это повторение на языке Питон исторически первой текстовой игры The Sumerian Game 1962 года. У древних игр обычно есть много реализаций, но я собираюсь искать и показывать опенсорсные версии.
Скачиваем, запускаем:
$ wget https://github.com/wzhishen/hammurabi/blob/master/hammurabi.py
$ python2 -i hammurabi.py
>>> hammurabi()
Congratulations, you are the newest ruler of ancient Samaria, elected
for a ten year term of office. Your duties are to dispense food, direct
farming, and buy and sell land as needed to support your people. Watch
out for rat infestations and the plague! Grain is the general currency,
measured in bushels. The following will help you in your decisions:
* Each person needs at least 20 bushels of grain per year to survive.
* Each person can farm at most 10 acres of land.
* It takes 2 bushels of grain to farm an acre of land.
* The market price for land fluctuates yearly.
Rule wisely and you will be showered with appreciation at the end of
your term. Rule poorly and you will be kicked out of office!
O great Hammurabi!
You are in year 1 of your ten year rule.
In the previous year 0 people starved to death.
In the previous year 5 people entered the kingdom.
The population is now 100.
We harvested 3000 bushels at 3 bushels per acre.
Rats destroyed 200 bushels, leaving 2800 bushels in storage.
The city owns 1000 acres of land.
Land is currently worth 19 bushels per acre.
There were 0 deaths from the plague.
How many acres of land will you buy? (0 to DECLINE)
1
How many bushels of grain will you feed to the people?
2000
How many acres of land will you plant with seed?
1000
O great Hammurabi, we have but 781 bushels to spend farming the land!
1000 acres are too many for us! We lack enough bushels to start our farming!
Please factor our funds. Again, how much land will you plant with seed?
[HINT: The maximum possible acres of current total funds to spend farming is 390 acres.]
390
***Thank God! No plague this year***
***O brilliant Hammurabi! This year we have NO people starved***
***O great Hammurabi, this year 3 immigrants come to our kingdom***
***O great Hammurabi, this year we harvest 1950 bushels of grain***
***O great Hammurabi, unluckily a horrible RAT INFESTATION happened! 546 bushels of grain were destroyed***
***O great Hammurabi, the price of land will be 19 bushels per acre next year***
O great Hammurabi!
You are in year 2 of your ten year rule.
In the previous year 0 people starved to death.
In the previous year 3 people entered the kingdom.
The population is now 103.
We harvested 1950 bushels at 5 bushels per acre.
Rats destroyed 546 bushels, leaving 1405 bushels in storage.
The city owns 1001 acres of land.
Land is currently worth 19 bushels per acre.
There were 0 deaths from the plague.
How many acres of land will you buy? (0 to DECLINE)
_

no subject
Date: 2023-07-11 05:34 (UTC)no subject
Date: 2023-07-11 06:08 (UTC)https://github.com/fruitnuke/retro/blob/master/dukedom/dukedom.py
https://en.wikipedia.org/wiki/Dukedom_(video_game)
no subject
Date: 2023-07-11 06:40 (UTC)Эта, судя по фразам, чуть расширена по сравнению с тем, что у нас было.
Dukedom was written in PL/I D by Vince Talbot in 1976 as an expanded version of Kingdom
Видимо, надо искать Kingdom.
Также в Hamurabi пишут A conversion of this game was included on the BBC Micro's Welcome Tape and Welcome Disc as Yellow River Kingdom (1981). "Yellow River" (в received pronunciation) несколько созвучно с "Эйфория", что наводит на мысли.
no subject
Date: 2023-07-11 20:48 (UTC)no subject
Date: 2023-07-11 21:13 (UTC)http://www.bbcmicro.co.uk/explore.php?id=1996
10 REM KINGDOM/Yellow River Kingdom 12 REM Program by Tom Hartley and Jerry Temple-Fry (NETHERHALL SCHOOL) and Richard G Warner 13 REM Version 5 - October 1981 14 REM For BBC Model A Microcomputer 16K Minimum 40 ON ERROR GOTO50 50 MODE7 60 CLS:ON ERROR GOTO800 100 PROCVARIABLE:PROCTITLEPAGE 110 PROCINSTRUCTIONS 200 F=5000+RND(2000) 210 P=300+RND(100) 220 J=0:S=0 300 S=S+1:IF S=4 THEN S=1 310 J=J+1:Y=(J-1) DIV 3 +1 320 PROCNEWSEASON 330 FOR V=1 TO 3:FL(V)=0:NEXT 340 TD=0:TF=0:FD=0:FF=0:VF=0 350 PROCMAP:PROCDBL(S$(S)+" Season Year "+STR$(Y),1,1) 360 IF RND(2)=1 THEN 380 370 PROCFLOOD:PROCATTACK:GOTO400 380 PROCATTACK:PROCFLOOD 400 PROCCALCULATE 410 PROCENDSEASON 440 IF P=0 OR F=0 THEN 500 450 IF J MOD 12 =0 THEN PROCRITUAL:IF Y%=0 THEN 500 460 IF P<200 AND RND(3)=1 THEN PROCADDTHIEVES 470 P=INT(P*1.045):GOTO300 500 VDU26:CLS:PRINTTAB(0,9) 510 PRINT"Press the RETURN key to start again."' 520 PRINT"Press the ESCAPE key to leave the"'"program." 530 REPEAT UNTIL GET$=CHR$(13):GOTO200 800 IF ERR<>17 THEN REPORT:PRINT" in line ";ERL:END 900 VDU26:CLS 910 PRINTTAB(5,9); 920 PRINT"Do you want to go on to" 930 PRINT" the next program (Y/N)? "; 940 PROCYESORNO:IF Y%<0 THEN 910 950 IF Y%=0 THEN CLEAR:GOTO100 970 PRINT '"BIORHYTHMS WOULD BE THE NEXT PROGRAM.":END 1000 DEFPROCMAP 1010 VDU26:CLS:PRINT'' 1020 FOR I=3 TO 23 1030 PRINTY$;W$;CHR$(&96);"55";Y$;TAB(27);R$ 1040 NEXT 1050 FOR I=3 TO 21 STEP 2 1060 PRINTTAB(28,I);" x ";TAB(28,I+1);"x";CHR$(255);"~x x" 1070 PRINTTAB(33,I+2);"x";CHR$(255);"~x"; 1080 NEXT 1100 FOR I=13 TO 15:PRINTTAB(30,I);" " 1110 NEXT 1120 PRINTTAB(30,14);"THIEVES";TAB(31,13);"TT";TAB(31,15);"T";TAB(32,16);"T";TAB(32,17);"T" 1200 PRINTTAB(0,23);" DYKE VILLAGES MOUNTAINS"; 1210 FOR V=1 TO 3:PROCVDRAW(V):NEXT 1299 ENDPROC 1500 DEFPROCVDRAW(V) 1510 PRINTTAB(VX(V)-2,VY(V));V$;"^&";Y$TAB(VX(V)-2,VY(V)+1);V$;"&^";Y$ 1599 ENDPROC 2000 DEFPROCINSTRUCTIONS 2010 PROCYELLOW:PRINT''' 2020 PRINT"The kingdom is three villages. It"'"is between the Yellow River and"'"the mountains." 2030 PRINT'"You have been chosen to take"'"all the important decisions. Your "'"poor predecessor was executed by"'"thieves who live in the nearby"'"mountains." 2040 PRINT'"These thieves live off the "'"villagers and often attack. The"'"rice stored in the villages must"'"be protected at all times." 2090 PROCSPACE 2100 CLS:PRINT'' 2110 PRINT"The year consists of three long "'"seasons, Winter, Growing and"'"Harvest. Rice is planted every"'"Growing Season. You must decide"'"how much is planted." 2120 PRINT'"The river is likely to flood the"'"fields and the villages. The high"'"dyke between the river and the"'"fields must be kept up to prevent"'"a serious flood." 2130 PRINT'"The people live off the rice that"'"they have grown. It is a very poor"'"living. You must decide what the"'"people will work at each season"'"so that they prosper under your"'"leadership." 2190 PROCSPACE 2199 ENDPROC 3000 DEFPROCNEWSEASON 3010 PROCYELLOW:PRINTTAB(8,1);"Census Results"':IF J=1 THEN 3050 3020 PRINT"At the start of the ";S$(S);" Season" 3030 PRINT"of year ";Y;" of your reign this is" 3040 PRINT"the situation.":GOTO3100 3050 PRINT"You have inherited this situation" 3060 PRINT"from your unlucky predecessor. It" 3070 PRINT"is the start of the Winter Season." 3100 PRINT'"Allowing for births and deaths," 3110 PRINT"the population is ";P;". "' 3120 PRINT"There are ";F;" baskets of rice" 3130 PRINT"in the village stores." 3140 PRINT'"How many people should:" 3150 PRINT" A) Defend the dyke......" 3160 PRINT" B) Work in the fields..." 3170 PRINT" C) Protect the villages." 3200 QU=14:A=0 3210 PRINTTAB(26,QU);:NI=FNNUMINP 3220 IF A+NI>P THEN PROCIMPOS:GOTO3210 3230 QU=QU+1:IF QU=16 THEN B=NI:GOTO3260 3240 A=NI:IF A<P THEN 3210 3250 B=0:PRINTTAB(26,QU);B:QU=16 3260 C=P-(A+B):PRINTTAB(26,QU);C 3300 IF S<>2 THEN 3390 3310 PRINT'"How many baskets of rice will be" 3320 PRINT"planted in the fields....." 3330 PRINTTAB(26,19);:G=FNNUMINP 3340 IF G>F THEN PROCIMPOS:GOTO3330 3350 F=F-G 3390 PROCSPACE 3399 ENDPROC 3500 DEFPROCENDSEASON 3510 PROCWAIT(1) 3520 IF F>0 THEN 3600 3530 CLS:PRINTTAB(3,7);"There was no food left.All of the" 3540 PRINT" people have run off and joined up" 3550 PRINT" with the thieves after ";J;" seasons" 3560 PRINT" of your misrule":PROCSPACE:ENDPROC 3600 IF P>0 THEN 3700 3610 CLS:PRINTTAB(2,8);"There is no-one left! They have all" 3620 PRINT" been killed off by your decisions " 3630 PRINT" after only ";Y;" year";:IF Y<>1 THEN PRINT"s"; 3640 PRINT".":PROCSPACE:ENDPROC 3700 F1=P/(FD+TD+ST+1):F2=F/(TF+FF+1):IF F2<F1 THEN F1=F2 3720 IF F2<2 THEN T$="Disastrous Losses!":GOTO3800 3730 IF F1<4 THEN T$="Worrying losses!":GOTO3800 3740 IF F1<8 THEN T$="You got off lightly!":GOTO3800 3750 IF F/P<4 THEN T$="Food supply is low.":GOTO3800 3760 IF F/P<2 THEN T$="Starvation Imminent!":GOTO3800 3770 IF ZA+ZF+ST>0 THEN T$="Nothing to worry about.":GOTO3800 3780 PROCDBL(" A quiet season ",1,11) 3790 PROCWAIT(2):ENDPROC 3800 PROCYELLOW:PRINTTAB(3,2);"Village Leader's Report" 3810 PRINT'TAB(15-LEN(T$)/2);CHR$(&88);T$ 3820 PRINT'"In the ";S$(S);" Season of year ";Y 3830 PRINT"of your reign, the kingdom has" 3840 PRINT"suffered these losses:"' 3900 PRINT"Deaths from floods..........";FD 3910 PRINT"Deaths from the attacks.....";TD 3920 PRINT"Deaths from starvation......";ST 3930 PRINT"Baskets of rice"'"lost during the floods......";FF 3940 PRINT"Baskets of rice"'"lost during the attacks.....";TF 3950 PRINT'"The village census follows." 3990 PROCSPACE 3999 ENDPROC 4000 DEFPROCADDTHIEVES 4010 PROCYELLOW:PRINTTAB(0,8) 4020 PRINT"Thieves have come out of the" 4030 PRINT"mountain to join you. They" 4040 PRINT"have decided that it will be" 4050 PRINT"easier to grow the rice than" 4060 PRINT"to steal it!":PROCSPACE 4070 P=P+50+RND(100) 4099 ENDPROC 4500 DEFPROCRITUAL 4510 PROCYELLOW:PRINT'' 4520 PRINT"We have survived for ";Y;" years" 4530 PRINT"under your glorious control." 4540 PRINT"By an ancient custom we must" 4550 PRINT"offer you the chance to lay" 4560 PRINT"down this terrible burden and" 4570 PRINT"resume a normal life." 4600 PRINT'"In the time honoured fashion" 4610 PRINT"I will now ask the ritual" 4620 PRINT"question:"':PROCWAIT(5) 4630 PRINT"Are you prepared to accept" 4640 PRINT"the burden of decision again?"' 4650 PRINT"You need only answer Yes or No" 4660 PRINT"for the people will understand"'"your reasons." 4670 PRINTTAB(0,21);:PROCYESORNO:IF Y%<0 THEN 4670 4699 ENDPROC 5000 DEFPROCATTACK 5010 LOCALX,Y,I 5020 ZA=0:R=RND(1):ON S GOTO5030,5040,5050 5030 IF R<.5 THEN ENDPROC ELSE 5060 5040 IF R<.2 THEN ENDPROC ELSE 5060 5050 IF R<.6 THEN ENDPROC ELSE 5060 5060 ZA=1 5070 IF VF=3 THEN ENDPROC 5100 V=RND(3):IF FL(V)=1 THEN 5100 5110 X=32:WX=VX(V):WY=VY(V)-1 5120 IF WY<17 THEN Y=13:D=-1 ELSE Y=17:D=1 5130 SY=Y 5140 PRINTTAB(X,Y);" ":IF Y=WY THEN 5160 5150 Y=Y+D:PRINTTAB(X,Y);"T":PROCWAIT(.05):GOTO5140 5160 X=X-1:PRINTTAB(X-1,Y);R$;"T":PROCWAIT(1-(X-WX)/5) 5170 PRINTTAB(X,Y);:IF X=29 THEN PRINT"x" ELSE PRINT" " 5180 IF X>WX THEN 5160 5200 FOR I=1 TO 99 5210 PRINTTAB(X,Y+1);CHR$(RND(94)+32):NEXT 5220 PROCVDRAW(V) 5300 X=X+1:IF X<27 THEN PRINTTAB(X-2,Y);" " 5310 IF X=31 THEN PRINTTAB(29,Y);"x" 5320 PRINTTAB(X-1,Y);R$;"T":PROCWAIT(.04) 5330 IF X<32 THEN 5300 5340 IF Y=SY THEN 5400 5350 PRINTTAB(X,Y);" ":Y=Y-D:PRINTTAB(X,Y);"T":PROCWAIT(.05):GOTO5340 5400 ON S GOTO 5410,5420,5430 5410 I=200+RND(70)-C:GOTO5440 5420 I=30+RND(200)-C:GOTO5440 5430 I=RND(400)-C 5440 I=INT(I):IF I<0 THEN I=0 5450 TD=INT(C*I/400):C=C-TD 5460 TF=INT(I*F/729+RND(2000-C)/10):IF TF<0 THEN TF=0 5470 IF TF>2000 THEN TF=1900+RND(200) 5480 F=F-TF 5499 ENDPROC 5500 DEFPROCFLOOD 5510 LOCALX,Y 5520 ZF=0:ON S GOTO 5530,5540,5550 5530 FS=RND(330)/(A+1):GOTO5560 5540 FS=(RND(100)+60)/(A+1):GOTO5560 5550 ENDPROC 5560 IF FS<1 THEN ENDPROC 5570 X=6:ZF=1:Y=RND(8)+10:IF FS<2 THEN FS=RND(2) ELSE FS=RND(4) 5600 PRINTTAB(1,Y);W$;W$;W$;W$;W$;W$ 5610 FOR K=1 TO FS*100 5620 ON RND(4) GOTO5630,5640,5650,5660 5630 IF X=25 THEN 5620 ELSE X=X+1:GOTO5700 5640 IF X=6 THEN 5620 ELSE X=X-1:GOTO5700 5650 IF Y=22 THEN 5620 ELSE Y=Y+1:GOTO5700 5660 IF Y=3 THEN 5620 ELSE Y=Y-1:GOTO5700 5700 V=1 5720 W1=VX(V)-X:W2=Y-VY(V) 5730 IF W2<>1 AND W2<>0 THEN 5760 5740 IF W1=0 OR W1=1 THEN FL(V)=1 5750 IF W1=-1 THEN 5780 5760 V=V+1:IF V<4 THEN 5720 5770 PRINTTAB(X,Y);W$ 5780 NEXTK 5790 VF=FL(1)+FL(2)+FL(3) 5800 OP=A+B+C 5810 A=INT((A/10)*(10-FS)) 5820 B=INT((B/10)*(10-FS)) 5830 C=INT((C/6)*(6-VF)) 5840 FF=INT(F*VF/6):F=F-FF 5850 FD=OP-A-B-C 5860 IF S=2 THEN G=G*(20-FS)/20 5870 IF S=3 THEN G=G*(10-FS)/10 5899 ENDPROC 6000 DEFPROCCALCULATE 6010 IF B=0 THEN G=0:GOTO6100 6020 ON S GOTO 6100,6030,6050 6030 IF G>1000 THEN G=1000 6040 G=G*(B-10)/B:GOTO6100 6050 IF G<0 THEN 6100 6060 G=18*(11+RND(3))*(0.05-1/B)*G 6070 IF G<0 THEN 6100 6080 F=F+INT(G) 6100 ST=0:P=A+B+C:IF P=0 THEN 6299 6110 T=F/P:IF T>5 THEN T=4:GOTO6200 6120 IF T<2 THEN P=0:GOTO6299 6130 IF T>4 THEN T=3.5:GOTO6200 6140 ST=INT(P*(7-T)/7):T=3 6200 P=P-ST:F=INT(F-P*T-ST*T/2) 6210 IF F<0 THEN F=0 6299 ENDPROC 7000 DEFPROCVARIABLE 7010 DIM S$(3),VX(3),VY(3),FL(3) 7020 S$(1)="Winter":S$(2)="Growing":S$(3)="Harvest" 7040 W$=CHR$(255):Y$=CHR$(&93):R$=CHR$(&91):V$=CHR$(&92) 7050 VX(1)=13:VY(1)=8 7060 VX(2)=21:VY(2)=12 7070 VX(3)=22:VY(3)=18 7099 ENDPROC 7100 DEFPROCIMPOS 7110 PRINTTAB(4,20);CHR$(&88);CHR$(&82);"I M P O S S I B L E" 7120 PROCWAIT(2) 7130 PROCSPACE 7140 PRINTTAB(5,20);SPC(20);TAB(0,22);SPC(40) 7199 ENDPROC 7200 DEFPROCYELLOW 7210 LOCALI 7220 CLS:FOR I=0 TO 24 7230 PRINTTAB(0,I);CHR$(&83);:NEXT 7240 PRINTTAB(0,0); 7250 VDU 28,3,24,39,0 7299 ENDPROC 8000 DEFPROCDBL(X$,X,Y) 8010 PRINTTAB(X-1,Y);CHR$(141);X$ 8020 PRINTTAB(X-1,Y+1);CHR$(141);X$ 8099 ENDPROC 8100 DEFPROCWAIT(X) 8110 LOCAL Z 8120 Z=TIME 8130 REPEAT UNTIL TIME-Z>X*100 8199 ENDPROC 8200 DEFPROCSPACE 8220 PRINTTAB(0,22);"Press the SPACE BAR to continue";:PROCKCL 8240 REPEAT UNTIL GET$=" " 8299 ENDPROC 8300 DEFPROCTITLEPAGE 8310 PROCMAP:PROCOFF:PROCWAIT(2):PRINTTAB(0,11);SPC(200) 8315PROCDBL(Y$+"YELLOW RIVER",11,11):PROCDBL(Y$+"KINGDOM",13,14) 8320 I%=INKEY(500) 8399 ENDPROC 8800 DEFPROCKCL 8810 IF INKEY$(0)>"" THEN 8810 8899 ENDPROC 8900 DEFPROCOFF 8910 VDU23;8202;0;0;0;:ENDPROC 8950 DEFPROCON 8960 VDU23;29194;0;0;0;:ENDPROC 9000 DEFPROCGPI(F2,ML):REM General Purpose Input Routine 9010 LOCALB,B$ 9020 A$="" 9030 PRINTSTRING$(ML," ");STRING$(ML+1,CHR$(8));CHR$(&83);:PROCON:PROCKCL 9040 B$=GET$:B=ASC(B$):IF B=13 THEN 9190 9050 IF B=127 AND A$="" THEN 9040 9060 IF B=127 THEN A$=LEFT$(A$,LEN(A$)-1):PRINTB$;:GOTO9040 9070 IF LEN(A$)=ML OR B<32 OR B>126 THEN 9170 9080 IF F2=0 OR B=32 OR (B>=48 AND B<=57) THEN 9180 9170 VDU7:GOTO9040 9180 PRINTB$;:A$=A$+B$:GOTO9040 9190 PROCOFF 9199 ENDPROC 9200 DEFPROCYESORNO 9210 LOCALB$ 9220 PROCGPI(0,3) 9230 B$=LEFT$(A$,1) 9240 Y%=-1 9250 IF B$="Y" OR B$="y" THEN Y%=1 9260 IF B$="N" OR B$="n" THEN Y%=0 9299 ENDPROC 9300 DEFFNNUMINP 9310 PROCGPI(1,6) 9320 =VAL(A$)no subject
Date: 2023-07-11 21:19 (UTC)Интересно, что "Euphoria Kingdom" - очень популярное название для игр и посейчас, так что поиск весь замусорен.
no subject
Date: 2023-07-11 21:26 (UTC)населена роботами.Значит, рабочая версия, что "Эйфория" - это перевод какой-то из версий Dukedom, плюс-минус мелочи перевода (напр., в русской версии "Мыши наводнили ваши амбары", а в английских везде rats) или мелкие сокращения (скажем, я не помню в русском варианте персонажа "High King").