public MazeGenerationFactory( IMazeModelFactory mazeModelFactory, IGrowingTreeAlgorithm growingTreeAlgorithm, IMazeFactory mazeFactory, IDeadEndFiller deadEndFiller, IRandomCarver randomCarver, IExtraWallCalculator extraWall, IRecursiveBacktrackerAlgorithm recursiveBacktrackerAlgorithm, IBinaryTreeAlgorithm binaryTreeAlgorithm, IHeuristicsGenerator heuristicsGenerator, IAgentFactory agentFactory, ITimeRecorder timeRecorder) { _mazeModelFactory = mazeModelFactory; _growingTreeAlgorithm = growingTreeAlgorithm; _mazeFactory = mazeFactory; _deadEndFiller = deadEndFiller; _randomCarver = randomCarver; _extraWall = extraWall; _recursiveBacktrackerAlgorithm = recursiveBacktrackerAlgorithm; _binaryTreeAlgorithm = binaryTreeAlgorithm; _heuristicsGenerator = heuristicsGenerator; _agentFactory = agentFactory; _timeRecorder = timeRecorder; }
public Game(ILevelFactory levelFactory, IGameSettingLoader gameSettingLoader, IDisplay display, IMazeFactory mazeFactory, IPlayerInput playerInput) { _levelFactory = levelFactory; _gameSettingLoader = gameSettingLoader; _display = display; _mazeFactory = mazeFactory; _playerInput = playerInput; }
public void RecursiveBacktrackerSolvableTest() { for (int setNumber = 0; setNumber < TEST_SET_SIZE; setNumber++) { RecursiveBacktracker rb = new RecursiveBacktracker(); IMazeFactory factory = rb; ISolver solver = rb; Maze recursiveBacktracerMaze = factory.generate(ROWS_COUNT, COLUMNSCOUNT); Assert.IsTrue(solver.IsSolvable(recursiveBacktracerMaze)); } }
public void PrimsSolvableTest() { for (int setNumber = 0; setNumber < TEST_SET_SIZE; setNumber++) { PrimsAlgorithm pa = new PrimsAlgorithm(); IMazeFactory factory = pa; ISolver solver = new RecursiveBacktracker(); Maze prismMaze = factory.generate(ROWS_COUNT, COLUMNSCOUNT); Assert.IsTrue(solver.IsSolvable(prismMaze)); } }
public Maze CreateMaze(IMazeFactory factory) { var maze = factory.MakeMaze(); var r1 = factory.MakeRoom(1); var r3 = factory.MakeRoom(3); var aDoor = factory.MakeDoor(r1, r3); maze.AddRoom(r1); maze.AddRoom(r3); return(maze); }
static async Task Main(string[] args) { ServiceCollection serviceCollection = ConfigureServices(); var services = serviceCollection.BuildServiceProvider(); IPonyAPIClient ponyAPI = services.GetRequiredService <IPonyAPIClient>(); IMazeFactory factory = services.GetRequiredService <IMazeFactory>(); IMazePathfinder pathfinder = services.GetRequiredService <IMazePathfinder>(); IMazeWalker walker = services.GetRequiredService <IMazeWalker>(); Maze maze = null; while (maze is null) { Console.WriteLine("Enter a maze GUID or press enter for a new maze:"); string input = Console.ReadLine(); if (input != "") { if (Guid.TryParse(input, out Guid mazeId)) { maze = await factory.FromID(mazeId); } else { Console.WriteLine("Could not parse mazeId"); } } else { maze = await factory.Create(); Console.WriteLine($"Maze ID {maze.MazeId} created."); } } Console.WriteLine(await ponyAPI.GetVisualMaze(maze.MazeId)); Path ponyPath = pathfinder.Solve(maze); Console.WriteLine("Here's the ideal path of the pony, let's see it in action:"); Console.WriteLine(ponyPath); await walker.Walk(ponyPath); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); services.Dispose(); }
public virtual void CreateMaze(IMazeFactory factory) { maze = factory.CreateMaze(); Room room1 = factory.CreateRoom1(); Room room2 = factory.CreateRoom2(); Portal portal1 = factory.CreatePortal(room1, new Vector3(0, 0, 2f)); Portal portal2 = factory.CreatePortal(room2, new Vector3(2f, 0, 0)); portal1.SetExit(portal2); portal2.SetExit(portal1); maze.AddRoom(room1); maze.AddRoom(room2); maze.Load(); }
public IMaze CreateMaze(IMazeFactory factory) { var maze = factory.MakeMaze(); var r1 = factory.MakeRoom(0); var r2 = factory.MakeRoom(1); var door = factory.MakeDoor(r1, r2); maze.AddRoom(r1); maze.AddRoom(r2); r1.SetSide(Direction.North, factory.MakeWall()); r1.SetSide(Direction.East, door); r1.SetSide(Direction.South, factory.MakeWall()); r1.SetSide(Direction.West, factory.MakeWall()); r2.SetSide(Direction.North, factory.MakeWall()); r2.SetSide(Direction.East, factory.MakeWall()); r2.SetSide(Direction.South, factory.MakeWall()); r2.SetSide(Direction.West, door); return(maze); }
public FileMazeGenerator(IMazeFactory mazeFactory) { _maze = mazeFactory.CreateMaze(); }
public DynamicMazeGenerator(IMazeFactory mazeFactory) { _maze = mazeFactory.CreateMaze(); }
public MazeWalker(IPonyAPIClient ponyClient, IMazeFactory factory) { this.ponyClient = ponyClient; this.factory = factory; }
private void DrawMaze(MazeSize size) { MazeGrid.Children.Clear(); MazeGrid.RowDefinitions.Clear(); MazeGrid.ColumnDefinitions.Clear(); IMazeFactory mazefactory = MazeFactoryStratigy.GetMazeFactory(MazeStratigy.WidthFirst); Maze maze = mazefactory.BuildMaze(size); int mazeSize = maze.Size; double height = MazeGrid.Height / mazeSize; for (int i = 0; i < mazeSize; i++) { MazeGrid.RowDefinitions.Add(new RowDefinition()); MazeGrid.ColumnDefinitions.Add(new ColumnDefinition()); } DrawingBrush _gridBrush; _gridBrush = new DrawingBrush(new GeometryDrawing( new SolidColorBrush(Colors.Red), new Pen(new SolidColorBrush(Colors.Black), 1.0), new EllipseGeometry(new Rect(0, 0, height / 2, height / 2)))); _gridBrush.Stretch = Stretch.None; _gridBrush.TileMode = TileMode.Tile; _gridBrush.Viewport = new Rect(0.0, 0.0, height, height); _gridBrush.ViewportUnits = BrushMappingMode.Absolute; DrawingBrush _gridBrushEndPoint; _gridBrushEndPoint = new DrawingBrush(new GeometryDrawing( new SolidColorBrush(Colors.Black), new Pen(new SolidColorBrush(Colors.Black), 1.0), new EllipseGeometry(new Rect(0, 0, height / 2, height / 2)))); _gridBrushEndPoint.Stretch = Stretch.None; _gridBrushEndPoint.TileMode = TileMode.Tile; _gridBrushEndPoint.Viewport = new Rect(0.0, 0.0, height, height); _gridBrushEndPoint.ViewportUnits = BrushMappingMode.Absolute; int borderthickness = 2; for (int i = 0; i < mazeSize; i++) { for (int j = 0; j < mazeSize; j++) { Border bd = new Border(); bd.Background = Brushes.Black; bd.BorderBrush = Brushes.Black; if (i == 0 && j < mazeSize - 1) { bd.BorderThickness = new Thickness(borderthickness, borderthickness, 0, borderthickness); } else { bd.BorderThickness = new Thickness(borderthickness, 0, 0, borderthickness); } if (j == mazeSize - 1 && i > 0) { bd.BorderThickness = new Thickness(borderthickness, 0, borderthickness, borderthickness); } else if (i > 0) { bd.BorderThickness = new Thickness(borderthickness, 0, 0, borderthickness); } if (i == 0 && j == mazeSize - 1) { bd.BorderThickness = new Thickness(borderthickness); } Grid.SetColumn(bd, j); Grid.SetRow(bd, i); MazeGrid.Children.Add(bd); } } for (int row = 0; row < mazeSize; row++) { for (int col = 0; col < mazeSize; col++) { var bd = GetGridBorder(row, col); bd.Background = Brushes.White; var nbs = maze.GetPassedNeighbors(new MazeCell() { X = row, Y = col }); for (int b = 0; b < nbs.Count; b++) { var border = GetGridBorder(nbs[b].X, nbs[b].Y); border.Background = Brushes.White; if (row == nbs[b].X && col < nbs[b].Y) //right { border.BorderThickness = new Thickness(0, border.BorderThickness.Top, border.BorderThickness.Right, border.BorderThickness.Bottom); bd.BorderThickness = new Thickness(bd.BorderThickness.Left, bd.BorderThickness.Top, 0, bd.BorderThickness.Bottom); } if (row == nbs[b].X && col > nbs[b].Y) //Left { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Top, 0, border.BorderThickness.Bottom); bd.BorderThickness = new Thickness(0, bd.BorderThickness.Top, bd.BorderThickness.Right, bd.BorderThickness.Bottom); } if (row < nbs[b].X && col == nbs[b].Y) //bottom { border.BorderThickness = new Thickness(border.BorderThickness.Left, 0, border.BorderThickness.Right, border.BorderThickness.Bottom); bd.BorderThickness = new Thickness(bd.BorderThickness.Left, bd.BorderThickness.Top, bd.BorderThickness.Right, 0); } if (row > nbs[b].X && col == nbs[b].Y)//top { border.BorderThickness = new Thickness(border.BorderThickness.Left, border.BorderThickness.Top, border.BorderThickness.Right, 0); bd.BorderThickness = new Thickness(bd.BorderThickness.Left, 0, bd.BorderThickness.Right, bd.BorderThickness.Bottom); } } } } var startPoint = GetGridBorder(maze.StartPoint.X, maze.StartPoint.Y); startPoint.Background = _gridBrush; startPoint.BorderThickness = new Thickness(startPoint.BorderThickness.Left, 0, startPoint.BorderThickness.Right, startPoint.BorderThickness.Bottom); var exitPoint = GetGridBorder(maze.Size - 1, maze.Size - 1); exitPoint.Background = _gridBrushEndPoint; exitPoint.BorderThickness = new Thickness(exitPoint.BorderThickness.Left, exitPoint.BorderThickness.Top, exitPoint.BorderThickness.Right, 0); }
// Use this for initialization void Start() { _MazeFactory = Locator.GetMazeFactory; CreateMaze(_MazeFactory); }
public MazeFactoryTests() { mazeFactory = new MazeFactory(); randomGenerator = new MockRandomGeneratorMin(); }
public ConsoleMaze(IMazeFactory mazeFactory, IDrawCell drawCell) : base(mazeFactory) { _drawCell = drawCell; }
protected Maze(IMazeFactory mazeFactory) { _mazeFactory = mazeFactory; }
public MazeSolver(IMazeFactory mazeFactory) { _mazeFactory = mazeFactory; }
public static void Provide(IMazeFactory mazeFactory) { _mazeFactoryService = mazeFactory ?? new NullMazeFactory(); }
public CountingMazeBuilder(IMazeFactory factory) { _factory = factory; _rooms = _doors = 0; }
public StandartMazeBuilder(IMazeFactory factory) { _currentMaze = null; _factory = factory; }