	PROGRAM KING
C
C	A LAND MANAGEMENT GAME
C	WRITTEN BY A. STORER
C	TRANSLATED TO FORTRAN BY DAVE THORSON
C
C
	N5=8
	CALL RINIT(I1,I2)
1	WRITE(5,2)
2	FORMAT(///////////'          K I N G'/' Do you want 
     cinstructions ? ',$)
	READ(5,3,END=9999) ANS
3	FORMAT(A1)
	IF(ANS.EQ.'Y') GOTO 4
	IF(ANS.EQ.'N') GOTO 50
	GOTO 1
4	WRITE(5,5) N5
5	FORMAT(//' Congratulations !!  You''ve just been elected'/
     c' premier of Setats Detinu, a small communist island 30 by 70'/
     c' miles long.  Your job is to decide upon the country''s budget'/
     c' and distribute money to your countrymen from the communal'/
     c' treasury.'//' The money system is in rallods, and each person'/
     c' needs 100 rallods per year to survive.  Your contry''s income'/
     c' comes from farm produce and tourists visiting your magnificent'/
     c' forests, hunting, fishing, etc.  Half your land is farm land'/
     c' which also has an excellent mineral content and may be sold to'/
     c' foreign industry (strip mining) who import and support their'/
     c' own workers.  Crops cost between 10 and 15 rallods per sq. mile'
     c/' to plant.'//' Your goal is to complete your',I3,'-year term'/
     c' of office.'//' Hit <CR> to begin.        Good Luck.')
	READ(5,3,END=9999) ANS
50	A=60000.+1000.*RAN(I1,I2)-1000.*RAN(I1,I2)
55	B=500.+10.*RAN(I1,I2)-10.*RAN(I1,I2)
65	D=2000.
100	W=95.+10*RAN(I1,I2)
105	IX5=X5+1.01
	IB=B+.5
	WRITE(5,106) IX5,A,IB
106	FORMAT(//' Begin year ',I2,' of your reign.'/
     C' You now have',F11.2,' rallods in your treasury,'/
     CI7,' countrymen,')
	V9=5.*RAN(I1,I2)+10.
	IF(C.LE.0.) GOTO 140
	IC=C+.5
	WRITE(5,136) IC
136	FORMAT(I7,' foreign workers,')
140	WRITE(5,141) D,W,V9
141	FORMAT(' and',F11.2,' sq. miles of land.'/
     C/' This year industry will buy land for',F7.2,' rallods per sq. mi
     Cle.'/' Land currently costs',F7.2,' rallods per sq. mile to plant.
     C')
200	WRITE(5,201)
201	FORMAT(
     C' How many sq. miles of land do you wish to sell to industry ?',$)
210	READ(5,211,END=9999) H
211	FORMAT(F10.0)
	IF(H.LT.-.000001) GOTO 200
	IF(H.LE.D-1000) GOTO 300
230	WRITE(5,231)D-1000.
231	FORMAT(' Think again, you''ve only',F9.2,' sq. miles of farmland
     C.')
	IF(X.NE.0.) GOTO 200
250	WRITE(5,251)
251	FORMAT(' (foreign industry will only buy farmland because forest
     C'/' land is uneconomical to strip mine due to trees, thicker top'/
     C' soil, etc.')
280	X=1.
299	GOTO 200
300	D=D-H
310	A=A+H*W
320	WRITE(5,321)
321	FORMAT(' How many rallods will you distribute to your'/
     C' countrymen ? ',$)
340	READ(5,341,END=9999) XI
341	FORMAT(F10.0)
342	IF(XI.LT.0.) GOTO 320
350	IF(XI.LT.A) GOTO 400
360	IF(XI.EQ.A) GOTO 380
370	WRITE(5,371) A
371	FORMAT(' Think again, you''ve only',F9.2,' rallods in the treasu
     Cry.')
375	GOTO 320
380	J=0
390	XK=0
395	A=0
399	GOTO 1000
400	A=A-XI
410	WRITE(5,411)
411	FORMAT(' How many sq. miles do you wish to plant ? ',$)
420	READ(5,419,END=9999) XJ
419	FORMAT(F10.0)
421	IF(XJ.LT.0.) GOTO 410
422	IF(XJ.LE.B*2) GOTO 426
423	WRITE(5,425)
425	FORMAT(' Sorry, but each countryman can only plant 2 sq. miles')
424	GOTO 410
426	IF(XJ.LT.D-1000.) GOTO 430
	WRITE(5,427) D-1000.
427	FORMAT(' Sorry, but you''ve only',F8.2,' sq.miles of farm land')
428	GOTO 410
430	U1=XJ*V9
435	IF(U1.LT.A) GOTO 500
440	IF(U1.EQ.A) GOTO 490
450	WRITE(5,451) A
451	FORMAT(' Think again, you''ve only',F9.2,' rallods in the
     C treasury.')
460	GOTO 410
490	XK=0
495	A=0
499	GOTO 1000
500	A=A-U1
510	WRITE(5,511)
511	FORMAT(' How many rallods do you wish to spend on pollution'/
     C' control ? ',$)
520	READ(5,419,END=9999) XK
522	IF(XK.LT.0.) GOTO 510
530	IF(XK.LE.A) GOTO 1000
540	WRITE(5,541) A
541	FORMAT(' Think again, you''ve only',F9.2,' remaining.')
550	GOTO 510
600	IF(H.NE.0.) GOTO 1002
602	IF(XI.NE.0.) GOTO 1002
604	IF(XJ.NE.0) GOTO 1002
606	IF(XK.NE.0) GOTO 1002
9999	CONTINUE
612	WRITE(5,613)
613	FORMAT('1Good bye.'///)
618	STOP '-- KING FINISHED'
1000	WRITE(5,6000)
6000	FORMAT(' Hit <CR> to see the results for this year.')
	READ(5,3) ANS
	GOTO 600
1002	CONTINUE
1010	A=A-XK
1020	A4=A
1100	IF(XI/100.-B.GE.0) GOTO 1120
1105	IF(XI/100..LT.50.) GOTO 1700
1110	IB=B-XI/100.+.5
	WRITE(5,1111) IB
1111	FORMAT(///////X,I6,' countrymen died of starvation.')
1120	F1=RAN(I1,I2)*(2000.-D)
1122	IF(XK.LT.25) GOTO 1130
1125	F1=F1/(XK/25.)
1130	IF(F1.LE.0.) GOTO 1150
1140	IF1=F1+.5
	WRITE(5,1141) IF1
1141	FORMAT(X,I6,' countrymen died of carbon-monoxide and'/
     C' dust inhalation.')
1150	IF((XI/100.-B).LT.0.) GOTO 1170
1160	IF(F1.GT.0.) GOTO 1180
1165	GOTO 1200
1170	WRITE(5,1171) (IF1+IB)*9.
1171	FORMAT(' You were forced to spend ',F9.2,' rallods on'/
     C' funeral expenses.')
1174	B5=IF1+IB
1175	A=A-9.*(IF1+IB)
1176	GOTO 1185
1180	WRITE(5,1171) IF1*9.
1182	B5=IF1
1183	A=A-IF1*9.
1185	IF(A.GE.0.) GOTO 1194
1187	WRITE(5,1188)
1188	FORMAT(' Insufficient reserves to cover cost -- land was sold.')
1189	D=D+A/W
1190	A=0.
1194	B=B-B5
1200	C1=0
	IF(H.EQ.0.) GOTO 1230
1220	C1=H+RAN(I1,I2)*10.-RAN(I1,I2)*20.
1224	IF(C.GT.0.) GOTO 1230
1226	C1=C1+20.
1230	P1=(XI/100.-B)/10+XK/25-(2000.-D)/50.-F1/2.
	IP1=ABS(P1)+.5
	IC1=C1+.5
	WRITE(5,1231) IC1,IP1
1231	FORMAT(X,I6,' workers came to the country and',I6,' country
     Cmen')
	IF(P1.GT.0.) WRITE(5,1275)
	IF(P1.LE.0.) WRITE(5,1276)
1275	FORMAT('    came to the island.')
1276	FORMAT('    left the island.')
1290	B=B+P1
1292	C=C+C1
1305	U2=(2000.-D)*(RAN(I1,I2)+1.5)/2.
	IF(XJ.LE.U2) U2=XJ
	IJU2=XJ-U2
1320	J=XJ+.5
	IF(C.NE.0.) WRITE(5,1321) J,IJU2
	IF(C.EQ.0.) WRITE(5,1310) IJU2
1321	FORMAT(' Of ',I6,' sq. miles of crops planted, you harvested ',
     CI6)
1310	FORMAT(' You harvested ',I6,' sq. miles of crops')
1340	IF(U2.EQ.0.) GOTO 1370
1344	IF(T1.GE.2.) GOTO 1370
1350	WRITE(5,1351)
1351	FORMAT(' (due to ',$)
1355	IF(T1.EQ.0.) GOTO 1365
1360	WRITE(5,1361)
1361	FORMAT('+increased ',$)
1365	WRITE(5,1366)
1366	FORMAT('+air and water pollution from foreign industry)')
1370	Q=(XJ-U2)*W/2.
1380	WRITE(5,1381) Q
1381	FORMAT(' making',F10.2,' rallods.')
1390	A=A+Q
1400	V1=(B-P1)*22.+RAN(I1,I2)*500.
1405	V2=(2000.-D)*15.
1410	WRITE(5,1411) ABS(V1-V2)
1411	FORMAT(' You made',F9.2,' rallods from tourist trade.')
1420	IF(V2.EQ.0.) GOTO 1450
1425	IF(V1-V2.GE.V3) GOTO 1450
1430	WRITE(5,1431)
1431	FORMAT(' The decrease is because ',$)
1435	G1=10.*RAN(I1,I2)
	IF(G1.LE.2.) GOTO 1460
	IF(G1.LE.4.) GOTO 1465
	IF(G1.LE.6.) GOTO 1470
	IF(G1.LE.8.) GOTO 1475
	GOTO 1480
1450	V3=ABS(V1-V2)
1451	A=V3+A
1452	GOTO 1500
1460	WRITE(5,1461)
	GOTO 1450
1465	WRITE(5,1466)
	GOTO 1450
1470	WRITE(5,1471)
	GOTO 1450
1475	WRITE(5,1476)
	GOTO 1450
1480	WRITE(5,1481)
	GOTO 1450
1461	FORMAT('+the fish population has dwindled due to'/
     C'       water pollution.')
1466	FORMAT('+air pollution is killing the'/
     C'      game bird population.')
1471	FORMAT('+mineral baths are being ruined'/
     C'      by water pollution.')
1476	FORMAT('+unpleasant smog is discouraging sun bathers.')
1481	FORMAT('+hotels are looking shabby due to smog grit.')
1500	IF(B5.GT.200.) GOTO 1600
1505	IF(B.LT.343.) GOTO 1700
1510	IF(A4/100..GT.5.) GOTO 1800
1515	IF(C.GT.B) GOTO 1550
1520	XN5=N5
	IF(XN5-1..EQ.X5) GOTO 1900
1545	GOTO 2000
1550	WRITE(5,1560)
1560	FORMAT('1The number of workers has exceeded the number of'/
     C' countrymen.  As a majority they have revolted and taken'/
     C' over the country.')
1570	IF(RAN(I1,I2).LE..5) GOTO 1580
1574	WRITE(5,1575)
1575	FORMAT(//' You have been thrown out of office and are now'/
     C' residing in prison.')
	GOTO 1596
1580	WRITE(5,1581)
1581	FORMAT(//' You have been assassinated.')
1596	STOP'-- KING OVERTHROWN'
1600	IB5=B5+.5
	WRITE(5,1601) IB5
1601	FORMAT(//X,I6,' countrymen died in one year !!!!'/
     C' Due to this extreme mismanagement you have not only been'/
     C' been impeached and thrown out of office but you have also')
1622	M6=RAN(I1,I2)*10.
	IF(M6.LE.3) WRITE(5,1623)
	IF(M6.GT.3.AND.M6.LE.6) WRITE(5,1624)
	IF(M6.GT.6) WRITE(5,1625)
1623	FORMAT(' had your left eye gouged out.')
1624	FORMAT(' gained a very bad reputation.')
1625	FORMAT(' been declared National Fink.')
	GOTO 1596
1700	WRITE(5,1701)
1701	FORMAT(//' Over one third of the population has died since you'/
     C' were elected to office.  The remaining people hate your guts.')
	GOTO 1570
1800	IF(B5-F1.LT.2.) GOTO 1515
	WRITE(5,1801)
1801	FORMAT(//' Money was left over in the treasury which you'/
     C' did not spend.  As a result some of your contrymen died'/
     C' of starvation.  The public is enraged and you have been'/
     C' forced to either resign or commit suicide.'//
     C' If you chose the latter please turn off your terminal first.')
	GOTO 1596
1900	WRITE(5,1901) N5
1901	FORMAT(//' C O N G R A T U L A T I O N S  !!!!!'//
     C' You have succesfully completed your',I2,'-year term of office.'/
     C' You were, of course, extremely lucky, but nevertheless, it''s'/
     C' quite an acheivement.'//' Good bye and good luck --'/
     C' you''ll probably need it if you''re the type that'/
     C' plays this game.')
	STOP '-- KING SUCCESFUL'
2000	X5=X5+1
	B5=0.
	GOTO 100
	END
C
C
C
	SUBROUTINE RINIT(ISEED1,ISEED2)
C	INITIALIZE RANDOM NUMBER SEEDS
	T=SECNDS(0.)
3	IF(T.LT.32000.) GOTO 4
	T=T/10.
	GOTO 3
4	ISEED1=T
	T=T-ISEED1
	ISEED2=T*1000
	DO 5 I=1,200
	X=RAN(ISEED1,ISEED2)
5	CONTINUE
	RETURN
	END
