Several kinds of random World maps generator for games
This library provides a world maps generator with following interfaces:
- Rust library as an API
- CLI tool to generate maps in terminal as visual output or as JSON output
- WebAssembly npm package for Web
Please read README.md of repository hosted on GitHub.
https://github.com/rhysd/world-map-gen
This document explains 1., as an API library for Rust.
This library provides some modules to handle a world map as one board filled up with cells.
land:land::Landstruct represents each cell in a boardboard:board::Boardstruct represents one world map. The struct is JSON serializable withserde_jsondraw: Helper to draw a board to terminal or as JSONgen: A random world map generator to buildboard::Boardstruct. It provides algorithms for 3 kinds of resolutionserror: Error type which may be returned from a map generator
use RandomBoardGen;
// Create generator instance with default random number generator
let mut generator = default;
// Generate 40x40 random world map. Map resolution (low, middle, high) is automatically
// determined by its width and height here.
// - Low: width and height are less than 15
// - Middle: width and height are less than 120
// - High: Otherwise
let board = generator.gen_auto;
// Iterate each cells per row
for in board.rows.enumerate