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 Maze
|
||||
|
||||
|
||||
def main() -> None:
|
||||
try:
|
||||
maze = Maze(maze=None, start=(1, 1), end=(16, 15))
|
||||
for alg in MazeGenerator.Kruskal.kruskal(20, 20):
|
||||
maze.set_maze(alg)
|
||||
maze.export_maze("test.txt")
|
||||
except Exception as err:
|
||||
print(err)
|
||||
# try:
|
||||
maze = Maze(maze=None, start=(1, 1), end=(16, 15))
|
||||
for alg in MazeGenerator.Kruskal.kruskal(20, 20):
|
||||
maze.set_maze(alg)
|
||||
os.system("clear")
|
||||
maze.ascii_print()
|
||||
maze.export_maze("test.txt")
|
||||
|
||||
|
||||
# except Exception as err:
|
||||
# print(err)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -19,13 +19,23 @@ class MazeGenerator:
|
||||
case 1:
|
||||
maze[math.trunc((x / width))][x % width].set_est(True)
|
||||
maze[math.trunc((y / width))][y % width].set_west(True)
|
||||
case 5:
|
||||
case width:
|
||||
maze[math.trunc((x / width))][x % width].set_south(
|
||||
True
|
||||
)
|
||||
maze[math.trunc((y / width))][y % width].set_north(
|
||||
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
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -35,3 +35,26 @@ class Maze:
|
||||
|
||||
def solver(self) -> str:
|
||||
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
|
||||
000282A8280282A80028
|
||||
002A8280280028280000
|
||||
2AA82A82AA82A82AA800
|
||||
02A8002A8028002A8280
|
||||
282A8282AAA828002AA8
|
||||
0028282A8282A82A82A8
|
||||
2A8002AA80002A802A80
|
||||
002802802A8280028280
|
||||
0282AA82A82AA80282A8
|
||||
2802AAA8282AA8282AA8
|
||||
000002A8028282AAA828
|
||||
02AAA800002A82A80000
|
||||
2AAAA82A82AA800282A8
|
||||
282AA82A8282A82AA828
|
||||
00002AAA82828282AAA8
|
||||
02A82A80282802A80028
|
||||
282A8000280028002AA8
|
||||
02AA82A82A82AAAAAAA8
|
||||
2A80000002AAAAA80000
|
||||
7D53BFD3D57951517D1D
|
||||
3D12C3903BD03AD4178D
|
||||
2BAEBEEEAA92EED547C9
|
||||
2287ED17AAAC5393FFF0
|
||||
6C6951292A87D2AEBD30
|
||||
37D43E8686E93AABAB8C
|
||||
21516D2D47FEE8284049
|
||||
6C7857C3FB9116C696D8
|
||||
751453D6D2AAC57BE970
|
||||
3BA952D17EA83BD05470
|
||||
22AAD2907BAE86967B74
|
||||
2AA83C2EFC69696FBC35
|
||||
686EE96FD7D4783FAD21
|
||||
7ED17ED3D57D3EC52FA0
|
||||
7B943D16FB7BABD3AFC8
|
||||
7407C5297EB82EB84174
|
||||
392D53C6912EE9447E9D
|
||||
62A952BBAAC13EFD7B89
|
||||
3AAC3EC6EABAAD557824
|
||||
66C7C7D7D6C6C7D556CD
|
||||
|
||||
1,1
|
||||
16,15
|
||||
|
||||
Reference in New Issue
Block a user