/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here base.Initialize(); aniTime = ANIMATION_TIME; //Preforms the Puzzle initialisation SlidingPuzzle puzzle = new SlidingPuzzle(); //puzzle.SetState("{1,2,3,4,8,6,7,5,0}"); puzzle.ShuffleBoard(); var path = A_StarSearch <string, SlidingPuzzleAction> .Search( puzzle, "{1,2,3,4,5,6,7,8,0}"); System.Console.WriteLine("Num steps = " + path.Count); //adds the steps to the board object board = new GUISrc.Board(this, ConvertToIntArray(path.Pop()), BOARD_SIZE); while (path.Count > 0) { board.AddState(ConvertToIntArray(path.Pop())); } }
public static void Main(String[] args) { SlidingPuzzle puzzle = new SlidingPuzzle(); //puzzle.SetState("{1,2,3,4,8,6,7,5,0}"); puzzle.ShuffleBoard(); var path = A_StarSearch <string, SlidingPuzzleAction> .Search( puzzle, "{1,2,3,4,5,6,7,8,0}"); System.Console.WriteLine("Num steps = " + path.Count); while (path.Count > 0) { System.Console.WriteLine(path.Pop()); } }