[1][2] Labs #338
1
skorohodovsa/task_2/.gitignore
vendored
Normal file
1
skorohodovsa/task_2/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/.obsidian
|
||||
103
skorohodovsa/task_2/README.md
Normal file
103
skorohodovsa/task_2/README.md
Normal file
|
|
@ -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 {
|
||||
<<interface>>
|
||||
+buildFromFile(filename): Maze
|
||||
}
|
||||
|
||||
class TextFileMazeBuilder {
|
||||
+buildFromFile(filename): Maze
|
||||
}
|
||||
|
||||
class PathFindingStrategy {
|
||||
<<interface>>
|
||||
+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 {
|
||||
<<interface>>
|
||||
+execute()
|
||||
+undo()
|
||||
}
|
||||
|
||||
class MoveCommand {
|
||||
-Player player
|
||||
-Direction dir
|
||||
-Cell previousCell
|
||||
+execute()
|
||||
+undo()
|
||||
}
|
||||
|
||||
class Player {
|
||||
-Cell currentCell
|
||||
+moveTo(cell)
|
||||
}
|
||||
|
||||
class Observer {
|
||||
<<interface>>
|
||||
+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
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user