diff --git a/source/solver.c b/source/solver.c index e1edab2711e337873c9a8cad472c8e1808b785e2..01501c2ddcf7a98293f01e03b04f668466e544da 100644 --- a/source/solver.c +++ b/source/solver.c @@ -1,5 +1,5 @@ /* solver.c */ -/* Last Change: 2018/08/27 (Mon) 23:01:56. */ +/* Last Change: 2018/08/27 (Mon) 23:42:09. */ #define MAX_ATTEMPS 10000 @@ -19,6 +19,8 @@ int lines; int dx[6]={-1,0,0,1,0,0}; int dy[6]={0,-1,0,0,1,0}; int dz[6]={0,0,-1,0,0,1}; +int history[8*72*72]; +int searchorder[6]; //x+-,y+-,z+- //z,y,x void read(void){ //read problem @@ -77,12 +79,14 @@ void read(void){ //read problem } int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be connected to goal - int i,src=0,contd,isbranch; - int history[8*72*72],index=0; + int i,j,t,src=0,contd,isbranch; + int index=0; int nowx=x,nowy=y,nowz=z; - int searchorder[6]; //x+-,y+-,z+- /* for(i=0;i<6;i++) */ /* printf("%d %d %d\n",dx[i],dy[i],dz[i]); */ + for(i=0;i<8*72*72;i++) + history[i]=-1; + index=0; while(1){ /* printf("%d %d %d\n",nowx,nowy,nowz); */ if(nowx<0||nowy<0||nowz<0||nowx>=width||nowy>=height||nowz>=depth){ @@ -111,13 +115,17 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne avail[nowz][nowy][nowx]=0; index--; if(nowx-dx[history[index]]<0||nowy-dy[history[index]]<0||nowz-dx[history[index]]<0||nowx-dz[history[index]]>=width||nowy-dy[history[index]]>=height||nowz-dz[history[index]]>=depth){ + index++; /* printf("something wrong\n"); */ }else{ nowx-=dx[history[index]]; nowy-=dy[history[index]]; nowz-=dz[history[index]]; avail[nowz][nowy][nowx]=1; - printf("%d %d %d -\n",nowx,nowy,nowz); + /* printf("%d %d %d -%d %d\n",nowx,nowy,nowz,history[index],index); */ + /* for(j=0;j=width||nowy-dy[history[index]]>=height||nowz-dz[history[index]]>=depth){ + index++; /* printf("something wrong\n"); */ }else{ nowx-=dx[history[index]]; nowy-=dy[history[index]]; nowz-=dz[history[index]]; avail[nowz][nowy][nowx]=1; - printf("%d %d %d -\n",nowx,nowy,nowz); + /* printf("%d %d %d -%d %d\n",nowx,nowy,nowz,history[index],index); */ + /* for(j=0;j