public void _02_Pathfinder_Solves_The_Puzzle()
        {
            SlidingPuzzleMap map = new SlidingPuzzleMap(
                "11111111;" +
                "11000101;" +
                "11000101;" +
                "10000101;" +
                "10000001;" +
                "10001111;" +
                "11000001;" +
                "10000001;" +
                "11W11111;" +
                "11111111");
            SlidingPuzzleState startingState = new SlidingPuzzleState(new Vector2Int(1, 6));

            var processor  = new SlidingPuzzleProcessor(map);
            var pathfinder = new Pathfinder.PuzzlePathfinder <Vector2Int, SlidingPuzzleState>().RecalculateGrah(processor, startingState, new Vector2Int[] { _up, _down, _left, _right });

            var stopwatch = new System.Diagnostics.Stopwatch();

            stopwatch.Start();
            var path = pathfinder.GetClosestWinPath(startingState);

            stopwatch.Stop();

            Debug.Log($"Pathfinding had taken: {stopwatch.ElapsedMilliseconds} ms [{stopwatch.ElapsedTicks} ticks]");

            Assert.That(path.Succesfull, Is.EqualTo(true), $"Path is not marked as succesful");
            Assert.That(path.Path, Is.EqualTo(new Vector2Int[] { _right, _up, _left, _down }), $"Path is incorrect");
        }
Esempio n. 2
0
 private void CreateMap(SlidingPuzzleMap map)
 {
     if (_processor != null)
     {
         _processor.Reconstruct(map);
     }
     else
     {
         _processor = new SlidingPuzzleProcessor(map);
     }
     _display.SetMap(map);
 }