290 FOR I = 1 TO HS: XDRAW 37 AT HY(I) *14,Y +(HX(I) *9): NEXT
300 REM SPOSTA I TANK
310 FOR K = 1 TO 6:TX = 0:TY = 0
320 IF XH(K) >0 THEN TX = XH(K):TY = YH(K)
330 IF TX = 0 THEN 480
340 HOME : INVERSE : VTAB 24: PRINT "MOSSE RESTANTI:"MV;: NORMAL : VTAB 21: HTAB 1: PRINT "NUOVA POSIZIONE DEL TANK N"K: PRINT "USA I-J-K-M PER SPOSTARE": PRINT "<SPAZIO> PER PIAZZARE IL TANK";
350 FOR L = 1 TO 11: XDRAW 31 AT TY *14,Y +(TX *9): FOR D = 1 TO 50: NEXT D,L:SH = 20 +K: XDRAW SH AT TY *14,Y +(TX *9)
370 IF R = TX AND C = TY THEN XDRAW SH AT TY *14,Y +(TX *9): XDRAW 31 AT TY *14,Y +(TX *9): GOTO 480
380 MX = ABS(TX -R):MY = ABS(TY -C):M = MX +MY
390 IF M >3 OR M >MV THEN PRINT : PRINT CHR$(7)"NON PUOI SPOSTARTI TANTO!": XDRAW SH AT YH(K) *14,Y +(XH(K) *9): XDRAW 31 AT YH(K) *14,Y +(XH(K) *9): GOSUB 3640: GOTO 340
400 IF A$(R,C) = "HQ" THEN XDRAW 32 AT C *14,Y +(R *9):A$(R,C) = ""
410 IF A$(R,C) = "AD" THEN XDRAW 33 AT C *14,Y +(R *9):A$(R,C) = "":
420 IF A$(R,C) = "FD" THEN XDRAW 34 AT C *14,Y +(R *9):A$(R,C) = ""
430 IF A$(R,C) = "" THEN A$(R,C) = STR$(K) +"H":XH(K) = R:YH(K) = C:A$(TX,TY) = "": XDRAW SH AT TY *14,Y +(TX *9): XDRAW 31 AT C *14,Y +(R *9):TX(K) = R:TY(K) = C: GOTO 460
450 IF A$(R,C) < >"" THEN HOME : PRINT CHR$(7)"QUESTO SPAZIO E' OCCUPATO": XDRAW SH AT YH(K) *14,Y +XH(K) *9: XDRAW 31 AT YH(K) *14,Y +XH(K) *9: GOSUB 3640: GOTO 340
460 MV = MV -M: IF MV = 0 THEN K = 6
470 TX = 0:TY = 0
480 NEXT : HOME
490 FOR I = 9 TO 16: FOR J = 1 TO 18: IF A$(I,J) = "MI2" THEN XDRAW 19 AT J *14,Y +(I *9)
500 NEXT J,I
510 GOSUB 1540: REM CONTROLLA SE C'E' UN VINCITORE
520 IF SC = 0 THEN 640
530 FOR I = 1 TO SC
540 IF A$(CX(I),CY(I)) = "" THEN PRINT "IL COLPO N "I" DEI VERDI E' A VUOTO": GOSUB 3580: GOTO 620
550 IF A$(CX(I),CY(I)) = "B" THEN HCOLOR= 3: DRAW 20 AT CY(I) *14,Y +(CX(I) *9):A$(CX(I),CY(I)) = "": PRINT "IL COLPO N "I" DEI VERDI ABBATTE BARRIERA": GOSUB 3580: GOTO 620
560 IF LEFT$(A$(CX(I),CY(I)),1) = "M" THEN GOSUB 3530: IF N/2 = INT(N/2) THEN PRINT "IL COLPO N "I" DEI VERDI E' A VUOTO": GOSUB 3580: GOTO 620
570 IF LEFT$(A$(CX(I),CY(I)),1) = "M" THEN A$(CX(I),CY(I)) = "": PRINT "IL COLPO N "I" DEI VERDI DISTRUGGE UNA MINA";: GOSUB 3580: GOTO 620
580 IF RIGHT$(A$(CX(I),CY(I)),1) = "H" THEN XDRAW 31 AT CY(I) *14,Y +(CX(I) *9): PRINT "IL COLPO N "I" DEI VERDI DISTRUGGE UN TANK" CHR$(7);:NU = VAL(A$(CX(I),CY(I))):TX(NU) = 0:TY(NU) = 0
590 IF RIGHT$(A$(CX(I),CY(I)),1) = "H" THEN GOSUB 3580:XH( VAL(A$(CX(I),CY(I)))) = 0:YH( VAL(A$(CX(I),CY(I)))) = 0:A$(CX(I),CY(I)) = "": GOTO 620
600 IF RIGHT$(A$(CX(I),CY(I)),1) = "C" THEN XDRAW 36 AT CY(I) *14,Y +(CX(I) *9):XC( VAL(A$(CX(I),CY(I)))) = 0:YC( VAL(A$(CX(I),CY(I)))) = 0: PRINT "IL COMPUTER HA COLPITO IL PROPRIO TANK!" CHR$(7):A$(CX(I),CY(I)) = "": GOSUB 3580: GOTO 620
610 PRINT "IL COLPO N "I" DEI VERDI E' A VUOTO": GOSUB 3580
620 FOR D = 1 TO 3000: NEXT : GOSUB 1540: NEXT
630 HOME :A = 31:B = 36
640 FOR K = 1 TO 6
650 IF TX(K) = 0 THEN 670
660 GOSUB 1130: REM CONTROLLA SE C'E' DUELLO DI TANK
670 TX(K) = 0:TY(K) = 0: NEXT K
680 GOSUB 1540: REM CONTROLLA SE C'E' UN VINCITORE
690 REM MOSSA DEI VERDI
700 HOME :M$ = "IL COMPUTER PIAZZA I COLPI DEI VERDI": GOSUB 3650
710 MV = 0:FL = 0:HQ = 0:SC = 0:B$ = "H"
720 FOR I = 1 TO 16: FOR J = 1 TO 18
730 IF A$(I,J) = "AD" THEN SC = 6
740 IF A$(I,J) = "FD" THEN FL = 1
750 IF A$(I,J) = "HQ" THEN HQ = 1
760 IF RIGHT$(A$(I,J),1) = "C" THEN MV = MV +1: IF SC < >6 THEN SC = SC +1
770 NEXT J,I: IF FL = 1 THEN MV = MV *2:FL = 0
780 IF NOT HQ THEN SC = INT(SC/2): IF SC = 0 THEN SC = 1
790 REM SCEGLIE I COLPI DEI VERDI
800 S = 0
810 FOR K = 6 TO 1 STEP -1
820 IF XH(K) >0 THEN I = XH(K):J = YH(K):S = S +1: GOSUB 1660: IF S = SC THEN K = 1
830 NEXT
840 IF S <SC THEN 810
850 IF TU THEN TU = 0: RETURN
860 HOME :M$ = "TOCCA AI VERDI SPOSTARE I TANK": GOSUB 3650
870 NU = 4: GOSUB 3530: IF N/2 = INT(N/2) THEN W = 1: FOR K = 6 TO 1 STEP -1:TX = 0:TY = 0: GOTO 890
880 FOR K = 1 TO 6:TX = 0:TY = 0
890 IF XC(K) >0 THEN I = XC(K):J = YC(K): GOSUB 1960:MV = MV -S
900 IF W AND MV < = 0 THEN K = 1
910 IF NOT W AND MV < = 0 THEN K = 6
920 REM
930 NEXT K:W = 0
940 GOSUB 1540: REM CONTROLLA SE C'E' UN VINCITORE
950 HOME : FOR I = 1 TO HS
960 IF A$(HX(I),HY(I)) = "" THEN PRINT "IL COLPO N "I" DEI ROSSI E' A VUOTO": GOSUB 3610: GOTO 1040
970 IF A$(HX(I),HY(I)) = "B" THEN HCOLOR= 3: DRAW 20 AT HY(I) *14,Y +(HX(I) *9):A$(HX(I),HY(I)) = "": PRINT "IL COLPO N "I" DEI ROSSI ABBATTE OSTACOLO": GOSUB 3610: GOTO 1040
980 IF LEFT$(A$(HX(I),HY(I)),1) = "M" THEN GOSUB 3530: IF N/2 = INT(N/2) THEN PRINT "IL COLPO N "I" DEI ROSSI E' A VUOTO": GOSUB 3610: GOTO 1040
990 IF LEFT$(A$(HX(I),HY(I)),1) = "M" THEN A$(HX(I),HY(I)) = "": PRINT "IL COLPO N "I" DEI ROSSI FA SALTARE MINA": GOSUB 3610: GOTO 1040
1000 IF RIGHT$(A$(HX(I),HY(I)),1) = "C" THEN XDRAW 36 AT HY(I) *14,Y +(HX(I) *9): PRINT "IL COLPO N "I" DEI ROSSI DISTRUGGE UN TANK" CHR$(7):NU = VAL(A$(HX(I),HY(I))):TX(NU) = 0:TY(NU) = 0
1010 IF RIGHT$(A$(HX(I),HY(I)),1) = "C" THEN GOSUB 3610:XC(NU) = 0:YC(NU) = 0:A$(HX(I),HY(I)) = "": GOTO 1040
1020 IF RIGHT$(A$(HX(I),HY(I)),1) = "H" THEN XDRAW 31 AT HY(I) *14,Y +(HX(I) *9):XH( VAL(A$(HX(I),HY(I)))) = 0:YH( VAL(A$(HX(I),HY(I)))) = 0: PRINT "I ROSSI HANNO COLPITO IL PROPRIO TANK!" CHR$(7):A$(HX(I),HY(I)) = "": GOSUB 3610: GOTO 1040
1030 PRINT "IL COLPO N "I" DEI ROSSI E' A VUOTO": GOSUB 3610
1040 GOSUB 3640:HX(I) = 0:HY(I) = 0: GOSUB 1540: NEXT
1050 HOME
1060 FOR K = 1 TO 6
1070 IF TX(K) = 0 THEN 1100
1080 A = 36:B = 31
1090 GOSUB 1130: REM CONTROLLA SE C'E' DUELLO DI TANK
1100 TX(K) = 0:TY(K) = 0: NEXT K
1110 GOSUB 1540: REM CONTROLLA SE C'E' UN VINCITORE
1120 HOME : GOTO 150
1130 REM ROUTINE PER CONTROLLARE SE C'E' DUELLO DI TANK
1140 D = 1
1150 ON D GOSUB 1180,1240,1300,1360
1160 D = D +1: IF D = 5 THEN D = 1: RETURN
1170 GOTO 1150
1180 R = TX(K) -1:C = TY(K): IF R = <1 THEN RETURN
1190 IF RIGHT$(A$(R,C),1) = B$ THEN 1210
1200 RETURN
1210 GOSUB 1420
1220 IF NOT FL THEN RETURN
1230 FL = 0:D = 4: RETURN
1240 R = TX(K) +1:C = TY(K): IF R >16 THEN RETURN
1250 IF RIGHT$(A$(R,C),1) = B$ THEN 1270
1260 RETURN
1270 GOSUB 1420
1280 IF NOT FL THEN RETURN
1290 FL = 0:D = 4: RETURN
1300 R = TX(K):C = TY(K) -1: IF C <1 THEN RETURN
1310 IF RIGHT$(A$(R,C),1) = B$ THEN 1330
1320 RETURN
1330 GOSUB 1420
1340 IF NOT FL THEN RETURN
1350 FL = 0:D = 4: RETURN
1360 R = TX(K):C = TY(K) +1: IF C >18 THEN RETURN
1370 IF RIGHT$(A$(R,C),1) = B$ THEN 1390
1380 RETURN
1390 GOSUB 1420
1400 IF NOT FL THEN RETURN
1410 FL = 0:D = 4: RETURN
1420 REM DUELLO
1430 FOR I = 1 TO 5: PRINT CHR$(7): NEXT : HOME : HTAB 17: FLASH : PRINT "DUELLO": NORMAL : FOR I = 1 TO 3000: NEXT
1440 FOR I = 1 TO 10: XDRAW A AT TY(K) *14,Y +(TX(K) *9): XDRAW B AT C *14,Y +(R *9): FOR J = 1 TO 50: NEXT : NEXT
1450 IF K = VAL( LEFT$(A$(R,C),1)) THEN XDRAW A AT TY(K) *14,Y +(TX(K) *9): XDRAW B AT C *14,Y +(R *9):FL = 1: HOME : PRINT "ENTRAMBI I TANK SONO DISTRUTTI":A$(R,C) = "":A$(TX(K),TY(K)) = "":XC(K) = 0:YC(K) = 0:XH(K) = 0:YH(K) = 0: GOTO 1530
1460 IF B$ = "C" THEN 1490
1470 IF K < VAL( LEFT$(A$(R,C),1)) THEN XDRAW 36 AT TY(K) *14,Y +(TX(K) *9):A$(TX(K),TY(K)) = "":XC(K) = 0:YC(K) = 0: HOME : PRINT "TANK DEI VERDI DISTRUTTO!": GOTO 1530
1480 GOTO 1520
1490 IF K > VAL( LEFT$(A$(R,C),1)) THEN XDRAW 36 AT C *14,Y +(R *9):XC( VAL(A$(R,C))) = 0:YC( VAL(A$(R,C))) = 0:A$(R,C) = "": HOME : PRINT "TANK DEI VERDI DISTRUTTO!": GOTO 1530
1500 XDRAW 31 AT TY(K) *14,Y +(TX(K) *9):FL = 1: HOME : PRINT "TANK DEI ROSSI DISTRUTTO!":XH( VAL(A$(TX(K),TY(K)))) = 0:YH( VAL(A$(TX(K),TY(K)))) = 0:A$(TX(K),TY(K)) = ""
1510 GOTO 1530
1520 XDRAW 31 AT C *14,Y +(R *9):FL = 1: HOME : PRINT "TANK DEI ROSSI DISTRUTTO":XH( VAL(A$(R,C))) = 0:YH( VAL(A$(R,C))) = 0:A$(R,C) = ""
1530 FOR I = 1 TO 4000: NEXT : RETURN
1540 REM CERCA UN VINCITORE
1550 H = 0:C = 0
1560 FOR WI = 1 TO 6
1570 IF XC(WI) >0 THEN C = C +1
1580 IF XH(WI) >0 THEN H = H +1
1590 NEXT
1600 IF H = 0 AND C = 0 THEN FOR I = 1 TO 5: PRINT CHR$(7): NEXT : PRINT "LA PARTITA E' FINITA IN PARITA'. VUOI PROVARE ANCORA ?";: GOTO 1640
1610 IF H = 0 THEN FOR I = 1 TO 5: PRINT CHR$(7): NEXT : HOME : PRINT "COMBATTIMENTO VINTO DAI VERDI.": PRINT "VUOI PROVARE ANCORA?";: GOTO 1640
1620 IF C = 0 THEN FOR I = 1 TO 5: PRINT CHR$(7): NEXT : HOME : PRINT
1630 RETURN : REM RESTANO ANCORA TANK
1640 INPUT "";A$: IF LEFT$(A$,1) = "N" THEN GOTO 4200
1650 CLEAR : GOTO 120
1660 REM SCEGLIE POSIZIONE COLPO DEI VERDI
1670 NU = 10: GOSUB 3530
1680 IF N/2 = INT(N/2) THEN D = 4: GOTO 1710
1690 IF N = 1 OR N = 3 OR N = 9 THEN NU = 2: GOSUB 3530:D = 1 +N: GOTO 1710
1700 IF N = 5 OR N = 7 OR N = 10 THEN D = 1
1710 NU = 3: GOSUB 3530: IF N = 3 THEN NU = 2: GOSUB 3530: ON D GOSUB 1860,1910,1910,1860: IF DI THEN DI = 0:NU = 2: GOTO 1730
1720 NU = 3
1730 GOSUB 3530: ON D GOTO 1740,1770,1800,1830
1740 IF I +N >16 THEN 1670
1750 IF RIGHT$(A$(I +N,J),1) < >"1" AND RIGHT$(A$(I +N,J),1) < >"C" THEN CX(S) = I +N:CY(S) = J: RETURN
1760 GOTO 1670
1770 IF J -N <1 THEN 1670
1780 IF RIGHT$(A$(I,J -N),1) < >"1" AND RIGHT$(A$(I,J -N),1) < >"C" THEN CX(S) = I:CY(S) = J -N: RETURN
1790 GOTO 1670
1800 IF J +N >18 THEN 1670
1810 IF RIGHT$(A$(I,J +N),1) < >"1" AND RIGHT$(A$(I,J +N),1) < >"C" THEN CX(S) = I:CY(S) = J +N: RETURN
1820 GOTO 1670
1830 IF I -N <1 THEN 1670
1840 IF RIGHT$(A$(I -N,J),1) < >"1" AND RIGHT$(A$(I -N,J),1) < >"C" THEN CX(S) = I -N:CY(S) = J: RETURN
1850 GOTO 1670
1860 IF N = 1 THEN 1890
1870 IF J -1 <1 THEN RETURN
1880 J = J -1:DI = 1: RETURN
1890 IF J +1 >18 THEN RETURN
1900 J = J +1:DI = 1: RETURN
1910 IF N = 1 THEN 1940
1920 IF I -1 <1 THEN RETURN
1930 I = I -1:DI = 1: RETURN
1940 IF I +1 >16 THEN RETURN
1950 I = I +1:DI = 1: RETURN
1960 REM SPOSTA TANK DEI VERDI
1970 TX = I:TY = J:FL = 0:TI = 0:S = 0
1980 FOR D = 1 TO 16
1990 IF RIGHT$(A$(D,J),1) = "H" OR A$(D,J) = "HQ2" OR A$(D,J) = "AD2" OR A$(D,J) = "FD2" THEN FL = D
2000 NEXT D: IF FL < >0 THEN GOTO 2400
2010 FOR D = 1 TO 18
2020 IF RIGHT$(A$(I,D),1) = "H" OR A$(I,D) = "HQ2" OR A$(I,D) = "AD2" OR A$(I,D) = "FD2" THEN FL = D
2030 NEXT D: IF FL < >0 THEN GOTO 2420
2040 NU = 4: GOSUB 3530:TI = TI +1: IF TI >10 THEN RETURN
2050 FL = 0: ON N GOTO 2120,2190,2260,2330
2060 IF A$(TR,TC) = "HQ2" THEN XDRAW 32 AT TC *14,Y +(TR *9):A$(TR,TC) = ""
2070 IF A$(TR,TC) = "AD2" THEN XDRAW 33 AT TC *14,Y +(TR *9):A$(TR,TC) = ""
2080 IF A$(TR,TC) = "FD2" THEN XDRAW 34 AT TC *14,Y +(TR *9):A$(TR,TC) = ""
2090 IF A$(TR,TC) = "" THEN XDRAW 36 AT TY *14,Y +(TX *9):A$(TR,TC) = A$(I,J):XC(K) = TR:YC(K) = TC:A$(I,J) = "": XDRAW 36 AT TC *14,Y +(TR *9):TX(K) = TR:TY(K) = TC: GOTO 2440
2100 IF A$(TR,TC) = "MI2" THEN XDRAW 36 AT TY *14,Y +(TX *9): FOR D = 1 TO 50: XDRAW 35 AT TC *14,Y +(TR *9): NEXT :A$(TR,TC) = "":XC(K) = 0:YC(K) = 0:A$(TX,TY) = "": HOME : PRINT CHR$(7)"TANK DISTRUTTO DA UNA MINA!": GOSUB 3640