Expand description
Hexlab is a library for generating and manipulating hexagonal mazes.
§Features
- Create hexagonal mazes of configurable size
- Customizable maze properties (radius, start position, seed)
- Efficient bit-flag representation of walls
- Multiple maze generation algorithms
- Maze builder pattern for easy maze creation
§Examples
Here’s a quick example to create a simple hexagonal maze:
use hexlab::prelude::*;
let maze = MazeBuilder::new()
.with_radius(3)
.build()
.expect("Failed to create maze");
assert_eq!(maze.len(), 37); // A radius of 3 should create 37 tiles
Customizing maze generation:
use hexlab::prelude::*;
let maze = MazeBuilder::new()
.with_radius(2)
.with_seed(12345)
.with_start_position(Hex::new(1, -1))
.build()
.expect("Failed to create maze");
assert!(maze.get(&Hex::new(1, -1)).is_some());
Manipulating walls:
use hexlab::prelude::*;
let mut walls = Walls::empty();
assert!(!walls.insert(EdgeDirection::FLAT_NORTH));
assert!(walls.contains(EdgeDirection::FLAT_NORTH));
assert!(!walls.contains(EdgeDirection::FLAT_SOUTH));
Re-exports§
Modules§
Structs§
- Maze
- Represents a hexagonal maze with tiles and walls.
- Maze
Builder - A builder pattern for creating hexagonal mazes.
- Tile
- Represents a single hexagonal tile in the maze
- Walls
- A bit-flag representation of walls in a hexagonal tile.