7 unstable releases (3 breaking)
new 0.4.2 | Apr 3, 2025 |
---|---|
0.4.1 | Apr 3, 2025 |
0.3.1 | Apr 3, 2025 |
0.2.0 | Apr 2, 2025 |
0.1.0 | Apr 2, 2025 |
#84 in Games
785 downloads per month
26KB
428 lines
🧠 puzzle_engine
A modular Rust engine for building and solving puzzles.
✨ Overview
puzzle_engine
is a general-purpose puzzle library written in Rust. It's designed with extensibility and clarity in mind — ideal for games, educational tools, or AI challenges.
This crate currently includes support for the following:
Mazes
- Grid Mazes, a 2 dimensional maze generated using randomized DFS.
- Network Mazes, a type of maze that consists of a randomly generated network of nodes.
Ciphers
- Caesar, A simple cipher where each letter is shifted by a fixed number of positions in the alphabet.
- Vigenere, A simple cipher where each character is encrypted using a corresponding shift from the keyword.
🚀 Features
✅ Procedural maze generation using randomized DFS
✅ Minimal API to move through and solve mazes
✅ Fully connected mazes — no isolated areas
✅ Built-in test coverage and examples
✅ Easy to extend with other puzzles in the future
✅ Simple ciphers
🧩 Example: Grid Maze
use puzzle_engine::grid_maze::{Maze, Direction};
fn main() {
let mut maze = Maze::new(5, 5);
println!("Starting at: {:?}", maze.player);
if maze.try_move(Direction::East) {
println!("Moved to: {:?}", maze.player);
}
if maze.is_at_end() {
println!("Maze solved!");
}
}
🧩 Example: Network Maze
use puzzle_engine::network_maze::Maze;
fn main() {
let mut maze = Maze::new(10).unwrap();
let path = maze.find_path();
let path = path.unwrap();
for next_node in path.iter().skip(1){
maze.traverse(next_node.clone()).unwrap();
}
if maze.is_at_end() {
println!("Maze solved!");
}
}
🧩 Example: Vigenere Cipher
use puzzle_engine::cipher::vigenere_cipher::Vigenere;
use puzzle_engine::cipher::prelude::*;
fn main() {
let v = Vigenere::new("KEY");
let plain = "Attack at dawn!";
let encrypted = v.encrypt(plain);
let decrypted = v.decrypt(&encrypted);
println!("plain: {}, encrypted: {}", plain, encrypted);
}
🔮 Roadmap
Planned puzzle modules:
- Grid Maze (DFS-based)
- Network Maze
- More Ciphers
- Nonograms
- Word search / Crossword generator
- Sokoban-style logic puzzles
- Puzzle trait abstraction for polymorphic puzzle engines
🤝 Contributing
Contributions are welcome! Feel free to open issues or PRs for new puzzle types, algorithm improvements, tests, or docs.
📄 License
Licensed under either of:
- Apache License, Version 2.0
- MIT License
See LICENSE for details.
🔗 Links
Built with 🧩 and 💛 by Andrew Sims
Dependencies
~1MB
~17K SLoC