0 GOSUB5000:GOSUB1000:GOTO270
7 PRINTM$;:CC=((PEEK(17024)AND1)*256+PEEK(17025))-1+M:FORC1=CC-LEN(M$)+1TOCC:POKEC1,PEEK(C1)-64:NEXT:RETURN
8 Q(Q+1)=Q(C)-64:Q(Q+2)=Q(C)-30:Q(Q+3)=Q(C)+34:Q(Q+4)=Q(C)+64:Q(Q+5)=Q(C)+30:Q(Q+6)=Q(C)-34:Q=Q+6:RETURN
9 IFPEEK(Q(C)+M)<128ANDPEEK(Q(C)+M+1)=C(P)THENPRINT@Q(C),C$(P);:R=R+1:GOSUB8
10 C=C+1:IFC>QTHENRETURN
11 GOTO9
12 Y=INT(L(R)/32):X=((L(R)/32)-Y)*32:RETURN
15 PRINT@(P-1)*12,C$(P)H(P);:RETURN
16 S=S+1:Q(S)=T:FORC=STO1STEP-1:IFD(Q(C))>D(Q(C-1))THENR=Q(C-1):Q(C-1)=Q(C):Q(C)=R
17 NEXT:RETURN
19 R=S+6:RETURN
20 IFFTHENPRINT@L(T),RIGHT$(STR$(D(T)),1);
21 F=-1:IFPEEK(M+L)<113ORPEEK(M+L)>120THENON1-(PEEK(2)=0)GOTO130,110
22 FORC=1TO42:IFL=L(C)THENT=C:C=42:NEXT:GOTO110
23 NEXT:STOP
60 PRINT@L(T),RIGHT$(STR$(D(T)),1);:PRINT@L(T)-32,C$(P);:PRINT@L(T)+32,C$(P);:PRINT@L(T)-1,C$(P);:PRINT@L(T)+1,C$(P);:RETURN
70 H=0:FORT=1TO42:IFT(T)=PTHENQ=1:C=1:R=0:Q(C)=L(T):GOSUB9:IFR>HTHENH=R
72 NEXT:RETURN
80 IFQ=0ANDD(T)=1THENSOUND1,1:GOTO110
81 IFQ>0ANDT(T)=PTHEN92
82 IFQ=0ANDT(T)=PTHENSOUND100,1:SOUND150,1:Q=T:F=0:GOTO110
84 IFQ=0ANDT(T)<>PTHENSOUND1,1:Q=0:F=-1:GOTO110
90 R=T:GOSUB12:A=X:B=Y:R=Q:GOSUB12:IFABS(A-X)<=2ANDABS(B-Y)<=2ANDD(Q)>1THEN93
92 SOUND1,1:PRINT@L(Q),RIGHT$(STR$(D(Q)),1);:Q=0:F=-1:GOTO110
93 I=0:FORR=1TOD(T):I=I+RND(6):NEXT:J=0:FORR=1TOD(Q):J=J+RND(6):NEXT
94 GOSUB99:PRINT@(T(T)-1)*12,C$(T(T))I;:PRINT@(P-1)*12,C$(T(Q))J;
95 FORR=1TO750:NEXT:IFI>=JTHEND(Q)=1
96 IFI<JTHENA(T(T))=A(T(T))-1:A(P)=A(P)+1:D(T)=D(Q)-1:D(Q)=1:T(T)=T(Q):GOSUB60
97 PRINT@L(Q),RIGHT$(STR$(D(Q)),1);:PRINT@L(T),RIGHT$(STR$(D(T)),1);:Q=0:F=-1:GOSUB99:IFA(P)=42THEN185
98 GOTO110
99 PRINT@0,"ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ";:RETURN
100 FORZ=1TO65000:FORP=1TON:T=Z(P):Q=0:F=-1:ONSTGOTO103:ONAPGOTO102,102:ST=1:P=RND(N):GOTO190
102 ST=1:P=N:GOTO190
103 IFAP=1ANDP=1THEN500
104 IFAP=2THEN500
105 IFA(P)<1THEN220
106 M$=CC$(P)+"'S TURN":PRINT@(32-LEN(M$))/2,;:GOSUB7
110 PRINT@L(T),;:M$=RIGHT$(STR$(D(T)),1):GOSUB7
120 K=PEEK(17023)ANDPEEK(2):IFK=32THEN80
130 IFK=83THENL=L(T)-30:K=65:GOTO20
140 IFK=90THENL=L(T)+30:K=88:GOTO20
150 IFK=65THENL=L(T)-34:K=83:GOTO20
160 IFK=88THENL=L(T)+34:K=90:GOTO20
170 IFK=13THENZ(P)=T:GOTO190
180 IFK<>81THEN120
185 R=4:P=3:Z=65000:GOTO220
190 GOSUB99:PRINT@L(T),RIGHT$(STR$(D(T)),1);:GOSUB70:H(P)=H(P)+H:GOSUB15
192 FORC=43TO85:Q(C)=-1:NEXT:C=0
194 T=RND(42):IFT(T)=PANDQ(42+T)THENQ(42+T)=0:C=C+1:Q(C)=T:IFC=A(P)THEN198
196 GOTO194
198 R=0:FORC=1TOA(P):T=Q(C):R=R+D(T)
200 IFD(T)<8THENR=R+1:H(P)=H(P)-1:GOSUB15:D(T)=D(T)+1:?@L(T),;:M$=RIGHT$(STR$(D(T)),1):GOSUB7:IFH(P)<1THENC=A(P):GOTO205
204 IFRND(2)=1THEN200
205 NEXT:IFR<8*A(P)ANDH(P)>0THEN198
210 GOSUB99:FORC=1TOA(P):T=Q(C):PRINT@L(T),RIGHT$(STR$(D(T)),1);:GOSUB60:NEXT
220 NEXTP:NEXTZ:IFA(1)>A(2)ANDA(1)>A(3)THENR=1
222 IFA(2)>A(1)ANDA(2)>A(3)THENR=2
224 IFA(3)>A(1)ANDA(3)>A(2)THENR=3
225 IFR=4THENGOSUB99:M$="IT'S A DRAW!":PRINT@(32-LEN(M$))/2,;:GOSUB7:GOTO240
226 GOSUB99:M$=CC$(R)+" IS VICTORIOUS!":PRINT@(32-LEN(M$))/2,;:GOSUB7
228 VI(R)=VI(R)+1
240 PRINT@487,;:M$=" PLAY AGAIN (Y/N)? ":GOSUB7
250 M$=INKEY$:IFM$=""THEN250
252 IFM$="N"THENEND
254 IFM$="Y"THENGOSUB6000:GOTO270
256 GOTO250
270 CLS3:ST=0:X=RND(28)+1:Y=RND(12)+1:Q=0:A=0:B=0:FORT=1TO42:T(T)=0:L(T)=0:D(T)=0:NEXT
275 FORP=1TO3:A(P)=0:H(P)=0:Z(P)=1:NEXT:P=1:H=0
280 FORT=1TO42:P=P+1:IFP>NTHENP=1
290 Q=Q+1:IFQ>25THENR=RND(T):GOSUB12:Q=0
300 C=RND(8):R=RND(4):IFR=1THENA=2:B=1
320 IFR=2THENA=2:B=-1
340 IFR=3THENA=-2:B=1
360 IFR=4THENA=-2:B=-1
380 IFPEEK(M+X+A+(Y+B)*32)<>175THEN290
400 IFX+A>29THEN290
420 IFX+A<2THEN290
440 IFY+B>13THEN290
460 IFY+B<2THEN290
470 X=X+A:Y=Y+B:T(T)=P:L(T)=X+Y*32:D(T)=C:A(P)=A(P)+1:GOSUB60:Q=0:NEXT:SOUND50,1
484 PRINT@2,;:M$="DO YOU PLAY THIS ONE (Y/N)?":GOSUB7
486 M$=INKEY$:IFM$=""THEN486
488 IFM$="Y"THENGOSUB99:GOTO100
490 IFM$="N"THEN270
492 GOTO486
500 ONRND(25)GOTO502,503:G=3:GOTO506
502 G=2:GOTO506
503 G=4
506 E=0:S=0:FORT=1TO42:IFT(T)=PTHENIFD(T)>3THENGOSUB16
508 NEXT:IFS=0THENT=1:GOTO190
510 FORC=1TOS:T=Q(C):Q(S+1)=L(T)-64:Q(S+2)=L(T)-30:Q(S+3)=L(T)+34:Q(S+4)=L(T)+64:Q(S+5)=L(T)+30:Q(S+6)=L(T)-34
520 T=9:FORR=S+1TOS+6:IFPEEK(M+Q(R)+1)=S(P)THENK=PEEK(M+Q(R))-112:IFD(Q(C))>=KTHENIFK<TTHENL=Q(R):T=K:E=-1:ONRND(15)GOSUB19
522 NEXT:IFT=9THEN600
525 FORR=1TO42:IFL=L(R)THENT=R:R=42:NEXT:GOTO530
527 NEXT:STOP
530 Q=Q(C):PRINT@L(Q),;:M$=RIGHT$(STR$(D(Q)),1):GOSUB7:PRINT@L(T),;:M$=RIGHT$(STR$(D(T)),1):GOSUB7
594 I=0:FORR=1TOD(T):I=I+RND(6):NEXT:J=0:FORR=1TOD(Q):J=J+RND(6):NEXT
595 PRINT@(T(T)-1)*12,C$(T(T))I;:PRINT@(P-1)*12,C$(T(Q))J;
596 FORR=1TO750:NEXT:IFI>=JTHEND(Q)=1
597 IFI<JTHENA(T(T))=A(T(T))-1:A(P)=A(P)+1:D(T)=D(Q)-1:D(Q)=1:T(T)=T(Q):GOSUB60
598 PRINT@L(Q),RIGHT$(STR$(D(Q)),1);:PRINT@L(T),RIGHT$(STR$(D(T)),1);:Q=0:F=-1:GOSUB99
599 IFA(P)=42THENC=S:NEXTC:GOTO185
600 NEXTC:IFETHEN506
610 GOTO190
1000 DIMC1,CC,M$,M,R,C,P,R,T,S,X,Y,A,B,Q(288),T(42),L(42),D(42),A(3),C(3)
1005 DIMH(3),H,L,E,P,N,F,K,G,I,J,S(2),Z,Z(3),AP,C$(3),CC$(3),VI(3)
1010 M=RND(-(PEEK(9)*256+PEEK(10))):M=16384:C$(1)=CHR$(223):C$(2)=CHR$(239):C$(3)=CHR$(255):C(1)=223:C(2)=239:C(3)=255
1020 CC$(1)="CYAN":CC$(2)="MAGENTA":CC$(3)="ORANGE":D(0)=9:AP=0:S(1)=239:S(2)=223
1500 PRINT@480,"NO. OF HUMAN PLAYERS (0-3)     "CHR$(8)CHR$(8)CHR$(8)CHR$(8)CHR$(8);:INPUTN:IFN<0ORN>3THEN1500
1510 IFN=1THENAP=1:N=2
1520 IFN=0THENAP=2:N=2
1590 RETURN
5000 CLS
5010 PRINT"dicewars IS A SIMPLIFIED VERSIONOF RISK. THE GOAL IS TO CONTROL"
5020 PRINT"ALL 42 TERRITORIES. USE THE aszxKEYS TO MOVE. spacebar SELECTS."
5030 PRINT"ATTACKER'S ROLL WINS IF IT IS > DEFENDER. ALL BUT ONE DICE ARE"
5040 PRINT"MOVED. OTHERWISE, THE ATTACKER  IS REDUCED TO 1. enter=END TURN.";
5050 PRINT"LARGEST # CONTIGUOUS TERRITORIES=NEW DICE RANDOMLY DISTRIBUTED"
5060 PRINT"THROUGHOUT PLAYER'S TERRITORIES.MAXIMUM NUMBER OF DICE ALLOWED"
5070 PRINT"PER TERRITORY IS 8. SURPLUS DICEARE STORED. DICE CANNOT BE MOVED";
5080 PRINT"SO PLAN AHEAD. q=END COMBAT."
5090 RETURN
6000 CLS:M$="DICEWARS":PRINT@(32-LEN(M$))/2,;:GOSUB7:PRINT:PRINT
6010 PRINTTAB(2)"ORIGINAL PROGRAM: TARO ITO":PRINTTAB(3)"MC-10 REMAKE: JIM GERRIE":PRINT
6015 M$="VICTORIES":PRINT@160+(32-LEN(M$))/2,;:GOSUB7:PRINT
6020 PRINT:PRINT"CYAN"TAB(12)"MAGENTA"TAB(24)"ORANGE":PRINT:PRINTVI(1)TAB(12)VI(2)TAB(24)VI(3)
6030 M$="(H)ELP  (C)ONTINUE  (E)XIT":PRINT@480+(32-LEN(M$))/2,;:GOSUB7
6040 M$=INKEY$:IFM$=""THEN6040
6050 IFM$="H"THENGOSUB5000:GOTO6030
6060 IFM$="C"THENRETURN
6070 IFM$="E"THENEND
6080 GOTO6040
