Реализация тестирования

- Написал логику тестирования алгоритмов
- добавил заглушки лабиринтов
- реализовал сохранение результатов
- пока оставил файл тесторивания в корне проекта
This commit is contained in:
GordStep 2026-05-23 01:01:08 +03:00
parent ef877978d2
commit 762517d624
14 changed files with 3899 additions and 98 deletions

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,221 @@
Лабиринт,Алгоритм,Время,Посещено клеток,Длина пути
maze10x10,BFS,1.250000059371814e-05,3.0,3.0
maze10x10,BFS,1.5699999494245276e-05,3.0,3.0
maze10x10,BFS,1.940000038302969e-05,3.0,3.0
maze10x10,BFS,1.7299998944508843e-05,3.0,3.0
maze10x10,BFS,1.6299998605973087e-05,3.0,3.0
maze10x10,BFS,1.4799999917158855e-05,3.0,3.0
maze10x10,BFS,1.5400000847876072e-05,3.0,3.0
maze10x10,BFS,1.52000011439668e-05,3.0,3.0
maze10x10,BFS,1.6199999663513154e-05,3.0,3.0
maze10x10,BFS,1.6399999367422424e-05,3.0,3.0
maze10x10(среднее),BFS,1.5919999896141235e-05,3.0,3.0
maze50x50,BFS,1.2699998478638008e-05,3.0,3.0
maze50x50,BFS,1.5499999790336005e-05,3.0,3.0
maze50x50,BFS,1.4700000974698924e-05,3.0,3.0
maze50x50,BFS,1.4100000043981709e-05,3.0,3.0
maze50x50,BFS,1.429999974789098e-05,3.0,3.0
maze50x50,BFS,1.429999974789098e-05,3.0,3.0
maze50x50,BFS,1.7500000467407517e-05,3.0,3.0
maze50x50,BFS,1.429999974789098e-05,3.0,3.0
maze50x50,BFS,1.7099999240599573e-05,3.0,3.0
maze50x50,BFS,1.6399999367422424e-05,3.0,3.0
maze50x50(среднее),BFS,1.5089999760675707e-05,3.0,3.0
maze100x100,BFS,1.21000011858996e-05,3.0,3.0
maze100x100,BFS,1.300000076298602e-05,3.0,3.0
maze100x100,BFS,1.3700000636163168e-05,3.0,3.0
maze100x100,BFS,1.37999995786231e-05,3.0,3.0
maze100x100,BFS,1.7899999875226058e-05,3.0,3.0
maze100x100,BFS,1.429999974789098e-05,3.0,3.0
maze100x100,BFS,1.3999999282532372e-05,3.0,3.0
maze100x100,BFS,1.5600000551785342e-05,3.0,3.0
maze100x100,BFS,2.1699999706470408e-05,3.0,3.0
maze100x100,BFS,1.449999945180025e-05,3.0,3.0
maze100x100(среднее),BFS,1.5060000077937727e-05,3.0,3.0
maze_empty,BFS,0.008173700000043,5328.0,158.0
maze_empty,BFS,0.0085839000003034,5328.0,158.0
maze_empty,BFS,0.0088789999990694,5328.0,158.0
maze_empty,BFS,0.0087582000014663,5328.0,158.0
maze_empty,BFS,0.0082992000006925,5328.0,158.0
maze_empty,BFS,0.0087729999995644,5328.0,158.0
maze_empty,BFS,0.0085763000006409,5328.0,158.0
maze_empty,BFS,0.008612699999503,5328.0,158.0
maze_empty,BFS,0.008642000000691,5328.0,158.0
maze_empty,BFS,0.0085005000000819,5328.0,158.0
maze_empty(среднее),BFS,0.0085798500002056,5328.0,158.0
maze_no_path,BFS,1.1899999663000926e-05,3.0,3.0
maze_no_path,BFS,1.4199998986441642e-05,3.0,3.0
maze_no_path,BFS,1.5699999494245276e-05,3.0,3.0
maze_no_path,BFS,1.5300000086426735e-05,3.0,3.0
maze_no_path,BFS,1.559999873279594e-05,3.0,3.0
maze_no_path,BFS,1.37999995786231e-05,3.0,3.0
maze_no_path,BFS,1.489999885961879e-05,3.0,3.0
maze_no_path,BFS,1.5800000255694613e-05,3.0,3.0
maze_no_path,BFS,1.4999999621068127e-05,3.0,3.0
maze_no_path,BFS,1.359999987471383e-05,3.0,3.0
maze_no_path(среднее),BFS,1.4579999515262898e-05,3.0,3.0
maze10x10,DFS,1.0800000382005235e-05,3.0,3.0
maze10x10,DFS,1.2299999070819467e-05,3.0,3.0
maze10x10,DFS,1.199999860546086e-05,3.0,3.0
maze10x10,DFS,1.2399999832268804e-05,3.0,3.0
maze10x10,DFS,1.3099999705445953e-05,3.0,3.0
maze10x10,DFS,1.4100000043981709e-05,3.0,3.0
maze10x10,DFS,1.3900000340072438e-05,3.0,3.0
maze10x10,DFS,1.6399999367422424e-05,3.0,3.0
maze10x10,DFS,1.37999995786231e-05,3.0,3.0
maze10x10,DFS,1.3500000932253895e-05,3.0,3.0
maze10x10(среднее),DFS,1.3229999785835389e-05,3.0,3.0
maze50x50,DFS,1.2000000424450263e-05,3.0,3.0
maze50x50,DFS,1.4999999621068127e-05,3.0,3.0
maze50x50,DFS,1.5100000382517464e-05,3.0,3.0
maze50x50,DFS,1.9099999917671084e-05,3.0,3.0
maze50x50,DFS,1.4399998690350913e-05,3.0,3.0
maze50x50,DFS,1.550000160932541e-05,3.0,3.0
maze50x50,DFS,1.8300001102034003e-05,3.0,3.0
maze50x50,DFS,1.4999999621068127e-05,3.0,3.0
maze50x50,DFS,1.5800000255694613e-05,3.0,3.0
maze50x50,DFS,1.4600000213249588e-05,3.0,3.0
maze50x50(среднее),DFS,1.548000018374296e-05,3.0,3.0
maze100x100,DFS,1.179999890155159e-05,3.0,3.0
maze100x100,DFS,1.449999945180025e-05,3.0,3.0
maze100x100,DFS,1.5300000086426735e-05,3.0,3.0
maze100x100,DFS,1.5499999790336005e-05,3.0,3.0
maze100x100,DFS,1.8200000340584666e-05,3.0,3.0
maze100x100,DFS,1.82999992830446e-05,3.0,3.0
maze100x100,DFS,1.469999915570952e-05,3.0,3.0
maze100x100,DFS,1.5499999790336005e-05,3.0,3.0
maze100x100,DFS,1.469999915570952e-05,3.0,3.0
maze100x100,DFS,1.5699999494245276e-05,3.0,3.0
maze100x100(среднее),DFS,1.5419999544974417e-05,3.0,3.0
maze_empty,DFS,0.0335334999999759,5328.0,2578.0
maze_empty,DFS,0.0060880999990331,5328.0,2578.0
maze_empty,DFS,0.0061276000014913,5328.0,2578.0
maze_empty,DFS,0.0064875999996729,5328.0,2578.0
maze_empty,DFS,0.0059213000004092,5328.0,2578.0
maze_empty,DFS,0.0059658000009221,5328.0,2578.0
maze_empty,DFS,0.0105012000003625,5328.0,2578.0
maze_empty,DFS,0.006032100000084,5328.0,2578.0
maze_empty,DFS,0.0058865000009973,5328.0,2578.0
maze_empty,DFS,0.0061174999991635,5328.0,2578.0
maze_empty(среднее),DFS,0.0092661200002112,5328.0,2578.0
maze_no_path,DFS,1.0900001143454574e-05,3.0,3.0
maze_no_path,DFS,1.4799999917158855e-05,3.0,3.0
maze_no_path,DFS,1.5899999198154546e-05,3.0,3.0
maze_no_path,DFS,1.590000101714395e-05,3.0,3.0
maze_no_path,DFS,1.469999915570952e-05,3.0,3.0
maze_no_path,DFS,1.7099999240599573e-05,3.0,3.0
maze_no_path,DFS,1.4400000509340316e-05,3.0,3.0
maze_no_path,DFS,1.4200000805431046e-05,3.0,3.0
maze_no_path,DFS,1.37999995786231e-05,3.0,3.0
maze_no_path,DFS,1.4900000678608194e-05,3.0,3.0
maze_no_path(среднее),DFS,1.4660000124422367e-05,3.0,3.0
maze10x10,A*,1.8000000636675395e-05,3.0,3.0
maze10x10,A*,1.5800000255694613e-05,3.0,3.0
maze10x10,A*,1.5899999198154546e-05,3.0,3.0
maze10x10,A*,1.6099998902063817e-05,3.0,3.0
maze10x10,A*,1.5699999494245276e-05,3.0,3.0
maze10x10,A*,1.5499999790336005e-05,3.0,3.0
maze10x10,A*,2.249999852210749e-05,3.0,3.0
maze10x10,A*,1.8700000509852543e-05,3.0,3.0
maze10x10,A*,2.409999979136046e-05,3.0,3.0
maze10x10,A*,1.97000008483883e-05,3.0,3.0
maze10x10(среднее),A*,1.8199999794887843e-05,3.0,3.0
maze50x50,A*,1.4900000678608194e-05,3.0,3.0
maze50x50,A*,1.720000000204891e-05,3.0,3.0
maze50x50,A*,1.6999998479150236e-05,3.0,3.0
maze50x50,A*,1.6699999832781032e-05,3.0,3.0
maze50x50,A*,1.8599999748403206e-05,3.0,3.0
maze50x50,A*,1.700000029813964e-05,3.0,3.0
maze50x50,A*,1.700000029813964e-05,3.0,3.0
maze50x50,A*,1.680000059423037e-05,3.0,3.0
maze50x50,A*,1.939999856404029e-05,3.0,3.0
maze50x50,A*,1.9299999621580355e-05,3.0,3.0
maze50x50(среднее),A*,1.7389999811712187e-05,3.0,3.0
maze100x100,A*,1.4100000043981709e-05,3.0,3.0
maze100x100,A*,1.6200001482502557e-05,3.0,3.0
maze100x100,A*,1.5800000255694613e-05,3.0,3.0
maze100x100,A*,1.5300000086426735e-05,3.0,3.0
maze100x100,A*,1.700000029813964e-05,3.0,3.0
maze100x100,A*,1.650000012887176e-05,3.0,3.0
maze100x100,A*,1.700000029813964e-05,3.0,3.0
maze100x100,A*,1.739999970595818e-05,3.0,3.0
maze100x100,A*,1.700000029813964e-05,3.0,3.0
maze100x100,A*,1.739999970595818e-05,3.0,3.0
maze100x100(среднее),A*,1.6370000230381267e-05,3.0,3.0
maze_empty,A*,0.0133368999995582,5328.0,158.0
maze_empty,A*,0.0137166999993496,5328.0,158.0
maze_empty,A*,0.013524399999369,5328.0,158.0
maze_empty,A*,0.0135778000003483,5328.0,158.0
maze_empty,A*,0.0148759999992762,5328.0,158.0
maze_empty,A*,0.0137644999995245,5328.0,158.0
maze_empty,A*,0.0138386999988142,5328.0,158.0
maze_empty,A*,0.0137219999996887,5328.0,158.0
maze_empty,A*,0.0136103999993792,5328.0,158.0
maze_empty,A*,0.013797000001432,5328.0,158.0
maze_empty(среднее),A*,0.013776439999674,5328.0,158.0
maze_no_path,A*,1.6299998605973087e-05,3.0,3.0
maze_no_path,A*,1.8000000636675395e-05,3.0,3.0
maze_no_path,A*,2.1400001060101204e-05,3.0,3.0
maze_no_path,A*,1.8000000636675395e-05,3.0,3.0
maze_no_path,A*,1.8300001102034003e-05,3.0,3.0
maze_no_path,A*,1.7700000171316788e-05,3.0,3.0
maze_no_path,A*,1.7700000171316788e-05,3.0,3.0
maze_no_path,A*,1.6699999832781032e-05,3.0,3.0
maze_no_path,A*,1.6199999663513154e-05,3.0,3.0
maze_no_path,A*,1.6399999367422424e-05,3.0,3.0
maze_no_path(среднее),A*,1.7670000124780928e-05,3.0,3.0
maze10x10,Dijkstra,1.159999919764232e-05,3.0,3.0
maze10x10,Dijkstra,1.2600001355167478e-05,3.0,3.0
maze10x10,Dijkstra,1.4400000509340316e-05,3.0,3.0
maze10x10,Dijkstra,1.320000046689529e-05,3.0,3.0
maze10x10,Dijkstra,1.359999987471383e-05,3.0,3.0
maze10x10,Dijkstra,1.7700000171316788e-05,3.0,3.0
maze10x10,Dijkstra,1.3900000340072438e-05,3.0,3.0
maze10x10,Dijkstra,1.3299999409355223e-05,3.0,3.0
maze10x10,Dijkstra,1.2599999536178076e-05,3.0,3.0
maze10x10,Dijkstra,1.52000011439668e-05,3.0,3.0
maze10x10(среднее),Dijkstra,1.3810000200464857e-05,3.0,3.0
maze50x50,Dijkstra,1.250000059371814e-05,3.0,3.0
maze50x50,Dijkstra,1.8200000340584666e-05,3.0,3.0
maze50x50,Dijkstra,1.3500000932253895e-05,3.0,3.0
maze50x50,Dijkstra,1.340000017080456e-05,3.0,3.0
maze50x50,Dijkstra,1.300000076298602e-05,3.0,3.0
maze50x50,Dijkstra,1.2999998943996616e-05,3.0,3.0
maze50x50,Dijkstra,1.2599999536178076e-05,3.0,3.0
maze50x50,Dijkstra,1.3500000932253895e-05,3.0,3.0
maze50x50,Dijkstra,1.3900000340072438e-05,3.0,3.0
maze50x50,Dijkstra,1.4400000509340316e-05,3.0,3.0
maze50x50(среднее),Dijkstra,1.3800000306218863e-05,3.0,3.0
maze100x100,Dijkstra,1.5699999494245276e-05,3.0,3.0
maze100x100,Dijkstra,1.429999974789098e-05,3.0,3.0
maze100x100,Dijkstra,1.5100000382517464e-05,3.0,3.0
maze100x100,Dijkstra,1.4400000509340316e-05,3.0,3.0
maze100x100,Dijkstra,1.4200000805431046e-05,3.0,3.0
maze100x100,Dijkstra,1.4999999621068127e-05,3.0,3.0
maze100x100,Dijkstra,1.429999974789098e-05,3.0,3.0
maze100x100,Dijkstra,1.3699998817173764e-05,3.0,3.0
maze100x100,Dijkstra,1.4199998986441642e-05,3.0,3.0
maze100x100,Dijkstra,1.3700000636163168e-05,3.0,3.0
maze100x100(среднее),Dijkstra,1.4459999874816276e-05,3.0,3.0
maze_empty,Dijkstra,0.0113691000005928,5328.0,158.0
maze_empty,Dijkstra,0.0113638999991962,5328.0,158.0
maze_empty,Dijkstra,0.0113867999989452,5328.0,158.0
maze_empty,Dijkstra,0.0116022000001976,5328.0,158.0
maze_empty,Dijkstra,0.0113552000002528,5328.0,158.0
maze_empty,Dijkstra,0.0113825999997061,5328.0,158.0
maze_empty,Dijkstra,0.0113117999990208,5328.0,158.0
maze_empty,Dijkstra,0.011768900001698,5328.0,158.0
maze_empty,Dijkstra,0.0116283999996085,5328.0,158.0
maze_empty,Dijkstra,0.0114497000013216,5328.0,158.0
maze_empty(среднее),Dijkstra,0.011461860000054,5328.0,158.0
maze_no_path,Dijkstra,1.2000000424450263e-05,3.0,3.0
maze_no_path,Dijkstra,1.3500000932253895e-05,3.0,3.0
maze_no_path,Dijkstra,1.6099998902063817e-05,3.0,3.0
maze_no_path,Dijkstra,1.449999945180025e-05,3.0,3.0
maze_no_path,Dijkstra,1.4199998986441642e-05,3.0,3.0
maze_no_path,Dijkstra,1.429999974789098e-05,3.0,3.0
maze_no_path,Dijkstra,1.3900000340072438e-05,3.0,3.0
maze_no_path,Dijkstra,1.3900000340072438e-05,3.0,3.0
maze_no_path,Dijkstra,1.3399998351815157e-05,3.0,3.0
maze_no_path,Dijkstra,1.3499999113264494e-05,3.0,3.0
maze_no_path(среднее),Dijkstra,1.3929999659012537e-05,3.0,3.0
unable to load file

View File

@ -0,0 +1,312 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "688ee55a",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# Переходим из docs/data/ в корень lab/\n",
"os.chdir('../../')\n",
"\n",
"from source import TextFileMazeBuilder\n",
"from source.observer import ConsoleView, Event\n",
"from source.strategy import MazeSolver, BFS, DFS, Dijkstra, AStar\n",
"# from source.strategy.maze_solver import \n",
"from source.classes import Cell, Maze"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "70b2bfca",
"metadata": {},
"outputs": [],
"source": [
"builder = TextFileMazeBuilder()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6700366a",
"metadata": {},
"outputs": [],
"source": [
"path_maze100x100 = 'mazes\\\\benchmarks\\\\maze_empty.txt'"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "72959083",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"height: 50\n",
"width: 113\n",
"start: (1, 1)\n",
"exit: (111, 48)\n",
"count cells: 5650\n",
"BFS\n",
"Путь найден:\n",
"#################################################################################################################\n",
"#S #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#..............................................................................................................E#\n",
"#################################################################################################################\n",
"time: 0.009009700000206067 ms\n",
"visited cells: 5328\n",
"path length: 158\n",
"DFS\n",
"Путь найден:\n",
"#################################################################################################################\n",
"#S..............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"#...............................................................................................................#\n",
"#. #\n",
"#...............................................................................................................#\n",
"# .#\n",
"# .#\n",
"# E#\n",
"#################################################################################################################\n",
"time: 0.005747199999859731 ms\n",
"visited cells: 5328\n",
"path length: 2578\n",
"A*\n",
"Путь найден:\n",
"#################################################################################################################\n",
"#S #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#..............................................................................................................E#\n",
"#################################################################################################################\n",
"time: 0.013083499999993364 ms\n",
"visited cells: 5328\n",
"path length: 158\n",
"Dijkstra\n",
"Путь найден:\n",
"#################################################################################################################\n",
"#S #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#..............................................................................................................E#\n",
"#################################################################################################################\n",
"time: 0.011428499999965425 ms\n",
"visited cells: 5328\n",
"path length: 158\n"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a60c907a",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@ -0,0 +1,3 @@
####
S E#
####

View File

@ -0,0 +1,3 @@
####
S E#
####

View File

@ -0,0 +1,3 @@
####
S E#
####

View File

@ -0,0 +1,50 @@
#################################################################################################################
#S #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# E#
#################################################################################################################

View File

@ -0,0 +1,3 @@
####
S E#
####

View File

@ -0,0 +1,9 @@
####################
#S #
# ########## #
# #### #
# ######## #
# #
# ####### #######
# #E #
####################

View File

@ -0,0 +1,4 @@
from .builder import *
from .classes import *
from .observer import *
from .strategy import *

View File

@ -39,4 +39,8 @@ class Maze:
for c in line:
print(c.toStr(), end='')
print()
print()
def info(self):
"""Основная информация о лабиринте"""
print(f'height: {self.height}\nwidth: {self.width}\nstart: {self.start.getXY()}\nexit: {self.exit.getXY()}\ncount cells: {self.height * self.width}')

View File

@ -49,4 +49,7 @@ class SearchStats:
def show(self):
"""Вывод информации о тесте в консоль"""
print(f'time: {self.timeMs} ms\nvisited cells: {self.visitedCells}\npath length: {self.pathLength}')
print(f'time: {self.timeMs} ms\nvisited cells: {self.visitedCells}\npath length: {self.pathLength}')
# def toStr(self) -> str:
# return f'{self.timeMs} {self.visitedCells} {self.pathLength}'

View File

@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 53,
"id": "4dbe48b6",
"metadata": {},
"outputs": [],
@ -17,7 +17,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 68,
"id": "007bf97a",
"metadata": {},
"outputs": [],
@ -25,12 +25,13 @@
"test_lab = './mazes/tests/test_lab.txt'\n",
"test_lab2 = './mazes/tests/test_lab2.txt'\n",
"test_lab3 = './mazes/tests/test_lab3.txt'\n",
"test_lab4 = './mazes/tests/test_lab20x20.txt'"
"test_lab4 = './mazes/tests/test_lab20x20.txt'\n",
"test_labNoPath = './mazes/tests/test_labNoPath.txt'"
]
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 55,
"id": "4489fc7e",
"metadata": {},
"outputs": [
@ -56,7 +57,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 56,
"id": "fde1eddb",
"metadata": {},
"outputs": [
@ -84,7 +85,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 57,
"id": "22325f68",
"metadata": {},
"outputs": [
@ -117,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 58,
"id": "19840429",
"metadata": {},
"outputs": [
@ -155,7 +156,7 @@
" (7, 1)])"
]
},
"execution_count": 20,
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
@ -169,7 +170,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 59,
"id": "73ba37a8",
"metadata": {},
"outputs": [
@ -207,7 +208,7 @@
" (7, 1)])"
]
},
"execution_count": 21,
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
@ -221,7 +222,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 60,
"id": "857c5c04",
"metadata": {},
"outputs": [
@ -243,7 +244,7 @@
"{'0', '1', '2', '3', '4'}"
]
},
"execution_count": 22,
"execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
@ -272,7 +273,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 61,
"id": "9a5ea5cb",
"metadata": {},
"outputs": [
@ -358,7 +359,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 62,
"id": "32edf4d1",
"metadata": {},
"outputs": [
@ -383,7 +384,88 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 70,
"id": "dc7708c7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"BFS\n",
"Путь найден:\n",
"####################\n",
"#S #\n",
"# ########## #\n",
"# #### #\n",
"# ######## #\n",
"# #\n",
"# ####### #######\n",
"# #E #\n",
"####################\n",
"time: 0.00013750000016443664 ms\n",
"visited cells: 88\n",
"path length: 0\n",
"DFS\n",
"Путь найден:\n",
"####################\n",
"#S #\n",
"# ########## #\n",
"# #### #\n",
"# ######## #\n",
"# #\n",
"# ####### #######\n",
"# #E #\n",
"####################\n",
"time: 0.0001343000003544148 ms\n",
"visited cells: 88\n",
"path length: 0\n",
"A*\n",
"Путь найден:\n",
"####################\n",
"#S #\n",
"# ########## #\n",
"# #### #\n",
"# ######## #\n",
"# #\n",
"# ####### #######\n",
"# #E #\n",
"####################\n",
"time: 0.0002116999994541402 ms\n",
"visited cells: 89\n",
"path length: 0\n",
"Dijkstra\n",
"Путь найден:\n",
"####################\n",
"#S #\n",
"# ########## #\n",
"# #### #\n",
"# ######## #\n",
"# #\n",
"# ####### #######\n",
"# #E #\n",
"####################\n",
"time: 0.00016429999959655106 ms\n",
"visited cells: 88\n",
"path length: 0\n"
]
}
],
"source": [
"maze = builder.buildFromFile(test_labNoPath)\n",
"\n",
"strats = [BFS(), DFS(), AStar(), Dijkstra()]\n",
"\n",
"for strat in strats:\n",
" solver = MazeSolver(maze, strat, ConsoleView())\n",
" print(solver.strategyName())\n",
" stats = solver.solve()\n",
" stats.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "48d20564",
"metadata": {},
"outputs": [
@ -393,25 +475,23 @@
"text": [
"BFS\n",
"Путь найден:\n",
"#####################################\n",
"#S #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#. #\n",
"#..................................E#\n",
"#####################################\n",
"time: 0.0008461000002171204 ms\n",
"visited cells: 315\n",
"path length: 43\n"
"####################\n",
"#S #\n",
"#. ########## #\n",
"#. #### #\n",
"#. ######## #\n",
"#. #\n",
"#. ####### #### #\n",
"#................E #\n",
"####################\n",
"time: 0.00018309999995835824 ms\n",
"visited cells: 92\n",
"path length: 23\n"
]
}
],
"source": [
"maze2 = builder.buildFromFile(test_lab2)\n",
"maze2 = builder.buildFromFile(test_lab3)\n",
"\n",
"solver = MazeSolver(maze2, BFS(), ConsoleView())\n",
"print(solver.strategyName())\n",
@ -421,7 +501,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 64,
"id": "bf13d5ba",
"metadata": {},
"outputs": [
@ -432,28 +512,17 @@
"DFS\n",
"Путь найден:\n",
"####################\n",
"S...# # # #\n",
"###.# ### # ### # ##\n",
"#...# # # # # # # ##\n",
"#.### # ### # ### ##\n",
"#.# .....# # # ##\n",
"#.###.###.### # # ##\n",
"#.# #.# #...# # # ##\n",
"#.# #.# ###.# # # ##\n",
"#.# #.# #.# # # ##\n",
"#.# #.### #.# # # ##\n",
"#.# #...# #...# # ##\n",
"#.# ###.# ###.# # ##\n",
"#.# #.# #.# ##\n",
"#.### #.### #.### ##\n",
"#.#...#.# # #.# # ##\n",
"#.#.#.#.# # #.# # ##\n",
"#.#.#.#.# # #.# # ##\n",
"#...#...# #.....E#\n",
"#S.................#\n",
"# ########## .#\n",
"# ####............#\n",
"#....... ######## #\n",
"#. #\n",
"#...####### #### #\n",
"# ..............E #\n",
"####################\n",
"time: 0.00014700000019729487 ms\n",
"visited cells: 83\n",
"path length: 76\n"
"time: 0.0001617000002624991 ms\n",
"visited cells: 79\n",
"path length: 57\n"
]
}
],
@ -468,7 +537,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 65,
"id": "9383cb75",
"metadata": {},
"outputs": [
@ -479,28 +548,17 @@
"Dijkstra\n",
"Путь найден:\n",
"####################\n",
"S...# # # #\n",
"###.# ### # ### # ##\n",
"#...# # # # # # # ##\n",
"#.### # ### # ### ##\n",
"#.# .....# # # ##\n",
"#.###.###.### # # ##\n",
"#.# #.# #...# # # ##\n",
"#.# #.# ###.# # # ##\n",
"#.# #.# #.# # # ##\n",
"#.# #.### #.# # # ##\n",
"#.# #...# #...# # ##\n",
"#.# ###.# ###.# # ##\n",
"#.# #.# #.# ##\n",
"#.### #.### #.### ##\n",
"#.#...#.# # #.# # ##\n",
"#.#.#.#.# # #.# # ##\n",
"#.#.#.#.# # #.# # ##\n",
"#...#...# #.....E#\n",
"#S #\n",
"#. ########## #\n",
"#. #### #\n",
"#. ######## #\n",
"#. #\n",
"#. ####### #### #\n",
"#................E #\n",
"####################\n",
"time: 0.00022080000007917988 ms\n",
"visited cells: 120\n",
"path length: 76\n"
"time: 0.00021570000035353587 ms\n",
"visited cells: 92\n",
"path length: 23\n"
]
}
],
@ -515,7 +573,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 66,
"id": "835cff61",
"metadata": {},
"outputs": [
@ -526,28 +584,17 @@
"A*\n",
"Путь найден:\n",
"####################\n",
"S...# # # #\n",
"###.# ### # ### # ##\n",
"#...# # # # # # # ##\n",
"#.### # ### # ### ##\n",
"#.# .....# # # ##\n",
"#.###.###.### # # ##\n",
"#.# #.# #...# # # ##\n",
"#.# #.# ###.# # # ##\n",
"#.# #.# #.# # # ##\n",
"#.# #.### #.# # # ##\n",
"#.# #...# #...# # ##\n",
"#.# ###.# ###.# # ##\n",
"#.# #.# #.# ##\n",
"#.### #.### #.### ##\n",
"#.#...#.# # #.# # ##\n",
"#.#.#.#.# # #.# # ##\n",
"#.#.#.#.# # #.# # ##\n",
"#...#...# #.....E#\n",
"#S #\n",
"#. ########## #\n",
"#. #### #\n",
"#. ######## #\n",
"#. #\n",
"#. ####### #### #\n",
"#................E #\n",
"####################\n",
"time: 0.00025749999986146577 ms\n",
"visited cells: 92\n",
"path length: 76\n"
"time: 0.00021229999993011006 ms\n",
"visited cells: 89\n",
"path length: 23\n"
]
}
],