当前位置: 首页>>代码示例>>C#>>正文


C# Puzzle.First方法代码示例

本文整理汇总了C#中Puzzle.First方法的典型用法代码示例。如果您正苦于以下问题:C# Puzzle.First方法的具体用法?C# Puzzle.First怎么用?C# Puzzle.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Puzzle的用法示例。


在下文中一共展示了Puzzle.First方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CaseA

        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..........
            .............
            ............."
                )));
        }
开发者ID:guylangston,项目名称:SokoSolve,代码行数:40,代码来源:PushMapTests.cs

示例2: MultipleCrates

        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..
            .............
            "
                )));
        }
开发者ID:guylangston,项目名称:SokoSolve,代码行数:41,代码来源:PushMapTests.cs

示例3: OverAndBackAgain

        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);
        }
开发者ID:guylangston,项目名称:SokoSolve,代码行数:54,代码来源:PushMapTests.cs

示例4: CaseB_WithPath

        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
            ")));
        }
开发者ID:guylangston,项目名称:SokoSolve,代码行数:43,代码来源:PushMapTests.cs


注:本文中的Puzzle.First方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。