home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 35
/
035.d81
/
mindbender
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
6KB
|
192 lines
1 poke53281,1:poke53280,2:gosub4050
70 at=679:for i=at to at+22:readx:pokei,x:next
72 poke198,0:wait198,1:poke198,0
74 print"[147]":as=3:mm=1:goto890
80 data32,180,2,132,251,32,180,2
90 data166,251,76,240,255,32,253,174
100 data32,158,173,32,170,177,96
110 pokevo,15:pokewv,17:pokeak,15:pokehi,58:pokelo,149
120 fortm=1to100:nexttm:pokewv,0
130 pokewv,17:pokehi,34:pokelo,75:fortm=1to100:nexttm:pokewv,0:return
140 :
150 sys at,1,14:printchr$(142)"[151]mindbender[146]";
155 if(mm)thensys at,24,12:print"[144][sample screen]":mm=.:goto160
157 sys at,24,14:print"[144][f7 quits]"
160 er=0:co$="":ro$="":ct=fre(0)
170 sys at,4,13:print"[144]a[146] b[146] c[146] d[146] e[146]";
180 sys at,6,12:printa$(b(1))u$a$(b(4))u$a$(b(7)):sys at,7,10:print"[144]1 ";
190 if val(f2$)=1 thengosub110
200 sys at,9,12:printa$(b(2))u$a$(b(5))u$a$(b(8)):sys at,10,10:print"[144]2 ";
210 if val(f2$)=2 thengosub110
220 sys at,12,12:printa$(b(3))u$a$(b(6))u$a$(b(9))u$a$(b(12))u$a$(b(15))
230 if val(f2$)=3 thengosub110
240 sys at,13,10:print"[144]3 ";:sys at,15,30:print"[144]move #";
250 sys at,15,18:printa$(b(10))u$a$(b(13))u$a$(b(16)):sys at,16,10:print"[144]4 ";
260 if val(f2$)=4 thengosub110
270 sys at,18,18:printa$(b(11))u$a$(b(14))u$a$(b(17)):sys at,19,10:print"[144]5 ";
280 if val(f2$)=5 thengosub110
290 ifd$=e$thener=3:goto760
300 if as=0 or as=3 then320
310 zz=zz+2:cr$=mid$(slv$,zz,2):co$=left$(cr$,1):ro$=right$(cr$,1)
312 geta$:ifa$="[136]"thengosub2000
315 goto410
320 sys at,22,9:print"enter move [col[146],row]: [157][157]";:poke198,0
330 if as<>3then340
331 fortm=1to2500
332 ifpeek(198)<>0thentm=2500
334 nexttm
335 print"[147]":poke53281,0:goto1130
340 poke198,0:wait198,1:getco$
342 ifco$<>"[133]"andco$<>"[136]"andco$>"z"thenco$=chr$(asc(co$)-128)
350 fori=1to7:ifco$=mid$("[133][136]abcde",i,1)thenprint""co$"[146]";:poke198,0:goto370
360 next:goto340
370 ifco$="[133]"then as=1:goto990:rem - autosolve
380 ifco$="[136]"thengosub2000:goto320
390 getro$:fori=1to7:ifro$=mid$("[133][136]12345",i,1)thenprintro$;:goto410
400 next:goto390
410 ifro$="[136]"thengosub2000:goto320
412 ifro$="[133]"then as=1:goto990:rem - autosolve
415 co=asc(co$)-64:ro=val(ro$):f2$=ro$:
420 if as=1then sys at,22,31:print""co$;"[146]"ro$;:cr$=""
430 ifco=1orco=2thenifro=4orro=5thener=1:goto760:rem - error rtn.
440 ifco=4orco=5thenifro=1orro=2thener=1:goto760
450 h=(co*10)+ro:f1=h:gosub640:ifer=1then760
460 fr=h:fori=1to17:ifmid$(d$,i,1)="3"thenh=i:tu=h
470 next:gosub700:t1=h
480 :
490 if abs(f1-t1)=9 or abs(f1-t1)=11 then er=1:goto760
500 if c(fr)=3 then er=2:goto760
510 if f1>t1 then550
520 if abs(f1-t1)=20 and c(fr)=c(fr+3) thener=1:goto760
530 if abs(f1-t1)=2 and c(fr)=c(fr+1)thener=1:goto760
540 goto570
550 if abs(f1-t1)=20 and c(fr)=c(fr-3)thener=1:goto760
560 if abs(f1-t1)=2 and c(fr)=c(fr-1)thener=1:goto760
570 ft=abs(fr-tu)
580 if ft<>1 and ft<>2 and ft<>3 and ft<>6 then er=1:goto760
590 :
600 c=c(tu):c(tu)=c(fr):c(fr)=c
610 d$="":forx=1to17:d$=d$+right$(str$(c(x)),1):next
620 forx=1to17:b(x)=c(x):next
630 mv=mv+1:mv$="":mv$=str$(mv):sys at,17,31:print mv$;:goto150
640 ifh>=11thenifh<=13thenh=h-10:return
650 ifh>=21thenifh<=23thenh=h-17:return
660 ifh>=31thenifh<=35thenh=h-24:return
670 ifh>=43thenifh<=45thenh=h-31:return
680 ifh>=53thenifh<=55thenh=h-38:return
690 er=1:return
700 ifh<=3thenh=h+10:return
710 ifh<=6thenh=h+17:return
720 ifh<=11thenh=h+24:return
730 ifh<=14thenh=h+31:return
740 h=h+38:return
750 :
760 if as=1 then er=5
770 b1=770+(er*10):poke785,188:poke786,168:pokeb1,peek(b1):b1=usr(0)
780 er$="[144]illegal entry[146]":goto830
790 er$="[144]position empty[146]":goto830
800 er$="[144]congratulations!![146]":goto830
810 er$="[144]thanks for playing. 'bye.[146]":goto830
820 er$="[144]puzzle solved![146]"
830 c=(22-len(er$)/2):sys at,24,c:printer$;
831 poke54296,15:form=1to3:forz=70to100step5
833 poke54273,z
834 poke54272,.
835 poke54277,15
836 poke54278,10
837 poke54276,17
838 next:next:poke54276,.
850 poke781,24:sys59903:er$="":f2$="":ifer<3then150
860 if as<>2 then870
861 goto3010
870 er=4:as=2:goto770
880 :
890 dim a$(3),b(17),c(17)
900 :
910 u$="[145][145]"
920 a$(1)=" [146][157][157][157] [146][144][209] [146][157][157][157] [146]"
930 a$(2)=" [146][157][157][157] [146][209] [146][157][157][157] [146]"
940 a$(3)=" [157][157][157] [158] [157][157][157] [146]"
950 e$="22222222311111111":rem - solution format
960 :
970 vo=54296:wv=54276:ak=54277:hi=54273:lo=54272:f2=0:f2$=""
980 :
990 d$="11111111322222222":rem - puzzle format
1000 for x=1 to 17:b(x)=val(mid$(d$,x,1)):c(x)=b(x):next
1010 if as=3 then1080
1020 mv=0:zz=-1:f2$="":sys at,17,31:print" ";
1030 :
1040 slv$="d3b3a3c3c4c2c1c3c5d5d3b3c3e3e4c4c2b2b3b1a1a3c3"
1050 slv$=slv$+"e3e5d5d3d4c4c2a2a3c3d3b3b1c1c3c5c4c2c3e3d3b3c3"
1060 print"";:goto150
1070 :
1080 poke53281,0:sys at,1,14:print"[205][201][206][196][194][197][206][196][197][210][146]":print:sys at,5,1
1090 print" [211]ixteen checkers are on opposite"
1100 print" sides of the puzzle board.":print
1110 print:print" [212]hey are arranged as shown on the"
1111 print"following sample screen:":fortm=1to1000
1112 ifpeek(198)<>0thentm=1000
1114 nexttm
1120 poke53281,10:print"[147]":goto150
1130 sys at,1,13:print"[205][201][206][196][194][197][206][196][197][210][146]":print
1140 print" [201]t is your job to reverse the positions"
1142 print"[145]of the checkers.":print
1150 print" [205]ove the black checkers only down and"
1160 print"to the right.":print
1170 print" [205]ove the white checkers only up and ":print"to the left.":print
1180 print" [217]ou may move to an adjacent empty"
1182 print"space or jump over an opposite checker.":print
1184 print" [196]iagonal moves are not allowed.":print
1190 print" [208]ress '[198]1' for auto-solve; '[198]7' to end":print
1200 print"<[212]his puzzle can be solved in 46 moves.>"
1210 sys at,24,10:print"[208]ress [210][197][212][213][210][206][146] to begin";:poke198,.
1220 get rt$:if rt$<>chr$(13) then1220
1230 as=0:poke53281,10:print"[147]":goto150
2000 :
2010 sys at,24,5:print"are you sure you want to quit?"
2020 poke198,0:wait198,1:getag$
2030 ifag$<>"y"andag$<>"[217]"andag$<>"n"andag$<>"[206]"then2020
2040 ifag$="[217]"orag$="y"then3000
2050 sys at,24,5:print" "
2055 sys at,24,14:print"[144][f7 quits]"
2060 return
2070 :
3000 :
3010 print"[147]":sys at,10,2:print"would you like to play again (y/n)?"
3020 poke198,0:wait198,1:getag$
3030 ifag$<>"y"andag$<>"[217]"andag$<>"n"andag$<>"[206]"then2020
3040 ifag$="[206]"orag$="n"then4000
3050 run
3060 :
4000 :
4010 open15,8,15,"r0:hello connect=hello connect":input#15,er:close15
4020 ifer<>63thenprint"[147]":end
4030 load"hello connect",8
4040 end
4050 print"[147]"chr$(142)
4060 print" "
4070 print" loadstar presents [144] "
4080 print" [144] "
4090 print" "
4100 print
4120 print
4130 print
4140 print" "
4150 print" mindbender [144] "
4160 print" [144] "
4170 print" written by daniel miller [144] "
4180 print" [144] "
4190 print" "
4200 print
4210 print" (c) 1987"
4220 print
4230 print" loadstar is not public domain"
4240 print" please respect the author's rights."
4250 print
4260 print" [129] "
4270 print" press any key [144] "
4280 print" [129] [144] "
4290 print" ";
4300 print"";
4310 return