Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created March 16, 2010 22:06
Show Gist options
  • Save jcromartie/334585 to your computer and use it in GitHub Desktop.
Save jcromartie/334585 to your computer and use it in GitHub Desktop.
int roboslider (int *b,int *bm, int *p, float *bw)
{
int r,c,ct,ct2,ok=0,x,mv,cur;
for(mv=0;(!ok)&&(mv<7);mv+=2)
for(x=0; (!ok)&&(x<10) ;x++)
{
for(ct=mv+1; (!ok)&&(ct<3+mv) ;ct++)
{
ps->torc(p[x],&r,&c);
if (c>=13)
{
if (ct==1) {c--; r++;}
if (ct==2) {c++; r++;}
if (ct==3)
{
for (ct2=r-3; ct2<c && (ps->fromrc(r+1,ct2)==-1 || b[ps->fromrc(r+1,ct2)]);ct2+=2);
if (!b[ps->fromrc(r+1,ct2)]) c-=2;
}
if (ct==4)
{
for (ct2=29-r; ct2>c && (ps->fromrc(r+1,ct2)==-1 || b[ps->fromrc(r+1,ct2)]);ct2-=2);
if (b[ps->fromrc(r+1,ct2)]==0) c+=2;
}
if (ct==5) {c-=2;}
if (ct==6) {c+=2;}
if (ct==7) {c--; r--;}
if (ct==8) {c++; r--;}
}
else
{
if (ct==2) {c--; r++;}
if (ct==1) {c++; r++;}
if (ct==4)
{
for (ct2=r-3;(ct2<c)&&((ps->fromrc(r+1,ct2)==-1)||(b[ps->fromrc(r+1,ct2)]!=0));ct2+=2);
if (b[ps->fromrc(r+1,ct2)]==0) c-=2;
}
if (ct==3)
{
for (ct2=29-r;(ct2>c)&&((ps->fromrc(r+1,ct2)==-1)||(b[ps->fromrc(r+1,ct2)]!=0));ct2-=2);
if (b[ps->fromrc(r+1,ct2)]==0) c+=2;
}
if (ct==6) {c-=2;}
if (ct==5) {c+=2;}
if (ct==7) {c--; r--;}
if (ct==8) {c++; r--;}
}
cur=ps->fromrc(r,c);
ok= ( cur!=-1 && !b[cur] );
if ( ok && ( cur==23 || cur==11 || cur==21 || cur==34 || cur==86 || cur==99 || cur==97 || cur==109 ))
ok=0;
}
}
x--;
if (ok)
{
bm[0]=p[x];
bm[1]=ps->fromrc(r,c);
bm[2]=-1;
*bw=roboevalmove(bm);
}
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment