1000 PRINT "THE KINGDOM OF EUPHORIA"
     PRINT
     GOSUB 3510
     REM PRINT STATE OF THE KINGDOM
1110 PRINT
     PRINT "YEAR ";Y/7
     PRINT "POPULATION: ";P
     IF B>0 THEN PRINT B;" BIRTHS"
     IF D>0 THEN PRINT D;" DEATHS BY NATURAL CAUSES"
     IF S>0 THEN PRINT S;" DEATHS BY STARVATION"
     IF K>0 THEN PRINT K;" WAR CASUALTIES"
     IF V>0 THEN PRINT V;" VICTIMS OF DISEASE"
     IF M>0 THEN PRINT M;" VICTIMS OF LOOTING"
     LET D=D+S+K+V+M
     LET P=P+B-D
     IF B+D>0 THEN PRINT "TOTAL: ";P
     PRINT "LAND (ACRES) : ";A
     IF T=0 THEN IF U=0 THEN GOTO 1350
     IF T>0 THEN PRINT T;" ACRES BOUGHT"
     IF T<0 THEN PRINT -T;" ACRES SOLD"
     IF U#0 THEN PRINT "FRUITS OF WAR: ";U;" ACRES"
     LET A=A+T+U
     LET T=0
     LET U=0
     PRINT "TOTAL: ";A
1350 PRINT "GRAIN (BUSHELS): ";G
     IF C<0 THEN GOTO 1530
     IF C=0 THEN GOTO 1430
     LET R=X
     PRINT "CROP YIELD ";C;" AT ";
     GOSUB 3220
     PRINT
1430 IF F>0 THEN PRINT F;" BUSHELS USED FOR FOOD"
     IF Q>0 THEN PRINT Q;" BUSHELS PLANTED"
     IF L#0 THEN PRINT "LAND DEALS: ";L;" BUSHELS"
     IF H>0 THEN PRINT "MERCENARY HIRE: ";H
     IF E>0 THEN PRINT E;" BUSHELS LOST TO RATS"
     IF Z#0 THEN PRINT "FRUITS OF WAR: ";Z;" BUSHELS"
     IF O>0 THEN PRINT "LOOTING LOSSES: ";O;" BUSHELS"
     LET G=G+C-F-Q+L-H-E+Z-O
     PRINT "TOTAL: ";G
1530 GOSUB 3310
     REM NOTICE IF GAME ENDED
     IF J<100 THEN GOTO 1690
     PRINT "THE PEASANTS TIRE OF WAR AND STARVATION"
     PRINT "YOU ARE DEPOSED."
1640 INPUT "DO YOU WISH TO PLAY AGAIN? (0 = no, 1 = yes) ", N
     IF N=0 THEN END
     GOTO 1000
1690 IF P>1 THEN GOTO 1750
     PRINT "YOU AND THE REMAINING POPULATION"
     PRINT "RETIRE IN THE SWISS ALPS."
     GOTO 1640
     REM MAKE LAND DEALS
1750 LET R=23+RND(8)
1760 GOSUB 3250
     PRINT "BUY AT ";
     GOSUB 3220
     INPUT T
     IF T<0 THEN GOTO 1760
     IF T=0 THEN GOTO 1860
     IF R*T<G THEN GOTO 2060
     IF R*T=G THEN GOTO 2060
     GOSUB 3270
     GOTO 1760
1860 LET R=R-1
1880 GOSUB 3250
     PRINT "SELL AT ";
     GOSUB 3220
     INPUT T
     IF T<0 THEN GOTO 1880
     IF T=0 THEN GOTO 2060
     IF T<A THEN GOTO 1990
     IF T=A THEN GOTO 1990
     PRINT "BUT THERE IS INSUFFICIENT LAND"
     GOTO 1880
1990 IF T<A/10 THEN GOTO 2050
     LET R=R-1
     PRINT "FOR SELLING SO MUCH YOU CAN ONLY GET ";
     GOSUB 3220
     PRINT
2050 LET T=-T
2060 LET L=-R*T
     REM DISTRIBUTE GRAIN
2110 GOSUB 3250
     PRINT "PLANT";
     INPUT Q
     IF Q<0 THEN GOTO 2110
     IF Q=A+T THEN GOTO 2180
     IF Q<A+T THEN GOTO 2180
     GOSUB 3270
     GOTO 2110
2180 IF Q=P*10 THEN GOTO 2220
     IF Q<P*10 THEN GOTO 2220
     PRINT "BUT THERE ARE INSUFFICIENT PEOPLE"
     GOTO 2110
2220 PRINT "HOW MANY BUSHELS DO YOU WISH TO ";
     PRINT "USE AS FOOD";
     INPUT F
     IF F<0 THEN GOTO 2220
     IF G+L-Q-F>0 THEN GOTO 2310
     IF G+L-Q-F=0 THEN GOTO 2310
     GOSUB 3270
     GOTO 2220
2310 IF F=40*P THEN LET S=P-F/40
     IF F<40*P THEN LET S=P-F/40
     LET J=J+S
     LET X=5+RND(4)
     IF Y/7*8-Y/49*7=Y THEN LET X=X/2-1
2350 LET C=X*Q
     IF G+L-Q-F+C=0 THEN GOTO 2390
     IF G+L-Q-F+C>0 THEN GOTO 2390
     LET X=(32767-G-L+Q+F)/Q
     GOTO 2350
2390 IF RND(99)<25 THEN LET E=(G+L-F+C)/10
     REM WAR AND PLAGUE
     IF RND(99)>15 THEN GOTO 2880
     LET W=25
     PRINT "A NEARBY KINGDOM THREATENS WAR"
     INPUT "DO YOU WISH TO MAKE A PRE-EMPTIVE STRIKE? (0 = no, 1 = yes) "; N
     IF N#0 THEN GOTO 2520
     LET W=100
     LET J=J+5
2520 PRINT "HOW MANY MERCENARIES WILL YOU HIRE AT 80 BUSHELS EACH";
     INPUT N
     IF N<0 THEN GOTO 2520
     LET D=G+L-Q-F+C-E
     IF RND(99)<W THEN GOTO 2610
     PRINT "PEACE NEGOTIATIONS SUCCEED"
     GOTO 2810
2610 IF W=25 THEN LET W=150
     LET R=P-S
     IF N>R/10 THEN GOTO 2660
     LET R=3*W/5*N*N/R*100/R
     GOTO 2680
2660 LET R=3*W/5+N*100/R
2680 LET K=(P-S)/2
     LET U=-(A+T)/2
     LET Z=-D/2
     IF R>RND(99) THEN GOTO 2760
     PRINT "YOU HAVE LOST THE WAR"
     LET J=J+5000/W
     GOTO 2810
2760 PRINT "YOU HAVE WON THE WAR"
     LET K=K/2
     LET U=-U
     LET Z=D/4
2810 IF N*80<D+Z THEN GOTO 2870
     IF N*80=D+Z THEN GOTO 2870
     GOSUB 3280
     PRINT "TO PAY THE MERCENARIES"
     LET M=3*(P-S-K)/4
     LET O=3*(R+Z)/4
     GOTO 2880
2870 LET H=N*80
2880 LET N=P-S-K-M
     IF RND(99)>4 THEN GOTO 2940
     PRINT "THE BLACK PLAGUE STRIKES"
     LET V=N/2
     GOTO 2970
2940 IF RND(99)>20 THEN GOTO 2980
     PRINT "A POX EPIDEMIC BREAKS OUT"
     LET V=N/20
2970 LET N=N-V
2980 LET B=(N*RND(5)+9)/100+1
     LET D=(N*RND(3)+4)/100
     IF Y/7*8-Y/49*7#Y THEN GOTO 3030
     PRINT "SEVEN YEAR LOCUSTS REDUCE CROP YIELD"
3030 IF E>0 THEN PRINT "RATS INFEST YOUR SILOS"
     LET Y=Y+8-(Y-Y/7*7)/6
     GOTO 1110
     REM UTILITY PRINT ROUTINES
3220 PRINT R;" BUSHELS/ACRE";
     RETURN
3250 PRINT "HOW MANY ACRES DO YOU WISH TO ";
     RETURN
3270 PRINT "BUT ";
3280 PRINT "THERE IS INSUFFICIENT GRAIN"
     RETURN
     REM INITIALIZE POPULATION AND GRAIN VECTORS
3310 LET B=0
     LET D=0
     LET K=0
     LET M=0
     LET S=0
     LET V=0
     LET C=0
     LET E=0
     LET F=0
     LET H=0
     LET L=0
     LET O=0
     LET Q=0
     LET Z=0
     RETURN
     REM INITIALIZATION, SETTING RANDOMIZER SEED
3510 LET Y=RND(6)+1
     LET J=0
     LET P=100
     LET A=1500
     LET G=5000
     LET T=0
     LET U=0
     GOSUB 3310
     LET C=-1
     REM PRINT INSTRUCTIONS (MAY BE OMITTED)
     INPUT "DO YOU NEED INSTRUCTIONS? (0 = no, 1 = yes) ", N
     IF N = 0 THEN RETURN
3710 PRINT "YOU HAVE INHERITED THE THRONE TO THE MEDIEVAL"
     PRINT "KINGDOM OF EUPHORIA, SOMEWHERE IN EUROPE."
     PRINT "AT THIS TIME IT IS ABOUT ";A;" ACRES IN SIZE,"
     PRINT "WITH ";P;" LOYAL PEASANTS TO SERVE YOU."
     PRINT "IN YOUR ROYAL SILOS YOU HAVE ";G;" BUSHELS OF"
     PRINT "NUTRITIOUS GRAIN WITH WHICH TO FEED THE PEOPLE"
     PRINT "AND TRANSACT INTERNATIONAL TRADE."
     PRINT "CLOSE BY YOUR SIDE ARE JEALOUS NEIGHBORING"
     PRINT "KINGDOMS, BUT YOU CAN PROTECT YOURSELF BY"
     PRINT "HIRING EVIL MERCENARIES."
     PRINT "EACH YEAR YOUR MINISTERS WILL PRESENT YOU"
     PRINT "WITH A SUMMARY OF YOUR CURRENT STATUS,"
     PRINT "AND THEN ASK YOU FOR DECISIONS ON WHAT"
     PRINT "TO DO FOR THE NEXT YEAR. PLEASE TYPE 1 OR 0"
     PRINT "FOR YES OR NO, OR A WHOLE NUMBER FOR"
     PRINT "NUMERIC ANSWERS."
     INPUT "ARE YOU READY, YOUR HIGHNESS? (0 = no, 1 = yes) ", N
     IF N=0 THEN END
     RETURN

