コード例 #1
0
ファイル: PushMapTests.cs プロジェクト: guylangston/SokoSolve
        public void CaseA()
        {
            var report = new TestReport();

            var sample = new Puzzle(new string[]
            {
                "#############",
                "#a ###    b##",
                "# A######  ##",
                "#  ######B ##",
                "#########  ##",
                "#############",
            });

            var boundry = sample.ToMap('#', 'A', 'B' );

            var staticMaps = new StaticMaps()
            {
                FloorMap = sample.ToMap(' ', 'a', 'b'),
                WallMap = sample.ToMap('#')
            };
            var stateMaps = new StateMaps()
            {
                CrateMap = sample.ToMap('A', 'B'),
                MoveMap = FloodFill.Fill(staticMaps.WallMap, sample.First(x => x.State == 'a').Position)
            };

            var pushMap = PushMap.Find(staticMaps, stateMaps, sample.First(x => x.State == 'A').Position, sample.First(x => x.State == 'a').Position);

            report.WriteLine(pushMap);

            Assert.That(report, Is.EqualTo(new TestReport(
            @".............
            ..X..........
            .............
            ..X..........
            .............
            ............."
                )));
        }
コード例 #2
0
ファイル: PushMapTests.cs プロジェクト: guylangston/SokoSolve
        public void MultipleCrates()
        {
            var report = new TestReport();

            var sample = new Puzzle(new string[]
            {
                "#############",
                "#   x     p##",
                "#x         ##",
                "#  ######X ##",
                "#########  ##",
                "#############",
            });

            var staticMaps = new StaticMaps()
            {
                FloorMap = sample.ToMap(' ', 'x', 'X', 'p'),
                WallMap = sample.ToMap('#')
            };

            var crate = sample.ToMap('X', 'x');
            var stateMaps = new StateMaps()
            {
                CrateMap = crate,
                MoveMap = FloodFill.Fill(staticMaps.WallMap.BitwiseOR(crate), sample.First(x => x.State == 'p').Position)
            };

            var pushMap = PushMap.Find(staticMaps, stateMaps, sample.First(x => x.State == 'X').Position, sample.First(x => x.State == 'p').Position);

            report.WriteLine(pushMap);

            Assert.That(report, Is.EqualTo(new TestReport(
            @".............
            .....XXXXXX..
            ..XXXXXXXXX..
            ..X......XX..
            .........XX..
            .............
            "
                )));
        }
コード例 #3
0
ファイル: PushMapTests.cs プロジェクト: guylangston/SokoSolve
        public void OverAndBackAgain()
        {
            var report = new TestReport();

            var sample = new Puzzle(new string[]
            {
                "#############",
                "#...........#",
                "#...........#",
                "#...........#",
                "######.######",
                "#......x....#",
                "#o.........p#",
                "#############",
            });

            var staticMaps = new StaticMaps()
            {
                FloorMap = sample.ToMap('.', 'x','o', 'p'),
                WallMap = sample.ToMap('#')
            };

            var crate = sample.ToMap('X', 'x');
            var stateMaps = new StateMaps()
            {
                CrateMap = crate,
                MoveMap = FloodFill.Fill(staticMaps.WallMap.BitwiseOR(crate), sample.First(x => x.State == 'p').Position)
            };

            var from = sample.First(x => x.State == 'x').Position;
            var to = sample.First(x => x.State == 'p').Position;
            var pushMap = PushMap.Find(staticMaps, stateMaps, from, to);
            report.WriteLine(pushMap);

            Assert.That(report, Is.EqualTo(new TestReport(
            @".............
            .XXXXXXXXXXX.
            .XXXXXXXXXXX.
            .XXXXXXXXXXX.
            ......X......
            .XXXXXXXXXXX.
            .XXXXXXXXXXX.
            .............
            "
                )));

            var playerRoute = pushMap.FindPlayerWalkRoute(to);
            report.WriteLine("pushMap.FindPlayerWalkRoute(to)");
            report.WriteLine(playerRoute);

            var crateRoute = pushMap.FindCrateRoute(to);
            report.WriteLine("pushMap.FindCrateRoute(to)");
            report.WriteLine(crateRoute);
        }
コード例 #4
0
ファイル: PushMapTests.cs プロジェクト: guylangston/SokoSolve
        public void CaseB_WithPath()
        {
            var report = new TestReport();

            var sample = new Puzzle(new string[]
            {
                "#############",
                "#a ###    b##",
                "# A######  ##",
                "#  ######B ##",
                "#########  ##",
                "#############",
            });

            var staticMaps = new StaticMaps()
            {
                FloorMap = sample.ToMap(' ', 'a', 'b'),
                WallMap = sample.ToMap('#')
            };
            var stateMaps = new StateMaps()
            {
                CrateMap = sample.ToMap('A', 'B'),
                MoveMap = FloodFill.Fill(staticMaps.WallMap, sample.First(x => x.State == 'b').Position)
            };

            var pushMap = PushMap.Find(staticMaps, stateMaps, sample.First(x => x.State == 'B').Position, sample.First(x => x.State == 'b').Position);

            report.WriteLine(pushMap);

            var path = pushMap.FindPlayerWalkRoute(new VectorInt2(6, 1));
            report.WriteLine(path);

            Assert.That(report, Is.EqualTo(new TestReport(
            @".............
            ......XXXX...
            .........X...
            .............
            .........X...
            .............

            DDDLUURULLL
            ")));
        }