home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 49
/
049.d81
/
chomp
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
3KB
|
97 lines
5 poke53280,7:poke53281,7
10 print"[147]=*= heuristic chomp =*=":run5700
300 ifa(u,v)thengosub7000:return
310 ifv=1thenx=w
320 v=l:return
600 ifpthenprint"[154] my move [146] "
610 u=x:v=y:forc=.to7:poke646,c:print"";:gosub300:a(u,v)=-1:next
620 foru=xtow:forv=ytol:gosub300:next:next:return
900 ifi+j+rnd(.)*l*(NULL)>sthenx=i:y=j:s=i+j+rnd(.)*l*(NULL)
910 return
1200 ifa(i,j)thengosub900:return
1210 ifi=1thenj=l
1220 i=w:return
1500 s=.:forj=1tol:fori=1tow:gosub1200:next:next:gosub600:return
1800 fore=.to1step.:ifs>t(n)thenifn<tthenn=n+1:next
1810 ifs=t(n)thenx=i:y=j:j=l:i=w
1820 e=1:next:return
2100 ifa(u,v)thenif(u<iorv<j)thens=s+d:return
2110 ifu=1thenv=l
2120 u=w:return
2400 s=.:d=1:forv=1tol:foru=1tow:gosub2100:next:d=d*10:next:return
2700 forn=.tot:f=s=t(n):ifs<=t(n)thenn=t
2710 next:return
3000 ifa(i,j)thengosub2400:gosub1800:return
3010 ifj=1theni=w
3020 j=l:return
3300 ifrnd(.)>.4thengosub2700:iffthengosub1500:return
3310 print"[152] t h i n k i n g "
3320 x=.:n=.
3325 fori=1tow:forj=1tol:gosub3000:next:next:ifx>.thengosub600:return
3330 gosub1500:return
3600 print"[144] --> your move [146] <-- "
3610 fore=.to1step.:wait56321,16,16
3615 x=int((peek(53248)-8)/32)+peek(53264)*8
3620 ifx<.thennext
3630 ifx>wthennext
3640 y=int((peek(53249)-66)/16):ify<.thennext
3650 ify>h-1thennext
3660 e=-a(x,y):next
3665 print" ":gosub600:return
3900 s=t(n):t(n)=t(m):t(m)=s:ifn>rthenn=n-r*2
3910 return
4200 ifpthenprint"[156] i win ... please wait":return
4210 print"[156] you win ... please wait":return
4500 gosub4200:s(p)=s(p)+1:s$=str$(s(.))+" win":ifs(.)-1thens$=s$+"s"
4510 s$=s$+" "+str$(s(1))+" loss":ifs(1)-1thens$=s$+"es"
4520 fore=.to1step.:iflen(s$)<34thens$=s$+" "
4530 iflen(s$)<34thens$=" "+s$
4540 e=-(len(s$)>=34):next:printy$"=*="s$"=*=";
4550 ifp=1thenw=w-2:ifw<1thenw=h:l=l-2:ifl<.thenl=.
4560 forc=1toc(p):forn=.tot:ifm(p,c)=t(n)thent(n)=t(t):n=t:iftthent=t-1
4570 next:next:p=1-p:forc=1toc(p):f=-1:forn=.tot:ifm(p,c)=t(n)thenf=.:n=t
4580 next:iffthent=t+1:t(t)=m(p,c)
4590 next:r=t:fore=.to1step.:r=int(r/2):r=r-(int(r/2)=r/2)
4600 forb=1tor:forn=btot-rstepr:m=n+r:ifm<=tthenift(n)>t(m)thengosub3900
4610 next:next:e=-(r=1):next:p=2:return
4800 ifa(u,v)thens=s+d:return
4810 ifv=1thenu=w
4820 v=l:return
5100 ifa(1,1)=.thenpoke53269,1:gosub4500:return
5110 s=.:d=1:foru=1tow:forv=1tol:gosub4800:next:d=d*10:next:c(p)=c(p)+1
5120 m(p,c(p))=s
5125 gosub2400:c(p)=c(p)+1:m(p,c(p))=s:onp+1gosub3600,3300:return
5400 print"[144]left button to continue -- right to quit"
5410 fore=-1to.step.:e=peek(56321)=255:next:ifpeek(56321)=239thenreturn
5420 poke53269,.:load"menu",8
5700 fora=.to53288:readn:ifn>255thena=n:readn
5710 pokea,n:next:sys49408:y$=""
5720 print"[151] maximum height (4-9)? ";
5730 fore=.to1step.:getk$:h=val(k$):e=-(h>3andh<10):next:printk$
5740 printy$"=*= point and click left =*="
5750 print"[155] from 'commodore magazine' june 1988[145]";
5760 dima(9,8),t(666),m(1,72),c(1),s(1):t(.)=1:l=2:poke53269,1
6000 ifl=hthengosub5400:l=int(h/3)+1
6010 forw=l+1toh+(l<5)*(h-l*2)
6020 poke53269,3:print"[149]":forj=1tol:fori=1tow:a(i,j)=-1
6030 printleft$(y$,j*2+3)tab(i*4-2)"[176][192][192][174][157][157][157][157][173][192][192][189]"
6040 next:next:c(.)=.:c(1)=.:forp=.to2:ifp=2thenp=.
6050 gosub5100:next:next:l=l+1:goto6000
6300 data896,252,,,248,,,240,,,248,,,220,,,142,,,7,,,3,,,,,,,,,,,,,,,,,,
6310 data,,,,,,,,,,,,,,,,,,,,,,,
6320 data,252,,49,254,48,49,252,56,251,191,124,221,50,224,10,49,64,3,207,
6330 data1,206,,,180,,1,74,,2,252,,3,2,,7,7,,124,3,224
6340 data24,1,192,24,1,128,,,,,,,,,,,,,,,,2040,14,15
6350 data49408,173,21,3,201,193,240,25,8,120,173,20,3
6355 data141,,192,173,21,3,141,1
6360 data192,169,33,141,20,3,169,193
6365 data141,21,3,40,96,216,173,25,212,172,2,192
6370 data32,88,193,140,2,192,24,109,,208,141,,208,138,105,,41,1,77,16
6380 data208,141,16,208,173,26,212,172,3,192,32
6385 data88,193,140,3,192,56,73,255,109
6390 data1,208,141,1,208,108,,192,140,5,192,141,4,192,162,,56,237,5,192
6400 data41,127,201,64,176,7,74,240,18,172,4,192,96,9,192,201,255,240,8,56
6410 data106,162,255,172,4,192,96,169,,96
6420 data53248,129,107,46,83,53264,,53280,,7,53287,1,1
7000 printleft$(y$,v*2+3)tab(u*4-2)" [157][157][157][157] ":a(u,v)=.:return