Author: Dann Corbit
Date: 16:09:28 09/19/02
Go up one level in this thread
On September 19, 2002 at 18:14:17, David Hanley wrote:
>On September 19, 2002 at 18:06:12, Severi Salminen wrote:
>
>>>I had to download TSCP and look it over. It's pretty compact.
>>>
>>>It's actually a *little* shorter. It has fewer comments but longer
>>>function/variable names and more of 'em. It's written in lisp vs C, and my
>>>source is all in one file, so it's hard to compare exactly.
>>
>>Hmm, are you comparing _source code_??? What's the point in that??
>
>Well, it intrests me.. Partly just to see what you really need to play chess
>well.. Also things like maintainability, debugging, etc, are theoretically
>easier on short programs, all other things being equal. Partially because i
>think there are so many long poorly written programs being written nowadays. I
>see simple programs with huge sources that need 128MB to do simple things, and
>it irks me.
>
>> Using one
>>letter variables and function names will make source files smaller but what's
>>the point comparing those?
>
>Well, neither of us are doing such things, so it's a reasonable comparison.
>Like i said, he has some more comments, but i use more small functions and
>variables with longer names.
>
>>
>>I think you really want to compare executables.
>
>No, i really don't.. ;) It's valid, just not what i'm curious about.
>
>> I while ago I made a assembler
>>chess program which really played chess but the source and executable are not
>>on my computer now. I'll get back to this later.
>
>That's pretty interesing, though. I'd be curious to see it.
From:
http://www.the5k.org/description.asp/entry_id=615
We have this:
<style>body{margin:20 20}</style><body onMouseMove="mm()" onMouseUp="bm(h)"
bgcolor=999999
onLoad="ub()"><script>n=-1;a=28;i=[[112,29,a],[86,26,a],[45,22,a],[18,27,a],[67,19,a],[0,18,a],[0,0,0],[0,18,0],[67,19,0],[18,27,0],[45,22,0],[86,26,0],[112,29,0]];tk=[1,2,4,5,5,8,100];b=[2,3,4,5,6,4,3,2,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(a=32;a-->=0;)b.push(-b[a]);v=['/','-','\\','|'];tm=[-17,-15,-10,-6,6,10,15,17];h=0;mdp=3;dp=mdp;ptfy=n;ptty=n;nn=-9999;function
fbm(){tx.value='Go
'+pc[a=t&1];if(pl[a]){pfy=pty=bopm=n;rt=nn;boy=ce=boc=0;dp=mdp=pl[t&1];tx.value='Thinking';fmb();}}function
fmb(){var lr=nn;var d=t&1?8:-8;dp--;var
y=0;if(dp==mdp-1)y=boy;for(;;){if(b[y]*d>0){var pm;var
c=0;if(dp==mdp-1){ptfy=y;c=boc;pm=(bopm==n)?fmv(y,d):bopm;}else
pm=fmv(y,d);for(;c<pm.length;){var ym=pm[c];var
op=b[ym];b[ym]=b[y];b[y]=0;t++;if(dp==mdp-1)ptty=ym;var br;if(dp>0)br=fmb();
else{br=0;for(var
x=0;x<64;)br+=b[x++]*d;}if(dp==mdp-1){if(br==rt)ce++;if(br>rt||(br==rt&&Math.random()<1/ce)){pfy=ptfy;pty=ptty;if(br!=rt)ce=0;rt=br;}}else
if(br>lr)lr=br;b[y]=b[ym];b[ym]=op;t--;c++;if(c>=pm.length){boc=0;bopm=n;break;}if(dp==mdp-1){dp++;boy=y;boc=c;bopm=pm;setTimeout("fmb()",9);return;}}}if(y++>62)break;}dp++;if(dp==mdp)mp(pfy,pty);return
-lr;}function fmv(y,d){var pm=new Array();if(b[y]*d<0)return pm;var
p=Math.abs(b[y]);if(p==1){if((a=y+d)>n&a<64){if(!b[a]){pm.push(a);if((d==(y&8)|(d<0&(y>>3)==6))&!b[a=y+2*d])pm.push(a);}if((z=y&7)!=0&b[a=y+d-1]*d<0)pm.push(a);if(z!=7&b[a=a+2]*d<0)pm.push(a);}}if(p==3){yy=y;x=y&7;y>>=3;for(var
c=0;c<tm.length;c++){var
m=tm[c];if(!((x<2&(m==6|m==-10))|(x<1&(m==15|m==-17))|(x>5&(m==-6|m==10))|(x>6&(m==-15|m==17))|(y<2&(m==-10|m==-6))|(y<1&(m==-15|m==-17))|(y>5&(m==15|m==17))|(y>6&(m==6|m==10))))if(b[a=yy+m]*d<=0)pm.push(a);}}if(p>1&p!=3){eur=eul=edr=edl=el=er=eu=ed=1;ul=u=ur=r=dr=dn=dl=l=y;for(var
c=0;c++<7;){r++;l--;if(p==2|p==5|(c==1&p==6)){if(el){if((l&7)==7|(a=b[l]*d)>0)el=0;else{pm.push(l);if(a<0)el=0;}}if(er){if(!(r&7)|(a=b[r]*d)>0)er=0;else{pm.push(r);if(a<0)er=0;}}if(eu){u+=8;if(u>63|(a=b[u]*d)>0)eu=0;else{pm.push(u);if(a<0)eu=0;}}if(ed){dn-=8;if(dn<0|(a=b[dn]*d)>0)ed=0;else{pm.push(dn);if(a<0)ed=0;}}}if(p==4|p==5|(c==1&p==6)){if(eur){ur+=9;if(!(r&7)|ur>63|(a=b[ur]*d)>0)eur=0;else{pm.push(ur);if(a<0)eur=0;}}if(eul){ul+=7;if((l&7)==7|ul>63|(a=b[ul]*d)>0)eul=0;else{pm.push(ul);if(a<0)eul=0;}}if(edl){dl-=9;if((l&7)==7|dl<0|(a=b[dl]*d)>0)edl=0;else{pm.push(dl);if(a<0)edl=0;}}if(edr){dr-=7;if(!(r&7)|dr<0|(a=b[dr]*d)>0)edr=0;else{pm.push(dr);if(a<0)edr=0;}}}}}return
pm;}q="<table cellpadding=0 cellspacing=0>";r="<tr height=";s="<td
width=";t="</table>";u="background-";_=u+"position-";z="='bm(this.style)'
";w(q);for(y=n;y++<7;){w(r+64+">");for(x=n;x++<7;){w(s+64+"
bgcolor="+(((x+y)&1)?0:'gray')+">");}}w(t);for(var y=n;y++<63;){var
p=b[y];if(p){p+=6;w("<div id=d"+y+" onmousedown"+z+"
style='position:absolute;"+_+"x:-"+i[p][0]+"px;"+_+"y:-"+i[p][2]+"px;"+u+"image:url(c.gif);'>"+q+r+28+">"+s+i[p][1]+">"+t+"</div>");}else
b[y]=0;}function io(p){return 32-i[p+6][1]/2;}function
ub(){for(y=n;y++<63;){ if(b[y]){z=document.all['d'+y].style;z.left=(y&7)*64+io(b[y])+20;z.top=(y>>3)*64+36;}}}function
mp(pf,pt){var pm=fmv(pf,t&1?8:-8);for(var cnt=0;cnt<pm.length;
cnt++)if(pm[cnt]==pt){if(b[pt]*b[pf]<0){l=document.all['d'+pt];l.style.visibility="hidden";l.id='r'+t;}document.all['d'+pf].id='d'+pt;b[pt]=b[pf];b[pf]=0;if(pt<8&&b[pt]==1)b[pt]=5;ub();t++;setTimeout("fbm();",9);}ub();
}function
bm(o){g=((event.x-20)>>6)+((event.y-20)>>6)*8;if(h!=o){h=o;ft=g;mm();}else
if(h){h.zIndex=h=0;mp(ft,g);}}function
mm(){if(h){h.left=event.x-32+io(b[ft]);h.top=event.y-16;h.zIndex=9;}}function
w(v){document.write(v);}ub();pc=["White","Black"];s="<select id=";u="<option
value=";v=">"+u+"1>AI-1"+u+"2>AI-2"+u+"3>AI-3"+u+"0>Human</select>";w(pc[1]+s+"wh"+v+pc[0]+s+"bl"+v);t=h=0;</script><input
type=button id='tx' value="Go " onclick="pl=[1*bl.value,1*wh.value];fbm();">
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.