home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 6
/
006.d81
/
othello
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
7KB
|
319 lines
10 rem * othello
11 rem * by mark jeske
12 rem * translated and revised for
13 rem * the commodore 64 by
14 rem * donna k. woody
20 gosub10000
30 goto1000
40 :
50 rem * valid input check
60 n=0
70 ifb(i)<>0then180
80 forj=0to7
90 k=i+o(j)
100 ifb(k)<>1then170
110 k=k+o(j)
120 ifb(k)=1then110
130 ifb(k)<>2then170
140 k=k-o(j)
150 ifk=ithen170
160 n=n+1:f(n)=k:goto140
170 nextj
180 return
188 :
189 rem * computer move check
190 n=0
200 ifb(i)<>0then320
210 forj=0to7
220 k=i+o(j)
230 ifb(k)<>2then310
240 k=k+o(j)
250 ifb(k)=2then240
260 ifb(k)<>1then310
270 k=k-o(j)
280 ifk=ithen310
290 n=n+1:f(n)=k
300 goto270
310 nextj
320 return
338 :
339 rem * begin computer moves
340 poke781,19:poke782,0:sys65520
341 print"my pieces - [157][157][157][157]"cp" ";tab(20)"your pieces - [157][157][157][157]"op" "
345 if level=1thengoto600
350 ifop+cp>51andlevel=2thengoto600
360 ifop+cp>51andlevel=3thengoto700
370 forl=1to60
380 i=p(l)
390 gosub190
400 ifn>0then440
410 nextl
420 poke781,20:poke782,0:sys65520:print"i cannot move."
430 goto590
440 poke781,20:poke782,0:sys65520:print"i move to ";
450 ifi>80andi<89thenprint"a";:goto530
460 ifi>70andi<79thenprint"b";:goto530
470 ifi>60andi<69thenprint"c";:goto530
480 ifi>50andi<59thenprint"d";:goto530
490 ifi>40andi<49thenprint"e";:goto530
500 ifi>30andi<39thenprint"f";:goto530
510 ifi>20andi<29thenprint"g";:goto530
520 ifi>10andi<19thenprint"h";
530 printi-(10*int(i/10))" and flip "n" of your"
535 poke781,21:poke782,0:sys65520:print"pieces."
540 b(i)=1
550 forj=1ton
560 b(f(j))=1
570 nextj
580 gosub1450
585 forx=1to100:nextx:poke781,20:poke782,0:sys65520:forx=1to120:print" ";:next
590 goto1030
598 :
599 rem * level 1 & 2 last moves
600 x=0:y=0
610 forl=1to60
620 i=p(l)
630 gosub190
640 ifn>xthenx=n:y=i
650 nextl
660 ifx=0then420
670 i=y
680 gosub190
690 goto440
698 :
699 rem * level 3 last moves
700 x=0
710 forl=0to99:a(l)=b(l):nextl
720 forl=1to60
730 i=p(l):gosub190
740 ifn>0then780
750 nextl
760 ifx>0then930
770 goto930
780 ifx>9then930
790 x=x+1
800 r(x)=i:s(x)=n
810 b(i)=1
820 forj=1ton
830 b(f(j))=1
840 nextj
850 y=0
860 forz1=1to60
870 i=p(z1):gosub60
880 ifn>ytheny=n
890 nextz1
900 s(x)=s(x)-y
910 fork=0to99:b(k)=a(k):nextk
920 goto750
930 forl=0to99:b(l)=a(l):nextl
940 ifx<1then420
950 y=-99
960 forl=1tox
970 ifs(l)>ytheny=1
980 nextl
990 i=r(y):gosub190
991 goto440
998 :
999 rem * board display - user imput
1000 printchr$(147)
1010 gosub1720
1020 gosub1450
1030 poke781,19:poke782,0:sys65520
1040 print"my pieces - [157][157][157][157]"cp" ";tab(20)"your pieces - [157][157][157][157]"op" "
1050 forl=1to60
1060 i=p(l)
1070 gosub60
1080 ifn>0then1120
1090 nextl
1100 print"you cannot move."
1110 goto340
1120 poke781,20:poke782,0:sys65520:print"your move (l#)?[160]";
1125 poke198,0:wait198,1:getx$
1130 ifx$="l"theni=90:goto1230
1140 ifx$="a"theni=80:goto1230
1150 ifx$="b"theni=70:goto1230
1160 ifx$="c"theni=60:goto1230
1170 ifx$="d"theni=50:goto1230
1180 ifx$="e"theni=40:goto1230
1190 ifx$="f"theni=30:goto1230
1200 ifx$="g"theni=20:goto1230
1210 ifx$="h"theni=10:goto1230
1220 goto1120
1230 printx$;
1240 poke198,0:wait198,1:getx$
1250 ifval(x$)<1orval(x$)>8then1240
1260 ifi<90then1310
1270 level=val(x$)
1280 iflevel>3thenlevel=3
1290 printright$(x$,1);:print" okay"
1300 goto1120
1310 i=i+val(x$)
1320 printright$(x$,1)
1330 gosub60
1340 ifn>0then1370
1350 print"illegal move "
1360 poke781,21:poke782,0:sys65520:goto1120
1370 print"you flipped "n" of my pieces."
1380 b(i)=2
1390 forl=1ton
1400 b(f(l))=2
1410 nextl
1420 gosub1450
1421 poke781,20:poke782,0:sys65520:forzz=1to120:print" ";:next
1425 goto340
1430 :
1440 rem * display b() on screen
1450 cp=0:op=0:x=34:y=3
1455 poke783,peek(783)and254:poke53272,21:poke204,1:poke19,0
1460 forl=89to11step-1
1470 ifb(l)=9thengoto1520
1480 ifb(l)=0thengoto1520
1490 ifb(l)=1thenpc$="[144][209]":cp=cp+1:goto1510
1500 op=op+1:pc$="[209][144]"
1510 poke781,y:poke782,x:sys65520:printpc$
1520 x=x-3
1530 ifx<7thenx=34:y=y+2:ify>17theny=3
1550 nextl
1560 ifop+cp=64then12000
1570 ifop=0orcp=0then12000
1580 return
1700 :
1710 rem * board display
1720 printchr$(147)
1730 printtab(10) "1 2 3 4 5 6 7 8"
1740 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1750 [153][163]7)"a sgn + + + + + + + +
1760 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1770 [153][163]7)"b sgn + + + + + + + +
1780 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1790 [153][163]7)"c sgn + + + + + + + +
1800 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1810 [153][163]7)"d sgn + + + + + + + +
1820 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1830 [153][163]7)"e sgn + + + + + + + +
1840 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1850 [153][163]7)"f sgn + + + + + + + +
1860 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1870 [153][163]7)"g sgn + + + + + + + +
1880 printtab(8)" [207][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208][183][183][208]
1890 [153][163]7)"h sgn + + + + + + + +
1900 printtab(8)" [183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183]"
1910 return
9998 :
9999 rem dimension variables
10000 dimp(60),b(99),o(7),f(20),r(10),s(10),a(99)
10005 poke783,peek(783)and254:poke53272,21
10010 rem * b = board array
10020 rem * p = sequential moves
10030 rem * o = move directions
10040 rem * f = pieces flipped
10050 :
10060 rem * read data values
10070 forl=0to7
10080 reado(l)
10090 nextl
10100 forl=0to99
10110 readb(l)
10120 nextl
10130 forl=1to60
10140 readp(l)
10150 nextl
10152 forl=1to8:readv(l):next
10154 forl=1to8:readh(l):next
10160 :
10170 rem * data statements
10180 data1,9,10,11,-1,-9
10181 data-10,-11
10182 data9,9,9,9,9,9,9,9,9,9
10183 data9,0,0,0,0,0,0,0,0,9
10190 data9,0,0,0,0,0,0,0,0,9
10191 data9,0,0,0,0,0,0,0,0,9
10192 data9,0,0,0,2,1,0,0,0,9
10200 data9,0,0,0,1,2,0,0,0,9
10201 data9,0,0,0,0,0,0,0,0,9
10202 data9,0,0,0,0,0,0,0,0,9
10203 data9,0,0,0,0,0,0,0,0,9
10210 data9,9,9,9,9,9,9,9,9,9
10211 data81,88,11,18,83,86
10220 data61,68,31,38,13,16,63,66,33,36,84,85,51,58,41,48,14,15
10230 data64,65,53,56,43,46,34,35,74,75,52,57,42,47,24,25,73,76
10240 data62,67,32,37,23,26,82,87,71,78,21,28,12,17,72,77,22,27
10242 data3,5,7,9,11,13,15,17
10244 data11,14,17,20,22,25,28,31
10250 :
10260 rem * set colors
10270 poke53281,7:poke53280,12:printchr$(144)
10280 :
10290 rem * display routine
10300 printchr$(147):poke781,2:poke782,15:sys65520:print"[152]welcome to"
10310 poke781,4:poke782,13:sys65520:print"* * * * * * *"
10320 poke781,6:poke782,13:sys65520:print"* othello *"
10325 poke781,8:poke782,13:sys65520:print"* * * * * * *"
10330 poke781,11:poke782,15:sys65520:print"written by"
10340 poke781,13:poke782,15:sys65520:print"mark jeske"
10350 poke781,17:poke782,5:sys65520:print"[152]translated for the commodore by"
10360 poke781,19:poke782,13:sys65520:print"[154]donna k. woody"
10370 poke781,23:poke782,9:sys65520:print"[144]press any key to begin"
10380 poke198,0:wait198,1:geta$
10390 printchr$(147)
10400 poke781,2:poke782,0:sys65520:print"do you need instructions (y/n)?[160]";
10410 poke198,0:wait198,1:geta$
10420 ifa$="y"then 10470
10430 ifa$="n"thenprintchr$(147):poke53272,23:goto10640
10440 goto10400
10450 :
10460 rem * instructions & level
10470 printchr$(147):poke53272,23
10480 print"[207][212][200][197][204][204][207] is played on an 8 x 8 board.":print
10490 print"[212]he game's object is to end up with":print
10500 print"the most pieces. [217]ou are playing white":print
10510 print"and