home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 31
/
031.d81
/
othello
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
208 lines
0 goto80
5 :
10 poke54276,.:poke54296,15:poke54273,hf:poke54272,100:poke54277,10:poke54278,10
20 poke54276,33:return
30 :
80 poke53280,3:poke53281,3
90 print"[147]"tab(11)"loadstar presents:"
95 print" [213][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][201]"
100 print"[142] [221][213][192][201] [192][178][192] [201] [213] [213][192][192] [201] [201] [213][192][201][221]"
110 print" [221][221] [221] [221] [171][192][179] [171][192] [221] [221] [221] [221][221]
120 [153]" (NULL)mid$tan(NULL) > (NULL) mid$ mid$tantan mid$tan mid$tan mid$tan(NULL)(NULL)
125 print" [202][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][203]"
130 print,"[149][157] commodore 64 version":printtab(19)"by
140 [153],"stop paul formisano"
150 [129]i[178]1[164]39:e$[178]e$[170]" ":[130]:[129]j[178]1[164]39:e$[178]e$[170]"cmd":[130]:n$[178]"12345678"
160 d$[178]"":[129]i[178]1[164]20:d$[178]d$[170]"":[130]:[134]a(9,9),i4(7),j4(7):f2[178]3:b[178][171]1:w[178]1:m$[178]"(NULL)(NULL)(NULL)"
170 m$[178]" stop(NULL)print# (NULL)":[129]k[178]0[164]7:[135]i4(k),j4(k):[130]
180 [141]1440:[141]1340:p[178]6:n$(b[170]1)[178]"black":n$(w[170]1)[178]"white
190 print"[147][144]want to play the computer? (y/n) ";:gosub820
200 ifx$="n"thenprint"no":goto320
210 ifx$<>"y"thengosub820:goto200
220 print"yes":f2=3:print"[144]should i play my best? ";:gosub820
230 ifx$="n"thenprint"no":goto260
240 ifx$<>"y"thengosub820:goto230
250 print"yes":s2=2:s4=1:s5=-1.5
260 print"[144]black always goes first."
270 print"do you want black or white? [144]";:gosub820
280 ifx$="b"thenprintn$(0):n$(2)="computer":goto310
290 ifx$<>"w"thengosub820:goto280
300 printn$(2):n$(0)="computer":f2=2
310 gosub1820
320 print"[147]";:gosub680:iff2=2thenprint" thinking...[144]"
330 t1=b:t2=w:onf2gosub920,1080,920
340 gosub1310:ifz=1then360
350 bc=bc+s1+1:wc=wc-s1:n1=n1+1:gosub680
360 ifwc=0orn1=64orz<0then410
365 gosub2100
370 t1=w:t2=b:on f2gosub920,920,1080:gosub1310:ifz=1then390
380 wc=wc+s1+1:bc=bc-s1:n1=n1+1:gosub680
390 ifbc=0orn1=64orz<0then410
400 gosub2100:goto330
410 sn=sm
420 printd$;e$:printe$:printe$:printd$;e$"[144]black has"bc" white has"wc""
430 ifbc=wcthenprint"a tie !!":goto530
440 ifbc>wcthenprint"black";:goto460
450 print"white";
460 print" wins.":cc=bc-wc:ifcc<0thencc=-cc
470 cc=(64*cc)/n1:print"[144]that was a ";
480 ifcc<11thenprint"close game.":goto530
490 ifcc<25thenprint"good game.":goto530
500 ifcc<39thenprint"big win.":goto530
510 ifcc<53thenprint"walkover.":goto530
520 print"perfect score."
530 print"want to see replay of the game? [157][157][157][157]";:gosub820:ifx$="n"then2000
540 print"[144]yes";:gosub1350:z8=-1:gosub1370:gosub420:z8=.
550 printd$""e$"do you want to start the game ? ";
560 gosub820:ifx$="y"thenprint"yes";:gosub1820:print"[147]";:goto180
570 print"no";:end
580 f1=0:fori1=-1to1:forj1=-1to1:ifa(i+i1,j+j1)=t2then600
590 nextj1,i1:return
600 f1=1:return
610 s1=0:fork=0to7:i5=i4(k):j5=j4(k):i6=i+i5:j6=j+j5:s3=0:ifa(i6,j6)<>t2then670
620 s3=s3+1:i6=i6+i5:j6=j6+j5:ifa(i6,j6)=t1then650
630 ifa(i6,j6)=0 then670
640 goto620
650 s1=s1+s3:ifu<>1then670
660 i6=i:j6=j:fork1=0tos3:a(i6,j6)=t1:i6=i6+i5:j6=j6+j5:nextk1
670 nextk:return
680 print"
690 x$[178]" -tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan(NULL)tantantan<"
700 [153]" a b c d e f g h"
710 [153]" ortantantan=tantantan=tantantan=tantantan=tantantan=tantantan=tantantan=tantantan^
720 fori=1to8:printmid$(n$,i,1)" [221] ";
725 getz$:ifz$="q"then2000
730 forj=1to8:printmid$(m$,(a(i,j)+2)*2,2)" [221] ";:nextj:print:ifi<>8thenprintx$
735 getz$:ifz$="q"then2000
740 nexti:print" [173][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][177][192][192][192][189]":ifz8thenprint""
741 ifz8=.thenprint" to forfeit a move, type: 0 a"
742 ifz8then745
743 print"[144]black pieces: [157][157][157][157]"bc;tab(20)"white pieces: [157][157][157][157]"wc"[144][145][145][145][145][145]"
745 getz$:ifz$="q"then2000
746 return
750 i=-1:j=i:fork=1to2:gosub820:ifx$="q"then2000
755 g=asc(x$):if47<gandg<58theni=g-48:goto780
760 if64<gandg<74thenj=g-64:goto780
770 next:return
780 print""x$"[144] ";:next:return
790 printleft$(d$,2*(i-1)+4);spc(4*(j-1)+4);:x$=mid$(m$,(t1+2)*2,2):fork=1top
800 print"[144] [157]";:forl=1to20:next:printx$"[157]";:forl=1to20:next:next:return
810 printx$"[157]";:forl=1to20:next:next:return <
820 forl=1to10:geta$:next
830 l=0:print" [157][146]";
840 l=l+1:getx$:ifx$<>""thenreturn
850 ifl<20then840
860 print" [157]";
870 l=l+1:getx$:ifx$<>""thenreturn
880 ifl<40then870
890 goto830
900 printd$""e$"bad move[144] input row 0-8[144] and col a-h[144]":printe$;
905 hf=30:gosub10
910 gosub1440:iff1>1thengosub680
920 rem move input subroutine
930 printd$;e$"input "n$(t1+1)"'s move <q quits>";:gosub750
940 ifi<0orj<0ori>8orj>8then900
950 ifi<>0then1000
960 g2=s2:g4=s4:g5=s5:s2=0:s4=0:s5=0:gosub1170:s2=g2:s4=g4:s5=g5:ifb1<0then980
970 printd$""e$"no forfeit allowed. "n$(t1+1)"[146] has a move."
975 hf=30:gosub10:goto1060
980 ifz=1thenz=-z:return
990 z=1:return
1000 if a(i,j)=0then1020
1010 printd$""e$"sorry...square occupied by "n$(a(i,j)+1)
1015 hf=30:gosub10:goto1060
1020 gosub580:iff1=1then1040
1030 printd$""e$"sorry...not next to "n$(t2+1)
1035 hf=30:gosub10:goto1060
1040 u=-1:gosub610:ifs1>0then1070
1050 printd$""e$"sorry...does not contain "n$(t2+1)
1060 printe$:hf=30:gosub10:goto930
1070 goto1140
1080 gosub1170:ifb1>0then1130
1090 ifs5=0then1110
1100 s5=0:goto1080
1110 printd$""e$n$(t1+1)" forfeits move":ifz=1thenz=-z
1111 ifz=.thenz=1
1115 hf=20:gosub10:hf=10:gosub10
1120 return
1130 i=i3:j=j3
1140 forl=1to37:printchr$(20);:next:ifn$(t1+1)="computer"thenhf=100:gosub10
1150 printd$""e$;n$(t1+1)" moves to "chr$(i+48)" "chr$(j+64):gosub790:z=0:u=1
1152 getz1$:ifz1$="q"then2000
1160 gosub610:printd$"[144]"e$;n$(t1+1)" takes"s1"of "n$(t2+1)"'s pieces"
1161 getz1$:ifz1$="q"then2000
1165 return
1170 b1=-1:i3=0:j3=0:fori=1to8:forj=1to8:ifa(i,j)<>0then1300
1180 gosub580:iff1=0then1300
1190 u=-1:gosub610:ifs1=0then1300
1200 if(i=1)or(i=8)thens1=s1+s2
1210 if(j=1)or(j=8)thens1=s1+s2
1220 if(i=2)or(i=7)thens1=s1+s5
1230 if(j=2)or(j=7)thens1=s1+s5
1240 if(i=3)or(i=6)thens1=s1+s4
1250 if(j=3)or(j=6)thens1=s1+s4
1260 ifs1<b1then1300
1270 ifs1>b1then1290
1280 ifrnd(1)>0.5then1300
1290 b1=s1:i3=i:j3=j
1300 nextj,i:return
1310 l=((t1+1)*64)and128:ifz<>0thenl=lor64:goto1330
1320 l=lor((((i-1)*8)and56)or(j-1and7))
1330 pokesm,l:sm=sm+1:return
1340 bc=2:wc=bc:n1=4
1350 fori=0to9:forj=0to9:a(i,j)=0:nextj,i:a(4,4)=w:a(5,5)=w:a(4,5)=b:a(5,4)=b
1360 z=0:f2=1:s2=0:s4=0:s5=0:sm=826:return
1370 print"[147][144] replay <press q to quit[144]> replay"
1375 p=3:ford=826tosn-1:gosub680:l=peek(d)
1380 i=1+(land56)/8:j=1+(land7):t1=b:t2=w:ifland128thent1=w:t2=b
1390 if(land64)=0then1410
1400 printd$e$:printe$:printe$:printd$""n$(t1+1)"[146] forfeits a move":forl=1to100
1405 next:next
1410 gosub1140
1420 next
1430 goto680
1440 f1=0:print"do you want instructions? (y/n) ";:gosub820
1450 ifx$="n"thenprintchr$(13)"[145] [145][145]";:return
1460 ifx$<>"y"thengosub820:goto1450
1470 print"[144]yes";:forf1=1to1000:next
1480 print"[147]othello[144] is played on an 8 x 8 grid with
1490 [153]"rows 1stop to 8stop and columns astop to hstop.
1500 print"the object of the game is to capture as"
1510 print"many of the opponent's pieces as"
1520 print"possible. to capture pieces, place your
1530 [153]"piece so that a horizontal, vertical
1540 print"or diagonal line of your opponent's
1550 [153]"pieces is contained by yours.
1560 print" [192][192][192][219][192][192][192][219][192][192][192][219][192][192][192][219][192][192][192][219][192][192][192]"
1570 print" [221] [144][209] [221] [144][209] [221] [144][209] [221] [144][209] [221] [209]"
1580 print" [192][