• Stars
    star
    19
  • Rank 1,163,249 (Top 23 %)
  • Language
    Crystal
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A* Path finding for PNG mazes, from Ruby now in Crystal. Using StumpyPNG

Crystal-Maze

A* Path finding for PNG mazes, from Ruby now in Crystal! Using StumpyPNG! Now Γ—40 faster than its Ruby counterpart: A-Star

Example-400x400maze

Installation

Build it from source: Clone and enter repository:

git clone https://github.com/Demonstrandum/Crystal-Maze.git && cd Crystal-Maze

then install dependencies with shards (StumpyPNG):

shards install

and run the make file:

make
sudo make install clean
#sudo make uninstall # to remove the program

Usage

To run the program itself:

maze ~/Pictures/yourImage.png

This will solve the maze and make and image with the suffix "-solved"
e.g. yourImage-solved.png in the same location as the input image.

You can also add optional arguments of heuristic distance type, verbosity and wheather to draw nodes or not. For heuristic distance just type euclidean or manhattan as argument for distance calculation type, these are the only two currently supported. Showing nodes is done with the argument --show-nodes and for verbosity (prints the nodes of the final path) either -v, verbose or --verbose.

For example:

maze euclidean -v hipMaze.png --show-nodes

GIFs

Maze being solved

Maze being mapped out by flood and then solved with A*

You can animate the solving with the --gif argument, this looks better with --show-nodes as you can see the nodes being placed and spreading. e.g.

maze mazes/50-maze.png --show-nodes --gif

The gif will most likely be very slow, so you can drop some frames to speed it up:

maze mazes/normal.png --show-nodes --gif --gif-speed 14

The above means: only keep every 14th frame.

which generates mazes/50-maze-solved.gif Be careful, when making GIFs with large mazes, the program will use a lot of memory and may freeze your computer!

Maze PNG requirements

The start and end points of the maze must be white and be from top or left to bottom or right, if this is not true, then it means the maze has a black border, in which case it will find a green pixel (doesn't have to be perfect green) and sets that as the start point and then finds a red pixel (doesn't have to be perfect red) and sets that as the end point.


P.S. It's highly recommended that the maze's walls and paths are 1 pixel wide as the program draws and reads the paths as one pixel.

More Repositories

1

BasicCanvas

A friendlier way to interact with the canvas; simple library for canvas manipulation.
JavaScript
10
star
2

Fractal

Draws PNG images of complex plane fractals, in Ruby.
Ruby
9
star
3

RubyFiglet

FIGlet in Ruby, font interpretation and printing.
Ruby
6
star
4

crepl

An intuitive calculator Read-Eval-Print-Loop.
C
5
star
5

seam

Symbolic Expressions As Markup
Rust
5
star
6

WordTime

A macOS menu bar item which tells the time in words.
Python
5
star
7

lispy

LISP Interpreter in Python 😣 β€” LIS(PY)
Python
4
star
8

Veto

Simple Straw Voting/Polling Website with Sinatra.
JavaScript
3
star
9

FAM

A very Fake Assembly(ish-language) Machine thingy...
Ruby
3
star
10

A-Star

A* path finding algorithm for images, in Ruby.
Ruby
3
star
11

COVID

COVID-19 Cases/deaths/recovered graph generator for a series of countries, in Julia.
Julia
2
star
12

boomer

Boomerfy Your Text
HTML
2
star
13

FAMalam

FAMalam is a front end web interface for the Fake Assembly Machine (FAM)
JavaScript
2
star
14

homepage

Simple homepage with favourites and URL/Search bar
JavaScript
1
star
15

Zoids

Boids in Zig (GLFW+NanoVG / WASM+WebGL).
Zig
1
star
16

progress_download

Simple customisable progress bar for downloading remote files in Ruby.
Ruby
1
star
17

Playground

C++ Starting point for windowed applications using GLFW with BGFX including ImGui to get started. Builds cross-platform with Bazel.
C++
1
star
18

Schyntax

Program by editing the syntax tree.
JavaScript
1
star
19

Caesar

Simple Caesar/rot cipher written in C++
C++
1
star
20

crelude

Personal C standard library / prelude.
C
1
star
21

robaat_robot

RobΓ₯t Robot
Ruby
1
star
22

Dotfiles

`dotfiles`
Shell
1
star