static void Main(string[] args) { Random r = new Random(); int[,] s = { {7,4,2}, {1,6,0}, {5,3,8} }; int[,] f = { {7,6,4}, {0,3,2}, {1,5,8} }; int[,] f2 = { {8,6,4}, {7,0,2}, {1,5,3} }; state xs = new state(s); state xf = new state(f2); node n = new node(); node.initArray(); n.setFinal(xf); n.setStart(xs); n.comparare(r); Console.Read(); }
static void Main(string[] args) { Random r = new Random(); int[,] s = { {0,2,3}, {7,1,6}, {5,4,8} }; int[,] fe = { {7,2,0}, {5,6,3}, {4,1,8} }; int[,] f = { {7,6,4}, {0,3,2}, {1,5,8} }; int[,] f2 = { {1,2,3}, {4,0,5}, {6,7,8} }; state xs = new state(s); state xf = new state(fe); node n = new node(); node.initArray(); n.setFinal(xf); n.setStart(xs); //n.comparare(r); n.executeHC(); //n.executeA(); //n.executeBF4(); Console.Read(); }
public void executeBKT() { cnt++; Console.WriteLine("APELARI:"+cnt); if(cnt>4600) { Console.WriteLine("NU EXISTA SOLUTIE!"); Thread.Sleep(20000); Environment.Exit(0); } if (val == fin) { Console.WriteLine("OMG SUCCESS!:"); Thread.Sleep(2000); Console.Clear(); afisTrace(trace); Thread.Sleep(20000); Environment.Exit(1); } state temp = new state(val); // Thread.Sleep(500); if (temp.mutasus()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); msus = new node(temp); msus.setTrace(trace + 'u'); } else Console.WriteLine("Stare deja vizitata!"); } // Thread.Sleep(500); temp = new state(val); if (temp.mutajos()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); mjos = new node(temp); mjos.setTrace(trace + 'j'); } else Console.WriteLine("Stare deja vizitata!"); } // Thread.Sleep(500); temp = new state(val); if (temp.mutast()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); mst = new node(temp); mst.setTrace(trace + 's'); } else Console.WriteLine("Stare deja vizitata!"); } // Thread.Sleep(500); temp = new state(val); if (temp.mutadr()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); mdr = new node(temp); mdr.setTrace(trace + 'd'); } else Console.WriteLine("Stare deja vizitata!"); } // Thread.Sleep(500); /* state[] xtest = (state [])vis.ToArray(typeof(state)); Console.WriteLine("---------------------------"); for (int c = 0; c < xtest.Length; c++) xtest[c].afis(); Console.WriteLine("---------------------------"); */ if (msus != null) msus.executeBKT(); if (mjos != null) mjos.executeBKT(); if(mst!=null) mst.executeBKT(); if(mdr!=null) mdr.executeBKT(); }
/* public state bestFind(state[] x) * { * state min = x[0]; * for (int i = 1; i < x.Length; i++) * if (calcDist(x[i]) < calcDist(min)) * min = new state(x[i]); * return min; * }*/ #endregion public void executeBKT() //DFS ? { cnt++; Console.WriteLine("APELARI:" + cnt); if (cnt > 4600) { Console.WriteLine("NU EXISTA SOLUTIE!"); Thread.Sleep(20000); Environment.Exit(0); } if (val == fin) { Console.WriteLine("OMG SUCCESS!:"); Thread.Sleep(2000); Console.Clear(); afisTrace(trace); Thread.Sleep(20000); Environment.Exit(1); } state temp = new state(val); // Thread.Sleep(500); if (temp.mutasus()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); msus = new node(temp); msus.setTrace(trace + 'u'); } else { Console.WriteLine("Stare deja vizitata!"); } } // Thread.Sleep(500); temp = new state(val); if (temp.mutajos()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); mjos = new node(temp); mjos.setTrace(trace + 'j'); } else { Console.WriteLine("Stare deja vizitata!"); } } // Thread.Sleep(500); temp = new state(val); if (temp.mutast()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); mst = new node(temp); mst.setTrace(trace + 's'); } else { Console.WriteLine("Stare deja vizitata!"); } } // Thread.Sleep(500); temp = new state(val); if (temp.mutadr()) { if (isVisited(temp) == false) { temp.afis(); vis.Add(temp); mdr = new node(temp); mdr.setTrace(trace + 'd'); } else { Console.WriteLine("Stare deja vizitata!"); } } // Thread.Sleep(500); /* state[] xtest = (state [])vis.ToArray(typeof(state)); * Console.WriteLine("---------------------------"); * for (int c = 0; c < xtest.Length; c++) * xtest[c].afis(); * Console.WriteLine("---------------------------"); */ if (msus != null) { msus.executeBKT(); } if (mjos != null) { mjos.executeBKT(); } if (mst != null) { mst.executeBKT(); } if (mdr != null) { mdr.executeBKT(); } }