Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

kysect/MazeGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MazeGenerator

Nuget

MazeGenerator - учебная библиотека, которая позволяет генерировать карты для игры в лабиринт.

Карта лабиринта представляет из себя матрицу Сells[][]

public enum Cells
{
    Wall,
    Empty,
    Exit
}

Пример создания лабиринта

int size = 5;
IMapGenerator generator = new GrowingTreeGenerator();
var maze = new Maze(generator.Generate(size));
maze.AddExit();
for (int i = 0; i < maze.Size; i++)
{
for (int j = 0; j < maze.Size; j++)
{
Console.Write(CellToString(maze.Map[i][j]));
Console.Write(" ");
}
Console.WriteLine();
}
string CellToString(Cells cellType)
{
return cellType switch
{
Cells.Wall => "0",
Cells.Empty => " ",
Cells.Exit => "#",
_ => throw new ArgumentOutOfRangeException(nameof(cellType), cellType, null)
};
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages