Ejemplo n.º 1
0
 public static string DFSAlgo(Stack <TextBox[, ]> stack, TextBox[,] box, Sudoku.Form1 form, TextBox memory)
 {
     while (stack.Count != 0)
     {
         if (stack.Count > Resources.memory)
         {
             Resources.memory = stack.Count;
         }
         memory.Text         = Resources.memory.ToString();
         TextBox[,] node_box = stack.Pop();
         CopyBox(node_box, box);
         form.Update();
         bool full_box           = true;
         List <TextBox[, ]> list = NextPossibleBoxes(node_box, ref full_box);
         if (full_box)
         {
             break;
         }
         else
         {
             foreach (TextBox[,] b in list)
             {
                 stack.Push(b);
             }
         }
     }
     if (stack.Count == 0)
     {
         return("Cannot solve");
     }
     else
     {
         return("DONE");
     }
 }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var board = new Sudoku.Form1(path, _loggedUser.Name);

            board.Show();
            this.Hide();
        }
Ejemplo n.º 3
0
        public static string BFSAlgo(Queue <TextBox[, ]> queue, TextBox[,] box, Sudoku.Form1 form, TextBox memory)
        {
            bool done_flag = false;

            while (queue.Count != 0)
            {
                if (queue.Count > Resources.memory)
                {
                    Resources.memory = queue.Count;
                }
                memory.Text         = Resources.memory.ToString();
                TextBox[,] node_box = queue.Dequeue();
                CopyBox(node_box, box);
                form.Update();
                bool full_box           = true;
                List <TextBox[, ]> list = NextPossibleBoxes(node_box, ref full_box);
                if (full_box)
                {
                    done_flag = true;
                    break;
                }
                else
                {
                    foreach (TextBox[,] b in list)
                    {
                        queue.Enqueue(b);
                    }
                }
            }
            if (done_flag)
            {
                return("DONE");
            }
            else
            {
                return("Cannot solve");
            }
        }
Ejemplo n.º 4
0
 public static void HillClimbingAlgo2(TextBox[,] current_box, int current_val, bool[,] is_fixed, TextBox[,] box, Sudoku.Form1 form, TextBox display, TextBox memory)
 {
     memory.Text = (++Resources.memory).ToString();
     while (current_val != 0)
     {
         TextBox[,] new_successor = NewSuccessor(current_box, is_fixed, current_val);
         CopyBox(new_successor, box);
         form.Update();
         display.Text = current_val.ToString();
         int new_val = HeuristicFunc2(new_successor);
         if (new_val < current_val)
         {
             HillClimbingAlgo2(new_successor, new_val, is_fixed, box, form, display, memory);
         }
     }
 }