yog/render/ascii

ASCII art rendering for grids and mazes.

Renders grid structures as text using simple ASCII characters (+, -, |). Perfect for terminal output and following along with “Mazes for Programmers” book examples.

Quick Start

import yog/render/ascii
import yog/builder/grid

 let map = [
   [">", ">", "."],
   [".", "V", ">"],
   [".", ".", "."],
 ]
 let maze =
   grid.from_2d_list(
     map,
     model.Directed,
     grid.including([">", "<", "V", "^"]),
   )

io.println(ascii.grid_to_string(maze))

Output

+---+---+---+
|       |   |
+---+   +---+
|   |       |
+---+---+---+
|   |   |   |
+---+---+---+

Values

pub fn grid_to_string(grid: grid.Grid(n, e)) -> String

Converts a grid to ASCII art using simple characters (+, -, |).

Each cell is represented as a 3-character wide space. Walls are drawn where edges don’t exist between adjacent cells.

Example

let maze = // ... create grid
io.println(ascii.grid_to_string(maze))
Search Document