本文整理汇总了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..........
.............
............."
)));
}
示例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..
.............
"
)));
}
示例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);
}
示例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
")));
}