mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
fix conflict
This commit is contained in:
+32
-47
@@ -117,19 +117,24 @@ class MazeMLX:
|
|||||||
for color in colors:
|
for color in colors:
|
||||||
yield color
|
yield color
|
||||||
|
|
||||||
def update_maze(self, maze: np.ndarray) -> None:
|
def get_margin_line_len(self, maze: np.ndarray) -> tuple[int, int, int]:
|
||||||
self.clear_image()
|
|
||||||
|
|
||||||
rows = len(maze)
|
rows = len(maze)
|
||||||
cols = len(maze[0])
|
cols = len(maze[0])
|
||||||
|
|
||||||
line_len = min(self.width // cols, self.height // rows)
|
line_len = min(self.width // cols, self.height // rows) - 1
|
||||||
|
|
||||||
maze_width = cols * line_len
|
maze_width = cols * line_len
|
||||||
maze_height = rows * line_len
|
maze_height = rows * line_len
|
||||||
|
|
||||||
margin_x = (self.width - maze_width) // 2
|
margin_x = ((self.width - maze_width) // 2) + 1
|
||||||
margin_y = (self.height - maze_height) // 2
|
margin_y = ((self.height - maze_height) // 2) + 1
|
||||||
|
|
||||||
|
return (line_len, margin_x, margin_y)
|
||||||
|
|
||||||
|
def update_maze(self, maze: np.ndarray) -> None:
|
||||||
|
self.clear_image()
|
||||||
|
|
||||||
|
line_len, margin_x, margin_y = self.get_margin_line_len(maze)
|
||||||
for y in range(len(maze)):
|
for y in range(len(maze)):
|
||||||
for x in range(len(maze[0])):
|
for x in range(len(maze[0])):
|
||||||
x0 = x * line_len + margin_x
|
x0 = x * line_len + margin_x
|
||||||
@@ -155,16 +160,7 @@ class MazeMLX:
|
|||||||
if maze is None:
|
if maze is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
rows = len(maze)
|
line_len, margin_x, margin_y = self.get_margin_line_len(maze)
|
||||||
cols = len(maze[0])
|
|
||||||
|
|
||||||
line_len = min(self.width // cols, self.height // rows)
|
|
||||||
|
|
||||||
maze_width = cols * line_len
|
|
||||||
maze_height = rows * line_len
|
|
||||||
|
|
||||||
margin_x = (self.width - maze_width) // 2
|
|
||||||
margin_y = (self.height - maze_height) // 2
|
|
||||||
|
|
||||||
for i in range(len(path)):
|
for i in range(len(path)):
|
||||||
ul = (
|
ul = (
|
||||||
@@ -212,16 +208,7 @@ class MazeMLX:
|
|||||||
if maze is None:
|
if maze is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
rows = len(maze)
|
line_len, margin_x, margin_y = self.get_margin_line_len(maze)
|
||||||
cols = len(maze[0])
|
|
||||||
|
|
||||||
line_len = min(self.width // cols, self.height // rows)
|
|
||||||
|
|
||||||
maze_width = cols * line_len
|
|
||||||
maze_height = rows * line_len
|
|
||||||
|
|
||||||
margin_x = (self.width - maze_width) // 2
|
|
||||||
margin_y = (self.height - maze_height) // 2
|
|
||||||
|
|
||||||
ul = (
|
ul = (
|
||||||
(entry[0] - 1) * line_len + margin_x + 3,
|
(entry[0] - 1) * line_len + margin_x + 3,
|
||||||
@@ -231,30 +218,28 @@ class MazeMLX:
|
|||||||
(entry[0] - 1) * line_len + line_len + margin_x - 3,
|
(entry[0] - 1) * line_len + line_len + margin_x - 3,
|
||||||
(entry[1] - 1) * line_len + line_len - 3 + margin_y,
|
(entry[1] - 1) * line_len + line_len - 3 + margin_y,
|
||||||
)
|
)
|
||||||
# print(f"ul: {ul}; dr: {dr}")
|
self.put_block(ul, dr, [0xFF, 0xBF, 0x00, 0x9F])
|
||||||
self.put_block(ul, dr)
|
|
||||||
self.redraw_image()
|
ul = (
|
||||||
|
(exit[0] - 1) * line_len + margin_x + 3,
|
||||||
|
(exit[1] - 1) * line_len + 3 + margin_y,
|
||||||
|
)
|
||||||
|
dr = (
|
||||||
|
(exit[0] - 1) * line_len + line_len + margin_x - 3,
|
||||||
|
(exit[1] - 1) * line_len + line_len - 3 + margin_y,
|
||||||
|
)
|
||||||
|
self.put_block(ul, dr, [0x00, 0xFF, 0x40, 0x9F])
|
||||||
|
|
||||||
def draw_ft(self, maze: np.ndarray, color: list | None = None):
|
def draw_ft(self, maze: np.ndarray, color: list | None = None):
|
||||||
margin = math.trunc(
|
line_len, margin_x, margin_y = self.get_margin_line_len(maze)
|
||||||
math.sqrt(self.width if self.width > self.height else self.height)
|
|
||||||
// 2
|
|
||||||
)
|
|
||||||
line_len = math.trunc(
|
|
||||||
(
|
|
||||||
(self.height - margin) // len(maze)
|
|
||||||
if self.height > self.width
|
|
||||||
else (self.width - margin) // len(maze[0])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
for y in range(len(maze)):
|
for y in range(len(maze)):
|
||||||
for x in range(len(maze[0])):
|
for x in range(len(maze[0])):
|
||||||
x0 = x * line_len + margin
|
|
||||||
y0 = y * line_len + margin
|
|
||||||
x1 = x * line_len + line_len + margin
|
|
||||||
y1 = y * line_len + line_len + margin
|
|
||||||
|
|
||||||
if maze[y][x].value == 15:
|
if maze[y][x].value == 15:
|
||||||
|
x0 = x * line_len + margin_x
|
||||||
|
y0 = y * line_len + margin_y
|
||||||
|
x1 = x * line_len + line_len + margin_x
|
||||||
|
y1 = y * line_len + line_len + margin_y
|
||||||
self.put_block((x0, y0), (x1, y1))
|
self.put_block((x0, y0), (x1, y1))
|
||||||
|
|
||||||
def draw_image(self, amazing: AMazeIng) -> None:
|
def draw_image(self, amazing: AMazeIng) -> None:
|
||||||
@@ -292,9 +277,9 @@ class MazeMLX:
|
|||||||
try:
|
try:
|
||||||
next(self.generator)
|
next(self.generator)
|
||||||
self.update_maze(amazing.maze.get_maze())
|
self.update_maze(amazing.maze.get_maze())
|
||||||
|
self.put_start_end(amazing)
|
||||||
return False
|
return False
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
self.put_start_end(amazing)
|
|
||||||
pass
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -341,7 +326,7 @@ class MazeMLX:
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
mlx = None
|
mlx = None
|
||||||
try:
|
try:
|
||||||
mlx = MazeMLX(1000, 1000)
|
mlx = MazeMLX(1800, 1800)
|
||||||
config = Parsing.DataMaze.get_data_maze("config.txt")
|
config = Parsing.DataMaze.get_data_maze("config.txt")
|
||||||
amazing = AMazeIng(**config)
|
amazing = AMazeIng(**config)
|
||||||
mlx.start(amazing)
|
mlx.start(amazing)
|
||||||
|
|||||||
+4
-4
@@ -1,8 +1,8 @@
|
|||||||
WIDTH=11
|
WIDTH=30
|
||||||
HEIGHT=11
|
HEIGHT=30
|
||||||
ENTRY=1,1
|
ENTRY=1,1
|
||||||
EXIT=11,11
|
EXIT=5,5
|
||||||
OUTPUT_FILE=maze.txt
|
OUTPUT_FILE=maze.txt
|
||||||
PERFECT=False
|
PERFECT=False
|
||||||
GENERATOR=DFS
|
GENERATOR=Kruskal
|
||||||
SOLVER=AStar
|
SOLVER=AStar
|
||||||
|
|||||||
Reference in New Issue
Block a user