private static void DisplayCellNoValue(Board board, int row, int col) { var startRow = 4 * row + 1; var startCol = 8 * col + 2; for (var rOff = 0; rOff < 3; rOff++) { for (var cOff = 0; cOff < 3; cOff++) { Console.SetCursorPosition(startCol + (2 * cOff), startRow + rOff); var targetValue = rOff * 3 + cOff; if (!board.IsValid(row, col, targetValue)) { Console.Write(InvalidValue); } else { Console.ForegroundColor = ConsoleColor.Gray; Console.Write(targetValue + 1); Console.ResetColor(); } } } }
static void Main(string[] args) { var b1 = Board.ReadInString("000010000007905400000804000001000200470030096000090000016050940004321600308000102"); var board1 = new Board(b1); board1.PrintOut(); Console.Out.WriteLine("going to solve now"); Console.Out.WriteLine("\n\n"); board1.Solve(); board1.IsValid(); //board1.Assign(); Console.Read(); }
private void topluCalistir_Click(object sender, EventArgs e) { try { OpenFileDialog theDialog = new OpenFileDialog { Title = "Open Text File", Filter = "TXT files|*.txt", InitialDirectory = @"C:\" }; if (theDialog.ShowDialog() == DialogResult.OK) { Board board = boardOlusturVeEkranaCiz(theDialog.FileName); bool valid = board.IsValid(); if (!valid) { MessageBox.Show("Board hatalı"); return; } progressBar1.Value = 0; progressBar1.PerformStep(); topluSonucTextBox.Text = ""; int denemeSayisi = Convert.ToInt32(calismaSayisiTextBox.Text); string metrik = metrikComboBox.SelectedItem.ToString(); BoardCozum solvedWithDfs = CozVeOrtalamaDondur(board, new DFSSolver(), denemeSayisi, metrik); label2.Text = string.Format("{0:0.000} , toplam: {1}\r\nDetay: {2}", solvedWithDfs.Sure, solvedWithDfs.Total, solvedWithDfs.Detail); foreach (int threadCount in TopluThreadParametreleri) { for (int maxChildCount = 1; maxChildCount <= TopluMaxChildCount; maxChildCount++) { BoardCozum solvedWithLoq = CozVeOrtalamaDondur(board, new LoQSolver(threadCount, maxChildCount), denemeSayisi, metrik); topluSonucTextBox.Text += string.Format("T:{0}, MaxC: {1} Sure: {2:0.000} ,toplam: {3}\r\nDetay: {4}\r\n", threadCount, maxChildCount, solvedWithLoq.Sure, solvedWithLoq.Total, solvedWithLoq.Detail); } progressBar1.PerformStep(); } progressBar1.Value = 100; File.WriteAllText("C:/toplu_sonuc.txt", topluSonucTextBox.Text); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message); } }
private void dosyaKullanarakCoz(string dosyaPath) { try { Board board = boardOlusturVeEkranaCiz(dosyaPath); bool valid = board.IsValid(); if (!valid) { MessageBox.Show("Board hatalı"); return; } int threadCount = Convert.ToInt32(theadSayisiTextBox.Text); int maxChildCount = Convert.ToInt32(maxChildCountTextBox.Text); string metrik = metrikComboBox.SelectedItem.ToString(); int denemeSayisi = Convert.ToInt32(calismaSayisiTextBox.Text); progressBar1.Value = 0; progressBar1.PerformStep(); // DFS çözüm BoardCozum solvedWithDfs = CozVeOrtalamaDondur(board, new DFSSolver(), denemeSayisi, metrik, true); label2.Text = string.Format("{0:0.000} , toplam: {1}\r\nDetay: {2}", solvedWithDfs.Sure, solvedWithDfs.Total, solvedWithDfs.Detail); // LoQ çözüm BoardCozum solvedWithLoq = CozVeOrtalamaDondur(board, new LoQSolver(threadCount, maxChildCount), denemeSayisi, metrik, true); label4.Text = string.Format("{0:0.000} , toplam: {1}\r\nDetay: {2}", solvedWithLoq.Sure, solvedWithLoq.Total, solvedWithLoq.Detail); progressBar1.PerformStep(); progressBar1.Value = 50; // Çözüm karşılaştırma label5.Text = string.Format("Sonuç kontrol: {0}", solvedWithDfs.CozumlerAyniMi(solvedWithLoq)); progressBar1.PerformStep(); progressBar1.Value = 100; } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } }