7 Commits

Author SHA1 Message Date
da7e 843fe5f80c uv config for build wheel package
add clean and fclean method to Makefile
2026-04-01 14:31:11 +02:00
maoake 40e25757c7 starting mypy with maze 2026-03-31 22:31:48 +02:00
maoake b1eda06fa5 fixing flake8 2026-03-31 22:01:45 +02:00
maoake 769198c06b adding the blink on the 42 2026-03-31 21:03:10 +02:00
maoake 2c7b565137 give a checkpoint to the project blink the 42 2026-03-31 20:29:01 +02:00
maoake d23959ce74 fix conflict 2026-03-31 20:17:08 +02:00
maoake 4cb678b5be something is up 2026-03-31 19:59:09 +02:00
11 changed files with 71 additions and 29 deletions
+1
View File
@@ -216,3 +216,4 @@ __marimo__/
.streamlit/secrets.toml
test.txt
mazegen-1.0.0-py3-none-any.whl
+10 -1
View File
@@ -1,3 +1,7 @@
build:
uv build --clear --wheel
cp dist/*.whl mazegen-1.0.0-py3-none-any.whl
install:
uv sync
uv pip install mlx-2.2-py3-none-any.whl
@@ -12,7 +16,10 @@ debug:
uv pdb python3 a_maze_ing.py config.txt
clean:
rm -rf __pycache__ .mypy_cache .venv
rm -rf */**__pycache__ __pycache__ .mypy_cache .venv dist build */**/*.egg-info *.egg-info
fclean: clean
rm mazegen-1.0.0-py3-none-any.whl
lint:
uv run flake8 . --exclude=.venv
@@ -34,3 +41,5 @@ run_test:
uv run pytest
mlx:
uv run python3 test.py
.PHONY: build install run debug clean fclean lint lint-strict run_test
View File
+40 -12
View File
@@ -1,9 +1,8 @@
from typing import Any
from src.AMazeIng import AMazeIng
from src.parsing import Parsing
from src.parsing.Parsing import DataMaze as Parsing
from mlx import Mlx
import numpy as np
import math
import time
@@ -96,8 +95,9 @@ class MazeMLX:
def random_color_ft() -> Any:
colors = [
[0xFF, 0xBF, 0x00, 0xFF], # blue
[0xFF, 0x00, 0x80, 0xFF], # purple
[0xFF, 0x00, 0xFF, 0xFF], # rose
[0x00, 0xFF, 0x40, 0xFF], # green
[0xFF, 0x00, 0xFF, 0xFF], # pink
[0x00, 0xFF, 0xFF, 0xFF], # yellow
]
while True:
for color in colors:
@@ -106,12 +106,12 @@ class MazeMLX:
@staticmethod
def random_color() -> Any:
colors = [
[0x00, 0x00, 0xFF, 0xFF], # red
[0xFF, 0x00, 0xFF, 0xFF], # pink
[0x00, 0xFF, 0xFF, 0xFF], # yellow
[0x00, 0xFF, 0x40, 0xFF], # green
[0xFF, 0xBF, 0x00, 0xFF], # blue
[0xFF, 0x00, 0x80, 0xFF], # purple
[0xFF, 0x00, 0xFF, 0xFF], # pink
[0x00, 0x00, 0xFF, 0xFF], # red
]
while True:
for color in colors:
@@ -240,16 +240,20 @@ class MazeMLX:
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), color)
def draw_image(self, amazing: AMazeIng) -> None:
if self.render_maze(amazing):
if self.path_printer and self.print_path:
if self.render_path():
color = next(self.color_gen_ft)
color
self.draw_ft(amazing.maze.get_maze(), color)
next(self.timer_gen)
else:
self.time_gen()
self.update_maze(amazing.maze.get_maze())
self.draw_ft(amazing.maze.get_maze())
self.put_start_end(amazing)
self.redraw_image()
def shift_color(self):
@@ -258,9 +262,18 @@ class MazeMLX:
def shift_color_ft(self):
self.color_gen_ft = self.random_color_ft()
def time_gen(self):
self.timer_gen = self.time_generator()
def restart_maze(self, amazing: AMazeIng) -> None:
self.generator = amazing.generate()
def time_generator(self) -> Any:
yield
while True:
time.sleep(0.3)
yield
def restart_path(self, amazing: AMazeIng) -> None:
self.path_printer = self.put_path(amazing)
@@ -277,7 +290,6 @@ class MazeMLX:
try:
next(self.generator)
self.update_maze(amazing.maze.get_maze())
self.put_start_end(amazing)
return False
except StopIteration:
pass
@@ -296,14 +308,30 @@ class MazeMLX:
if keycode == 52:
self.close_loop(None)
def handle_key_press_mteriier(
self, keycode: int, amazing: AMazeIng
) -> None:
if keycode == 38:
self.restart_maze(amazing)
self.print_path = False
if keycode == 233:
self.restart_path(amazing)
self.print_path = True if self.print_path is False else False
if keycode == 34:
self.print_path = False
self.color = next(self.color_gen)
if keycode == 39:
self.close_loop(None)
def start(self, amazing: AMazeIng) -> None:
self.restart_maze(amazing)
self.shift_color()
self.shift_color_ft()
self.time_gen()
self.mlx.mlx_loop_hook(self.mlx_ptr, self.draw_image, amazing)
self.mlx.mlx_hook(self.win_ptr, 33, 0, self.close_loop, None)
self.mlx.mlx_hook(
self.win_ptr, 2, 1 << 0, self.handle_key_press, amazing
self.win_ptr, 2, 1 << 0, self.handle_key_press_mteriier, amazing
)
self.mlx.mlx_loop(self.mlx_ptr)
@@ -311,8 +339,8 @@ class MazeMLX:
def main() -> None:
mlx = None
try:
mlx = MazeMLX(1800, 1800)
config = Parsing.DataMaze.get_data_maze("config.txt")
mlx = MazeMLX(1000, 1000)
config = Parsing.get_data_maze("config.txt")
amazing = AMazeIng(**config)
mlx.start(amazing)
with open("test.txt", "w") as output:
+2 -2
View File
@@ -1,5 +1,5 @@
WIDTH=30
HEIGHT=30
WIDTH=13
HEIGHT=13
ENTRY=1,1
EXIT=5,5
OUTPUT_FILE=maze.txt
+8
View File
@@ -23,3 +23,11 @@ python_version = "3.10"
[tool.pytest.ini_options]
pythonpath = ["src"]
[build-system]
requires = ["setuptools>=78.1.0", "wheel>=0.45.1"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
package-dir = {"" = "src/amaz_lib"}
+8 -5
View File
@@ -1,16 +1,16 @@
from dataclasses import dataclass
import numpy
from numpy.typing import NDArray
from typing import Optional, Any
@dataclass
class Maze:
maze: numpy.ndarray
maze: Optional[NDArray[Any]] = None
def get_maze(self) -> numpy.ndarray | None:
def get_maze(self) -> Optional[NDArray[Any]]:
return self.maze
def set_maze(self, new_maze: numpy.ndarray) -> None:
def set_maze(self, new_maze: NDArray[Any]) -> None:
self.maze = new_maze
def __str__(self) -> str:
@@ -24,6 +24,9 @@ class Maze:
return res
def ascii_print(self) -> None:
if self.maze is None:
print("None")
return
for cell in self.maze[0]:
print("_", end="")
if cell.get_north():
-6
View File
@@ -1,6 +0,0 @@
__version__ = "1.0.0"
__author__ = "mteriier, dgaillet"
from .Parsing import DataMaze
__all__ = ["DataMaze"]
-1
View File
@@ -1,4 +1,3 @@
import pytest
from amaz_lib.Cell import Cell
+1 -1
View File
@@ -1,6 +1,6 @@
from amaz_lib.Cell import Cell
import numpy as np
from amaz_lib import AStar, Maze, MazeSolver
from amaz_lib import AStar, Maze
def test_solver() -> None:
Generated
+1 -1
View File
@@ -9,7 +9,7 @@ resolution-markers = [
[[package]]
name = "a-maze-ing"
version = "0.1.0"
source = { virtual = "." }
source = { editable = "." }
dependencies = [
{ name = "numpy", version = "2.2.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.11'" },
{ name = "numpy", version = "2.4.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.11'" },