Commit c6c67e0a authored by royus's avatar royus

not done

parent 56a93b0f
/* 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<index;j++) */
/* printf("%d ",history[j]); */
/* printf("\n"); */
/* return 0;//goback */
continue;
}
......@@ -154,7 +162,6 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
src++;
}else
searchorder[src]=5;
int j,t;
for(i=0;i<src;i++){
j=rand()%(src);
t=searchorder[i];
......@@ -178,9 +185,11 @@ int available(int z,int y, int x){ //return 1 when (nowx,nowy,nowz) can be conne
nowy+=dy[searchorder[i]];
nowz+=dz[searchorder[i]];
/* printf("%d %d %d\n",dx[searchorder[i]],dy[searchorder[i]],dz[searchorder[i]]); */
printf("%d %d %d +\n",nowx,nowy,nowz);
history[index]=searchorder[i];
/* printf("%d\n",index); */
/* printf("%d %d %d +%d %d\n",nowx,nowy,nowz,searchorder[i],index+1); */
/* for(j=0;j<index;j++) */
/* printf("%d ",history[j]); */
/* printf("\n"); */
index++;
}
}
......@@ -190,13 +199,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<index;j++) */
/* printf("%d ",history[j]); */
/* printf("\n"); */
/* printf("%d %d %d\n",dx[history[index]],dy[history[index]],dz[history[index]]); */
continue;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment