Loading main (26.5 KiB) File changed.No diff preview for this file type. View original file View changed file solver.c +17 −3 Changes for solver.c: 17 added lines, 3 removed lines. Original line number Diff line number Diff line /* solver.c */ /* Last Change: 2019/07/25 (Thu) 14:39:28. */ /* Last Change: 2019/07/29 (Mon) 09:32:40. */ #include<stdio.h> #include<limits.h> Loading Loading @@ -151,10 +151,23 @@ short int search_placable(short int blockid){ //calc the cost (sum of Euclidean short int i,j,k,l,index=0; short int place[5][2]; //(relative) place of edge #block_data[blockid][1-4][] (x,y) short int blockw=0,blockh=0; /* calc cost */ if(block_data[blockid][2][2]==-1){ //if monomino return 1; for(i=0;i<MAXSIZE;i++) for(j=0;j<MAXSIZE;j++){ cost[i][j][0]=0; if(board_beta[i][j]==block_data[blockid][1][2]){ if(i+1<MAXSIZE&&board_beta[i+1][j]==0) cost[i+1][j][0]=1; if(j+1<MAXSIZE&&board_beta[i][j+1]==0) cost[i][j+1][0]=1; if(i-1>=0&&board_beta[i-1][j]==0) cost[i-1][j][0]=1; if(j-1>=0&&board_beta[i][j-1]==0) cost[i][j-1][0]=1; } /* calc cost */ } }else{ for(k=1;k<=4;k++){ place[k][0]=SHRT_MIN; place[k][1]=SHRT_MIN; Loading Loading @@ -199,6 +212,7 @@ short int search_placable(short int blockid){ //calc the cost (sum of Euclidean } } } } /* calc costrank */ for(i=0;i<MAXSIZE;i++) for(j=0;j<MAXSIZE;j++) Loading Loading
main (26.5 KiB) File changed.No diff preview for this file type. View original file View changed file
solver.c +17 −3 Changes for solver.c: 17 added lines, 3 removed lines. Original line number Diff line number Diff line /* solver.c */ /* Last Change: 2019/07/25 (Thu) 14:39:28. */ /* Last Change: 2019/07/29 (Mon) 09:32:40. */ #include<stdio.h> #include<limits.h> Loading Loading @@ -151,10 +151,23 @@ short int search_placable(short int blockid){ //calc the cost (sum of Euclidean short int i,j,k,l,index=0; short int place[5][2]; //(relative) place of edge #block_data[blockid][1-4][] (x,y) short int blockw=0,blockh=0; /* calc cost */ if(block_data[blockid][2][2]==-1){ //if monomino return 1; for(i=0;i<MAXSIZE;i++) for(j=0;j<MAXSIZE;j++){ cost[i][j][0]=0; if(board_beta[i][j]==block_data[blockid][1][2]){ if(i+1<MAXSIZE&&board_beta[i+1][j]==0) cost[i+1][j][0]=1; if(j+1<MAXSIZE&&board_beta[i][j+1]==0) cost[i][j+1][0]=1; if(i-1>=0&&board_beta[i-1][j]==0) cost[i-1][j][0]=1; if(j-1>=0&&board_beta[i][j-1]==0) cost[i][j-1][0]=1; } /* calc cost */ } }else{ for(k=1;k<=4;k++){ place[k][0]=SHRT_MIN; place[k][1]=SHRT_MIN; Loading Loading @@ -199,6 +212,7 @@ short int search_placable(short int blockid){ //calc the cost (sum of Euclidean } } } } /* calc costrank */ for(i=0;i<MAXSIZE;i++) for(j=0;j<MAXSIZE;j++) Loading