예제 #1
0
파일: search.cs 프로젝트: zhangkun-bjtu/tmp
 static void matrix_to_status(int[] universe, int[,] matrix, ref status ans)
 {
     int temp = 0, bing_num = 0, i, j;
     for (i = 0; i < 4; i++)
     {
         for (j = 0; j < 3; j++)
         {
             if (matrix[i, j] == 6) break;
             temp++;
         }
         if (matrix[i, j] == 6) break;
     }
     ans.cao = temp;
     temp = 0;
     ans.zongclear();
     ans.hengclear();
     for (i = 0; i < 4; i++)
     {
         for (j = 0; j < 4; j++)
         {
             if (matrix[i, j] != 6 && matrix[i + 1, j] != 6)
             {
                 if (matrix[i, j] != 0 && matrix[i, j] != 7 && matrix[i, j] == matrix[i + 1, j])
                 {
                     ans.zong[ans.zongcntnum++] = temp;
                 }
                 temp++;
             }
         }
     }
     temp = 0;
     for (i = 0; i < 5; i++)
     {
         for (j = 0; j < 3; j++)
         {
             if (!(matrix[i, j] == 6 || matrix[i, j + 1] == 6 || (1 <= matrix[i, j] && matrix[i, j] <= ans.zongcntnum) || (1 <= matrix[i, j + 1] && matrix[i, j + 1] <= ans.zongcntnum)))
             {
                 if (matrix[i, j] == matrix[i, j + 1] && matrix[i, j] != 0 && matrix[i, j] != 7) ans.heng[ans.hengcntnum++] = temp;
                 temp++;
             }
         }
     }
     temp = 0;
     for (i = 0; i < 5; i++)
     {
         for (j = 0; j < 4; j++)
         {
             if (matrix[i, j] == 7 || matrix[i, j] == 0)
             {
                 if (matrix[i, j] == 7) ans.bing[bing_num++] = temp;
                 temp++;
             }
         }
     }
     int[,] cnt_matrix = new int[5, 4];
     status_to_matrix(ans, cnt_matrix);
     for (i = 1; i <= 5; i++) ans.universe[i] = universe[i];
     for (i = 0; i < 5; i++)
     {
         for (j = 0; j < 4; j++)
         {
             if (matrix[i, j] != cnt_matrix[i, j]) ans.universe[cnt_matrix[i, j]] = universe[matrix[i, j]];
         }
     }
 }