Generate, display and solve mazes in an animated way in the terminal.

Overview

How to Run

Usage: maze_solver.exe [OPTIONS] <--generator <GENERATOR>|--input <INPUT>> [ROWS] [COLUMNS]

Arguments:
  [ROWS]     Number of rows to draw [default: 16]
  [COLUMNS]  Number of columns to draw [default: 48]

Options:
  -g, --generator <GENERATOR>  Generator used [possible values: depth_first_search, breadth_first_search, kruskal]
  -i, --input <INPUT>          Input path used
  -s, --solver <SOLVER>        Solver used. If Some, then the generator will run with a delay of 0 [possible values: depth_first_search, a_star]
  -t, --trace                  Flag to enable drawing visited cells
  -d, --delay <DELAY>          Number of milliseconds between animation [default: 25]
  -h, --help                   Print help information
  -V, --version                Print version information

Here are some examples:

# Animate generating a 10 by 12 maze using the depth-first seach generator.
cargo run --release -- 10 12 -g depth_first_search

# Animate generating a 16 by 48 maze using the depth-first seach generator and a delay of 0ms (instant).
cargo run --release -- -g depth_first_search -d 0

# Animate solving a 16 by 48 kruskal maze using the depth-first search solver.
cargo run --release -- -g kruskal -s depth_first_search

# Animate solving a 16 by 48 kruskal maze with trace using the depth-first search solver.
cargo run --release -- -g kruskal -s depth_first_search -t

# Animate solving the medium sized example using the depth-first search solver.
cargo run --release -- -i examples/medium.maze -s depth_first_search

I tested that this works on at least Windows 10, Ubuntu and macOS.

Generators

The following generators are included:

Randomized depth-first search.

Randomized breadth-first search.

Kruskal's algorithm.

Solvers

The following solvers are included:

Depth-first search

A*

No gif yet.

Note on Design

It was important to me that large mazes could be drawn in a limited space, which meant that some thought had to be given on how the maze should be represented. A simple (yet effective) representation would look like this:

+ +-+   [N, H]     
| | |   [V, V, V]     
+ +-+   [N, H]
|   |   [V, N, V]
+-+ +   [H, N]

H: Horizontal,
V: Vertical,
N: None,

This is 5x5 character matrix to represent a 2x2 maze. We can do better by combining the vertical and horizontal walls into the same line:

_ ___   [H, N, H, H, H]
| |_|   [V, N, H, V, H]
|__ |   [V, H, N, N, V]

H: Horizontal,
V: Vertical,
N: None,

This gives us a 3x3 character matrix, which is a lot better! Furthermore, if replace the underscores with underlines, then we can actually draw characters inside the cells. This allows for very nice looking animations.

You might also like...
Terminal typing "game"

ToggleCoolCowSaysType A terminal based typing game. Usage: toggle_cool_cow_says_type [-t {word_count}] [-t {file_extension}] [-s] {project_path} -s :

rpg-cli is a bare-bones JRPG-inspired terminal game written in Rust
rpg-cli is a bare-bones JRPG-inspired terminal game written in Rust

rpg-cli is a bare-bones JRPG-inspired terminal game written in Rust. It can work as an alternative to cd where you randomly encounter enemies as you change directories.

A terminal battleship game in Rust
A terminal battleship game in Rust

Battleship.rs A terminal battleship game in Rust. Run with docker: $ docker run --rm -it deepu105/battleship:main This is slightly different than the

A terminal based game engine
A terminal based game engine

ccdb: The cmd game engine (Thats also multi threaded) How to use Tutorial Multi threading If you want to use multi threading you have to use ACore The

Play jungle chess on the linux terminal.
Play jungle chess on the linux terminal.

Jungle-Chess This is my first project written in Rust. Happy for contributors and feedback! The code is dirty. Play Jungle Chess on an Emoji-Enabled L

Play or watch Othello in your terminal!
Play or watch Othello in your terminal!

othello-cli othello-cli is a cli version of Othello (Reversi) written in Rust. You can play against another player, the AI, or watch two AIs play each

Transform your terminal into an art canvas where you can draw stuff!
Transform your terminal into an art canvas where you can draw stuff!

Termdraw Turn your terminal into the drawing cavnas of your dream... or not! Installation To install this dream-come-true of a tool simply run cargo i

Terminal-based Snake game written in Rust without dependencies (for educational purposes).
Terminal-based Snake game written in Rust without dependencies (for educational purposes).

RustSnake This is a simple terminal-based Snake game implemented in Rust without dependencies. To start the game type cargo run. Control the snake usi

A simple space shooter game. Runs in the terminal using characters-based UI. Fully written in Rust, using the
A simple space shooter game. Runs in the terminal using characters-based UI. Fully written in Rust, using the "ruscii" library.

Thrust - a terminal shooter game Originally created as a project for the "Missing Semester" course at JKU Linz (338.006). The game is entirely written

Owner
Julia
Embedded Systems student.
Julia
An application that tries to solve a Wordle puzzle only by using clues

wordlebot An application that tries to solve a Wordle puzzle only by using clues. You decide the word to discover (if you want to compete with wordleb

Rich Neswold 2 May 25, 2022
A tool to display the minimap of a game larger on a second screen

maximap A tool to display the minimap of a game larger on a second screen. Should work on all operating systems supported by captrs and rust_minifb, s

Richard Baumann 18 Oct 11, 2022
A canvas on which you can draw anything with ease before drawing the pixels on your small hardware display.

embedded-canvas    canvas - a piece of cloth backed or framed as a surface for a painting NOTE: This crate is still in development and may have breaki

Lechev.space 13 Aug 31, 2022
A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that wraps around the screen!

Bevy Wrapping Square example A simple example showcasing how to use Bevy to display a square with acceleration (controllable with your keyboard) that

Luciano Mammino 3 Oct 23, 2022
A tetris game I wrote in rust using ncurses. I'm sure that there's a better way to write a tetris game, and the code may be sus, but it techinically works

rustetris A tetris game I wrote in rust using ncurses. I'm sure that there's a better way to write a tetris game, and the code may be sus, but it tech

Eric G 3 Oct 15, 2022
An easy way to integrate @rhaiscript with @bevyengine.

Bevy Rhai What is Bevy Rhai? Bevy Rhai is an easy way to integrate and use Rhai with Bevy. It provides everything you need to get started, all you nee

Leon Davis 10 Jun 12, 2022
🎨 Procedurally generate 2D sprites

sprite (Executable) Run On Linux you need the gtk-rs dependencies to compile: cargo install sprite sprite This should produce the following window: s

Thomas Versteeg 68 Nov 25, 2022
Generate rust command line executables from gRPC protobuf services.

Rust template repository. An opinionated starting point for rust projects such as systemd services command line tools client programs server programs

Kris Nóva 8 Sep 18, 2022
Plugin to generate flowfields from tilemaps in the Godot Engine!

Godot Tilemap Flowfields RTS-Style optimized path-finding for crowds of agents. Built for the Godot game engine, written with performance in mind in R

Arne Winter 18 Jan 10, 2023
Terminal UI implementation and types for the Dark Forest game

dark-forest.rs Terminal UI implementation and types for the Dark Forest game Development We use the standard Rust toolchain cargo check

Georgios Konstantopoulos 63 Nov 12, 2022