From d05d292101709b39db5ec8d79be6f3d7894fcf0e Mon Sep 17 00:00:00 2001 From: SerKin0 <71343548+SerKin0@users.noreply.github.com> Date: Wed, 20 May 2026 11:38:02 +0300 Subject: [PATCH] =?UTF-8?q?[2]=20=D0=A1=D1=82=D0=B0=D1=80=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D1=8F=20=D1=81=D0=B1=D0=BE=D1=80=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skorohodovsa/task_2/.gitignore | 1 + skorohodovsa/task_2/README.md | 103 +++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 skorohodovsa/task_2/.gitignore create mode 100644 skorohodovsa/task_2/README.md diff --git a/skorohodovsa/task_2/.gitignore b/skorohodovsa/task_2/.gitignore new file mode 100644 index 0000000..af253e0 --- /dev/null +++ b/skorohodovsa/task_2/.gitignore @@ -0,0 +1 @@ +/.obsidian \ No newline at end of file diff --git a/skorohodovsa/task_2/README.md b/skorohodovsa/task_2/README.md new file mode 100644 index 0000000..e8ab679 --- /dev/null +++ b/skorohodovsa/task_2/README.md @@ -0,0 +1,103 @@ +# Поиск выхода из лабиринта +--- +## Цель работы + +Разработать гибкую, расширяемую программу для загрузки лабиринта из файла, поиска пути от старта до выхода с возможностью выбора алгоритма, визуализации процесса и экспериментального сравнения алгоритмов. В ходе работы необходимо применить минимум 3 паттерна проектирования из списка GoF, обосновать их выбор и продемонстрировать преимущества такой архитектуры. + +--- +## Архитектура + +```mermaid +classDiagram + class Maze { + -Cell[] cells + -int width, height + -Cell start + -Cell exit + +getCell(x,y): Cell + +getNeighbors(cell): List~Cell~ + } + + class Cell { + -int x, y + -bool isWall + -bool isStart + -bool isExit + +isPassable(): bool + } + + class MazeBuilder { + <> + +buildFromFile(filename): Maze + } + + class TextFileMazeBuilder { + +buildFromFile(filename): Maze + } + + class PathFindingStrategy { + <> + +findPath(maze, start, exit): List~Cell~ + } + + class BFSStrategy + class DFSStrategy + class AStarStrategy + class DijkstraStrategy + + class SearchStats { + +timeMs: float + +visitedCells: int + +pathLength: int + } + + class MazeSolver { + -Maze maze + -PathFindingStrategy strategy + +setStrategy(strategy) + +solve(): SearchStats + } + + class Command { + <> + +execute() + +undo() + } + + class MoveCommand { + -Player player + -Direction dir + -Cell previousCell + +execute() + +undo() + } + + class Player { + -Cell currentCell + +moveTo(cell) + } + + class Observer { + <> + +update(event) + } + + class ConsoleView { + +update(event) + +render(maze, player, path) + } + + MazeBuilder <|.. TextFileMazeBuilder + MazeBuilder --> Maze : creates + PathFindingStrategy <|.. BFSStrategy + PathFindingStrategy <|.. DFSStrategy + PathFindingStrategy <|.. AStarStrategy + PathFindingStrategy <|.. DijkstraStrategy + MazeSolver --> PathFindingStrategy : uses + MazeSolver --> Maze : uses + Command <|.. MoveCommand + MoveCommand --> Player + Player --> Cell + Observer <|.. ConsoleView + MazeSolver --> Observer : notifies +```