astar-mumu

Crates.ioastar-mumu
lib.rsastar-mumu
version0.1.0
created_at2025-08-15 16:09:05.413714+00
updated_at2025-08-15 16:09:05.413714+00
descriptionA* algorithm plugin for the Lava language
homepagehttps://lava.nu11.uk
repositoryhttps://gitlab.com/tofo/mumu-astar
max_upload_size
id1797039
size83,874
(justifiedmumu)

documentation

README

astar-mumu

A* algorithm plugin for the Lava (MuMu) language. Provides fast grid pathfinding and random maze generation for Rust-based Lava/MuMu interpreters.

Features

  • astar:astar: Standard grid-based A* (BFS) pathfinding, supports obstacles.
  • astar:maze: Generate random solvable mazes, returns obstacle arrays.
  • astar:maze_png: Generate mazes and export them as PNG images.
  • astar:path_png: Pathfind on a grid and render solution path as PNG.

Installation

cargo build --release
sudo cp target/release/libmumuastar.so /usr/local/lib/
sudo ldconfig

Usage

  1. Load the plugin in your MuMu/Lava interpreter:
extend("astar")
  1. Call provided functions:

Example: Basic pathfinding

maze = astar:maze(1234, 16, 12)
result = astar:astar(maze)
// result.path contains the path, result.success is true if a path was found

Example: Maze and PNG output

maze = astar:maze(5678, 32, 20)
astar:maze_png(5678, 32, 20, 0, 0, 31, 19, "maze.png")

Example: Save a path as PNG

maze = astar:maze(1337, 16, 16)
graph = astar:astar(maze)
astar:path_png(graph, "solved.png")

Function Reference

  • astar:astar(graph): Finds a path from start to end on a grid. graph must be a keyed array with fields:

    • dimension: [width, height]
    • start: [sx, sy]
    • end: [ex, ey]
    • obj: [[ox, oy], ...] (obstacles)
  • astar:maze(seed, width=20, height=20, sx=0, sy=0, ex=width-1, ey=height-1): Generates a solvable maze and returns a keyed array with dimension, start, end, obj.

  • astar:maze_png(seed, width, height, sx, sy, ex, ey, filename): Same as above, also saves the maze as a PNG.

  • astar:path_png(graph, filename): Saves a solution path as a PNG. Returns the input graph.

License

Dual MIT/Apache-2.0, see LICENSE.


Copyright (c) 2025 Tom Fotheringham and contributors

Commit count: 0

cargo fmt