mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
ascii print + fix maze generator kruskal
This commit is contained in:
+13
-7
@@ -1,15 +1,21 @@
|
|||||||
|
import os
|
||||||
|
from numpy import ma
|
||||||
from src.amaz_lib import MazeGenerator
|
from src.amaz_lib import MazeGenerator
|
||||||
from src.amaz_lib import Maze
|
from src.amaz_lib import Maze
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
try:
|
# try:
|
||||||
maze = Maze(maze=None, start=(1, 1), end=(16, 15))
|
maze = Maze(maze=None, start=(1, 1), end=(16, 15))
|
||||||
for alg in MazeGenerator.Kruskal.kruskal(20, 20):
|
for alg in MazeGenerator.Kruskal.kruskal(20, 20):
|
||||||
maze.set_maze(alg)
|
maze.set_maze(alg)
|
||||||
maze.export_maze("test.txt")
|
os.system("clear")
|
||||||
except Exception as err:
|
maze.ascii_print()
|
||||||
print(err)
|
maze.export_maze("test.txt")
|
||||||
|
|
||||||
|
|
||||||
|
# except Exception as err:
|
||||||
|
# print(err)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
@@ -19,13 +19,23 @@ class MazeGenerator:
|
|||||||
case 1:
|
case 1:
|
||||||
maze[math.trunc((x / width))][x % width].set_est(True)
|
maze[math.trunc((x / width))][x % width].set_est(True)
|
||||||
maze[math.trunc((y / width))][y % width].set_west(True)
|
maze[math.trunc((y / width))][y % width].set_west(True)
|
||||||
case 5:
|
case width:
|
||||||
maze[math.trunc((x / width))][x % width].set_south(
|
maze[math.trunc((x / width))][x % width].set_south(
|
||||||
True
|
True
|
||||||
)
|
)
|
||||||
maze[math.trunc((y / width))][y % width].set_north(
|
maze[math.trunc((y / width))][y % width].set_north(
|
||||||
True
|
True
|
||||||
)
|
)
|
||||||
|
for x in range(height):
|
||||||
|
for y in range(width):
|
||||||
|
if x == 0:
|
||||||
|
maze[x][y].set_north(True)
|
||||||
|
if x == height - 1:
|
||||||
|
maze[x][y].set_south(True)
|
||||||
|
if y == 0:
|
||||||
|
maze[x][y].set_est(True)
|
||||||
|
if y == width - 1:
|
||||||
|
maze[x][y].set_west(True)
|
||||||
return maze
|
return maze
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -35,3 +35,26 @@ class Maze:
|
|||||||
|
|
||||||
def solver(self) -> str:
|
def solver(self) -> str:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def ascii_print(self) -> None:
|
||||||
|
for line in self.maze:
|
||||||
|
if line is self.maze[0]:
|
||||||
|
for cell in line:
|
||||||
|
print("_", end="")
|
||||||
|
if cell.get_north():
|
||||||
|
print("__", end="")
|
||||||
|
else:
|
||||||
|
print(" ", end="")
|
||||||
|
print()
|
||||||
|
for cell in line:
|
||||||
|
if cell is line[0] and cell.get_west():
|
||||||
|
print("|", end="")
|
||||||
|
if cell.get_south() is True:
|
||||||
|
print("__", end="")
|
||||||
|
else:
|
||||||
|
print(" ", end="")
|
||||||
|
if cell.get_est() is True:
|
||||||
|
print("|", end="")
|
||||||
|
else:
|
||||||
|
print("_", end="")
|
||||||
|
print()
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
2AAA802AAAA8282AAAA8
|
7D53BFD3D57951517D1D
|
||||||
000282A8280282A80028
|
3D12C3903BD03AD4178D
|
||||||
002A8280280028280000
|
2BAEBEEEAA92EED547C9
|
||||||
2AA82A82AA82A82AA800
|
2287ED17AAAC5393FFF0
|
||||||
02A8002A8028002A8280
|
6C6951292A87D2AEBD30
|
||||||
282A8282AAA828002AA8
|
37D43E8686E93AABAB8C
|
||||||
0028282A8282A82A82A8
|
21516D2D47FEE8284049
|
||||||
2A8002AA80002A802A80
|
6C7857C3FB9116C696D8
|
||||||
002802802A8280028280
|
751453D6D2AAC57BE970
|
||||||
0282AA82A82AA80282A8
|
3BA952D17EA83BD05470
|
||||||
2802AAA8282AA8282AA8
|
22AAD2907BAE86967B74
|
||||||
000002A8028282AAA828
|
2AA83C2EFC69696FBC35
|
||||||
02AAA800002A82A80000
|
686EE96FD7D4783FAD21
|
||||||
2AAAA82A82AA800282A8
|
7ED17ED3D57D3EC52FA0
|
||||||
282AA82A8282A82AA828
|
7B943D16FB7BABD3AFC8
|
||||||
00002AAA82828282AAA8
|
7407C5297EB82EB84174
|
||||||
02A82A80282802A80028
|
392D53C6912EE9447E9D
|
||||||
282A8000280028002AA8
|
62A952BBAAC13EFD7B89
|
||||||
02AA82A82A82AAAAAAA8
|
3AAC3EC6EABAAD557824
|
||||||
2A80000002AAAAA80000
|
66C7C7D7D6C6C7D556CD
|
||||||
|
|
||||||
1,1
|
1,1
|
||||||
16,15
|
16,15
|
||||||
|
|||||||
Reference in New Issue
Block a user