Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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);
            }
        }