static void Main(string[] args) { //Chess board // Recur(6,6,7,0); //BFS algoritm Chess_board test1 = new Chess_board(new BFS()); //test.SwitchAlgoritms(); test1.SetQueen(); Chess_board test2 = test1.Clone() as Chess_board; test2.currentAlgoritm = new A_stars(); //Chess_board test2 = new Chess_board(new A_stars()); // test2.CloneMass(test1); try { var pr = Process.GetCurrentProcess(); var mem0 = pr.PeakVirtualMemorySize64; test1.SwitchAlgoritms(); var memuse = pr.PeakVirtualMemorySize64 - mem0; Console.WriteLine("Method got {0} additional Mb", memuse / 1024.0 / 1024.0); } catch (StackOverflowException ex) { Console.WriteLine("Can`t find solve"); } test2.SwitchAlgoritms(); test2.ShowResult(); test1.ShowResult(); //A_stars Algoritm //test2.currentAlgoritm = new A_stars(); Console.ReadLine(); }
private Chess_board(Chess_board gh) { this.board = new int[gh.board.GetLength(0), gh.board.GetLength(1)]; for (int i = 0; i < gh.board.GetLength(0); i++) { for (int j = 0; j < gh.board.GetLength(1); j++) { this.board[i, j] = gh.board[i, j]; } } this.currentAlgoritm = gh.currentAlgoritm; this.stopwat = gh.stopwat; }