static string GoUpwards(int[,] matrix, string data, int size, int x, int y, int mask) { while (y >= 0) { for (int j = 0; j < 2; j++) { x -= j; if (x < 0) { break; } if (matrix[y, x] == 1 || matrix[y, x] == -1) { continue; // Все служебные белые клетки должны стать -1 } if (data.Length == 0) { matrix[y, x] = 0; continue; } if (data[0] == '1') { matrix[y, x] = 1; } data = data.Remove(0, 1); if (Dicts.Mask(mask, x, y) == 0) { if (matrix[y, x] == 0) { matrix[y, x] = 1; } else { matrix[y, x] = 0; } } // Убрать коментарии, чтобы вернуть всё на место //matrix[y, x] = 1; //DisplayMatrix(matrix); //Thread.Sleep(15); } y -= 1; x += 1; } if (x == 5) { x -= 1; } return(data); }
static string GoDownwards(int[,] matrix, string data, int size, int x, int y, int mask) { y = 0; while (y < size) { for (int j = 0; j < 2; j++) { x -= j; if (x < 0) { break; } if (matrix[y, x] == 1 || matrix[y, x] == -1) { continue; } if (data.Length == 0) { matrix[y, x] = 0; continue; } if (data[0] == '1') { matrix[y, x] = 1; } data = data.Remove(0, 1); if (Dicts.Mask(mask, x, y) == 0) { if (matrix[y, x] == 0) { matrix[y, x] = 1; } else { matrix[y, x] = 0; } } //matrix[y, x] = 1; //DisplayMatrix(matrix); //Thread.Sleep(15); } y += 1; x += 1; } return(data); }