Each player governs a village season by season, splitting the population between mending the dyke, planting corn and defending against thieves. Each player starts with $1,000, 1,000 people and 2,500 sacks of corn. Each spring you choose how many sacks to plant, too few dyke menders or defenders brings floods or thieves, and too little corn planted brings starvation, all shown with short animations on a pre-drawn village scene. When corn runs short you must buy it at $15–19 a sack, and a surplus can be sold at $5–9. The aim is to finish as the richest player.
The handwritten label reads “KINGDOM”, and the program saves itself as “KINGDOm” with the last letter in inverse. This is a different version of the Kingdom game also found on TS PD Library Tape 1003. In this version the title screens advance after PAUSE 600 instead of waiting for a key, and the “THIS PROGRAM CRASHES” REM is gone. Several bugs in that version are fixed here: the Queen title test, the missing corn figure, the sell prompt’s missing INPUT and the doubled confirmation. The flood and thief animations are also different. The end-of-game winner routine, however, is incomplete (see below).
Program Analysis
Program Structure
- Lines 1–57: title and rules screens, number of players, player registration (
GOSUB 7000), background build (GOSUB 8000) and array setup. - Lines 100–630: season loop.
Scycles through spring, summer, autumn and winter,Ycounts years, and the inner loop overPhandles each player’s turn. - Lines 640–660: start of the winner announcement.
- Lines 1000–1170: flood; lines 2020–2180: thieves; lines 3000–3040: starvation.
- Lines 4000–4220: forced corn purchase; lines 5000–5140: optional corn sale.
- Lines 7000–7190: name, age and sex for each player; lines 8000–8050: background screen string.
Game Rules
At the start of each turn, 0–9 newcomers join the village. The player’s title (King, Queen, Prince or Princess) depends on the sex entered and on whether the age is over 18. Workers are assigned with whole-number inputs that can’t exceed the population. A flood follows if fewer than Q(P)/2.2 people mend the dyke, and thieves strike if fewer than Q(P)/2.2 defend. Each disaster kills 6 people for each point of a random 5–14 and costs corn or money. Starvation deaths equal the shortfall between corn planted and twice the population. Corn then becomes C(P)/1.2+D(P)*3. If the store is below twice the population the player has to buy corn, and if it is above, the player can sell. Population grows by 20% and money by 9% every season.
Notable Techniques
DIM N$(A,11)holds each player’s name in characters 1–10 and the M/F flag in character 11.INPUT N$(F)(11)writes straight into that one position.- Subroutine 8000 builds the whole 22-line scene once, in
FASTmode, as one stringM$: water (▒), the dyke (█), open village ground and a cornfield of slashes. Line 470 prints it in a singlePRINT AT 0,0;M$. - Lines 240–280 center each figure with
TAB 15-((LEN STR$ value+N)/2), whereNallows for the label’s length. - The flood animation replaces part of the dyke with water, runs a channel to the house, animates waves there by alternating inverse characters, then restores the dyke. The thief walks in as a
T, and the fight is shown by cycling the four quadrant graphics▖ ▘ ▝ ▗. GOSUB 2000targets a line that doesn’t exist. The ZX81 continues at the next line, 2020.
Potential Issues
- The game never names a winner. Line 650 opens
FOR F=1 TO A, and line 660 prints the first player’s money, but there is noNEXT, no comparison, and no stop. Execution runs on into the flood routine at 1000 and ends at itsRETURNwith noGOSUBactive.W$andWare set up but never used. - Line 2160 reads
PRINT C(P)=C(P)-K*25instead ofLET, so thieves never take corn and a 0 is printed. - Line 4210 adds 1 sack (
C(P)+1) instead of the number bought,I, although the full price is deducted. - Line 450 opens
FOR F=1 TO 22for aSCROLLbut has noNEXT, so the screen scrolls only once before the scene is drawn. - Starvation (line 530) is judged against
D(P), the corn planted that spring, which carries over unchanged through the year, rather than the corn in store. - Because
Yincreases each spring and the loop stops when it reaches 5, the game ends after the spring of year 5 (17 seasons), not after five full years. - In the sale routine, pressing ENTER with no input makes
A$(1)fail on an empty string, and any reply other than a number or N makesVALfail.
Source Code
1 PRINT AT 3,7;"*****************"
2 PRINT AT 4,7;"* *"
3 PRINT AT 5,7;"* K I N G D O M *"
4 PRINT AT 6,7;"* *"
5 PRINT AT 7,7;"*****************"
6 PRINT AT 10,0;" YOU HAVE TO GOVERN A VILLAGE";AT 12,0;"FOR A PERIOD OF FIVE YEARS.YOU";AT 14,0;"MUST TRY TO KEEP ALIVE AS MANY"
7 PRINT AT 16,0;"PEOPLE AS POSSIBLE,THEY WILL DO";AT 18,0;"ONE OF THREE JOBS.";AT 20,0;"YOU MUST PROTECT THEM AGAINST..."
8 PAUSE 600
10 FOR F=10 TO 21
11 PRINT AT F,0;" "
12 NEXT F
13 PRINT AT 10,0;"...(A)=>FLOODS";AT 11,0;"...(B)=>STARVATION";AT 12,0;"...(C)=>THIEVES";AT 14,0;"YOU HAVE TO BE AS RICH AS POSS.";AT 16,0;"AT THE END OF FIVE YEARS";AT 18,0;"AND THE RICHEST WINS."
14 PAUSE 600
16 FOR F=10 TO 21
17 PRINT AT F,0;" "
18 NEXT F
19 PRINT AT 10,0;"HOW MANY PLAYERS? ";
20 INPUT A
21 PRINT A
22 DIM N$(A,11)
23 DIM U(A)
24 GOSUB 7000
34 PRINT AT 21,5;"TYPE ANY KEY TO START"
35 IF INKEY$ ="" THEN GOTO 35
36 FOR F=1 TO 22
37 SCROLL
38 NEXT F
39 GOSUB 8000
40 DIM M(A)
41 DIM C(A)
42 DIM Q(A)
43 FOR F=1 TO A
44 LET M(F)=1000
45 LET Q(F)=1000
46 LET C(F)=2500
47 NEXT F
48 DIM D(A)
49 DIM N(A)
50 DIM Z(A)
51 DIM X(A)
52 DIM T(A)
53 FOR F=1 TO A
54 LET Z(F)=0
55 LET X(F)=0
56 LET T(F)=0
57 NEXT F
100 REM START
105 LET S=0
110 LET Y=0
115 LET S=S+1
120 IF S=1 THEN LET Y$="SPRING"
125 IF S=2 THEN LET Y$="SUMMER"
130 IF S=3 THEN LET Y$="AUTUMN"
135 IF S=4 THEN LET Y$="WINTER"
140 IF S=1 THEN LET Y=Y+1
150 IF S=4 THEN LET S=0
170 FOR P=1 TO A
175 LET N(P)=INT (RND*10)
176 LET Q(P)=Q(P)+N(P)
180 PRINT AT 0,9;Y$;" YEAR ";Y
190 IF N$(P)(11)="M" AND U(P)>18 THEN PRINT "KING ";N$(P)( TO 10)
193 IF N$(P)(11)="F" AND U(P)<=18 THEN PRINT "PRINCESS ";N$(P)( TO 10)
195 IF N$(P)(11)="M" AND U(P)<=18 THEN PRINT "PRINCE ";N$(P)( TO 10)
200 IF N$(P)(11)="F" AND U(P)>18 THEN PRINT "QUEEN ";N$(P)( TO 10)
201 PRINT
202 PRINT N(P);" PEOPLE CAME TO THE VILLAGE."
203 PRINT
210 PRINT TAB 9;"CASUALTIES:;"
211 PRINT "STARVED . FLOODS . THIEVES"
212 PRINT TAB 3;X(P);TAB 12;Z(P);TAB 22;T(P)
214 PRINT "********************************"
220 PRINT TAB 10;"YOU HAVE:"
240 PRINT TAB 15-(((LEN (STR$ M(P)))+2)/2);"$";M(P);","
260 PRINT TAB 15-(((LEN (STR$ Q(P)))+8)/2);Q(P);" PEOPLE,"
280 PRINT TAB 15-(((LEN (STR$ C(P)))+15)/2);C(P);" SACKS 0F CORN."
290 PRINT "********************************"
300 PRINT "LABOR ARRANGEMENT:"
320 PRINT "(A) MENDING THE DYKE ";
330 INPUT A1
335 IF INT A1<>A1 THEN GOTO 330
340 PRINT A1
360 PRINT "(B) PLANTING CORN ";
370 INPUT A2
375 IF INT A2<>A2 THEN GOTO 370
380 PRINT A2
400 PRINT "(C) DEFENDING THE VILLAGE ";
409 INPUT A3
410 IF INT A3<>A3 THEN GOTO 409
411 PRINT A3
412 IF A1+A2+A3<=Q(P) THEN GOTO 420
413 PRINT AT 21,5;"TOO MANY PEOPLE"
414 FOR F=1 TO 22
415 IF INT A3<>A3 THEN GOTO 410
416 NEXT F
417 GOTO 180
420 IF Y$<>"SPRING" THEN GOTO 430
422 PRINT "HOW MANY SACKS OF CORN ARE TO";" BE PLANTED? ";
423 INPUT D(P)
424 PRINT D(P)
425 IF D(P)>C(P) THEN GOTO 422
426 LET C(P)=C(P)-D(P)
427 IF D(P)/10>A2 THEN LET D(P)=A2*10
430 PAUSE 600
450 FOR F=1 TO 22
460 SCROLL
466 FAST
470 PRINT AT 0,0;M$
490 PRINT AT 8,14;"******";AT 9,14;"* *";AT 10,14;"* ++ *";AT 11,14;"* *";AT 12,14;"*****▛"
500 PRINT AT 10,27;"T"
501 LET T(P)=0
502 LET Z(P)=0
503 LET X(P)=0
504 SLOW
510 IF A1<Q(P)/2.2 THEN GOSUB 1000
520 IF A3<Q(P)/2.2 THEN GOSUB 2000
530 IF D(P)<Q(P)*2 THEN GOSUB 3000
535 LET C(P)=(C(P)/1.2)+D(P)*3
540 IF C(P)+D(P)<Q(P)*2 THEN GOSUB 4000
550 IF C(P)+D(P)>Q(P)*2 THEN GOSUB 5000
560 LET Q(P)=Q(P)*1.2
565 LET Q(P)=INT (Q(P))
575 LET C(P)=INT (C(P))
580 LET M(P)=M(P)*1.09
583 LET M(P)=INT (M(P))
590 FOR F=1 TO 22
600 SCROLL
610 NEXT F
611 IF M(P)<0 THEN LET M(P)=0
612 IF C(P)<0 THEN LET C(P)=0
613 IF Q(P)<0 THEN LET Q(P)=0
620 NEXT P
630 IF Y<5 THEN GOTO 115
640 PRINT AT 0,0;"NOW FOR THE WINNER....."
644 LET W$=""
645 LET W=0
650 FOR F=1 TO A
660 PRINT N$(F)( TO 10);" WITH $";M(F);","
1000 LET K=INT (RND*10)+5
1010 IF K*6>Q(P) THEN LET K=INT (Q(P)/6)
1015 PRINT AT 10,3;"▒"
1020 FOR F=4 TO 16
1030 PRINT AT 10,F;"▒"
1040 NEXT F
1045 FOR N=1 TO K
1050 PRINT AT 9,16;"[,,][,,]";AT 10,16;"▒▒";AT 11,16;"▒▒"
1060 PRINT AT 9,16;"[~~][~~]";AT 10,16;"▒▒";AT 11,16;"▒▒"
1070 PRINT AT 9,16;"▒▒";AT 10,16;"[,,][,,]";AT 11,16;"▒▒"
1080 PRINT AT 9,16;"▒▒";AT 10,16;"[~~][~~]";AT 11,16;"▒▒"
1090 PRINT AT 9,16;"▒▒";AT 10,16;"▒▒";AT 11,16;"[,,][,,]"
1100 PRINT AT 9,16;"▒▒";AT 10,16;"▒▒";AT 11,16;"[~~][~~]"
1105 NEXT N
1106 PRINT AT 9,16;" ";AT 10,16;" ";AT 11,16;" "
1110 FOR F=16 TO 4 STEP -1
1111 PRINT AT 10,F;" "
1112 NEXT F
1115 PRINT AT 10,3;"█"
1130 LET Q(P)=Q(P)-K*6
1140 LET Z(P)=Z(P)+K*6
1150 LET C(P)=C(P)-K*20
1160 LET M(P)=M(P)-K*10
1170 RETURN
2020 LET K=INT (RND*10)+5
2025 IF K*6>Q(P) THEN LET K=INT (Q(P)/6)
2030 FOR F=27 TO 16 STEP -1
2040 PRINT AT 10,F;"T "
2050 NEXT F
2060 FOR F=1 TO K
2070 PRINT AT 10,16;"▖"
2080 PRINT AT 10,16;"▘"
2090 PRINT AT 10,16;"▝"
2100 PRINT AT 10,16;"▗"
2110 NEXT F
2120 FOR F=16 TO 27
2130 PRINT AT 10,F;" T"
2140 NEXT F
2150 LET Q(P)=Q(P)-K*6
2151 LET T(P)=K*6
2160 PRINT C(P)=C(P)-K*25
2170 LET M(P)=M(P)-K*15
2180 RETURN
3000 REM STAR
3010 LET K=ABS (D(P)-(Q(P)*2))
3015 IF K>Q(P) THEN LET K=Q(P)
3020 LET Q(P)=Q(P)-(INT (K))
3035 LET X(P)=K
3040 RETURN
4000 REM BUY
4010 LET K=INT (RND*5)+15
4020 FOR F=1 TO 22
4030 SCROLL
4040 NEXT F
4050 PRINT AT 0,0;"YOU HAVENT GOT ENOUGH CORN TO FEED ";"YOUR VILLAGE--YOU MUST BUY SOME..."
4060 PRINT
4070 PRINT "CURRENT BUYING RATE =";K
4080 PRINT
4090 PRINT "YOU HAVE $";M(P)
4100 PRINT
4110 PRINT "THE MOST YOU CAN HAVE ARE ";INT (M(P)/K)
4120 PRINT "SACKS"
4140 PRINT "HOW MANY DO YOU WANT TO BUY?";
4150 INPUT I
4160 IF I>(M(P)/K) THEN GOTO 4140
4170 PRINT I
4180 PRINT
4190 PRINT "THAT WILL COST $";I*K
4200 LET M(P)=M(P)-(K*I)
4210 LET C(P)=C(P)+1
4220 RETURN
5000 REM SELL
5010 FOR F=1 TO 22
5020 SCROLL
5030 NEXT F
5040 PRINT AT 0,0;"YOU HAVE A SURPLUS OF CORN,DO YOU";" WANT TO SELL ANY,IF SO SPECIFY THE AMOUNT."
5050 INPUT A$
5060 IF A$(1)="N" THEN RETURN
5070 LET K=VAL A$
5071 IF K<=C(P) THEN GOTO 5080
5072 PRINT
5073 PRINT "YOU ONLY HAVE ";INT (C(P));" SACKS."
5074 IF INKEY$ ="" THEN GOTO 5074
5075 GOTO 5000
5080 LET J=INT (RND*5)+5
5090 PRINT K;" SACKS OF CORN,AT"
5100 PRINT "$";J;" A SACK,WILL MAKE "
5110 PRINT "$";K*J
5120 LET M(P)=M(P)+K*J
5130 LET C(P)=C(P)-K
5140 RETURN
7000 FOR F=1 TO A
7010 CLS
7020 PRINT "PLAYER ";F
7030 PRINT
7040 PRINT "YOUR NAME PLEASE: "
7050 INPUT N$(F)
7051 PRINT N$(F)
7052 PRINT
7060 PRINT "YOUR AGE(APPROX)? ";
7070 INPUT U(F)
7080 PRINT U(F)
7090 PRINT
7100 PRINT "ARE YOU MALE(M)/FEMALE(F)? ";
7110 INPUT N$(F)(11)
7120 PRINT N$(F)(11)
7130 PRINT
7140 PRINT "O.K.? ";
7150 INPUT H$
7160 PRINT H$
7170 IF H$="NO" OR H$="N" THEN GOTO 7010
7180 NEXT F
7190 RETURN
8000 FAST
8005 LET M$=""
8010 FOR F=1 TO 22
8020 LET M$=M$+"▒▒▒█ //////"
8030 NEXT F
8040 SLOW
8050 RETURN
9000 SAVE "KINGDO[M]"
9010 RUNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.


