malwoden
Version:
   
69 lines (68 loc) • 2.58 kB
TypeScript
import { Vector2 } from "../struct";
import { IRNG } from "../rand";
import { Builder } from "./builder";
export interface DrunkardsWalkConfig<T> {
width: number;
height: number;
floorTile: T;
wallTile: T;
rng?: IRNG;
topology?: "four" | "eight";
}
/** Generator to perform a Drunkard's Walk*/
export declare class DrunkardsWalkBuilder<T> extends Builder<T> {
private _paths;
private _rng;
private _coveredCount;
private _topology;
private _floorTile;
private _wallTile;
/**
* Creates a new DrunkardsWalk Generator
* @param config - Generator Config
* @param config.width number - Width of the map
* @param config.height number - Height of the map
* @param config.rng IRNG - Optional random number generator
* @param config.topology "four" | "eight" - Topology to use. Default four.
* @param config.floorTile - The value to use for a path
* @param config.wallTile - The value to use for a wall
*/
constructor(config: DrunkardsWalkConfig<T>);
/**
* Adds a point to the drunkards walk,
* adjusting path, table, and steps as needed.
* @param point Vector2 - The point to add
*/
private addPoint;
/**
* Returns a list of paths previously walked.
* @returns Vector2[][]
*/
getPaths(): Vector2[][];
/**
* Returns # of walked tiles / # of total tiles.
* @returns number - Between 0.0 and 1.0
*/
getCoverage(): number;
private nextStepWillOverflow;
/**
* Generate a path by walking a number of steps.
* Can be called multiple times to have the Drunkard 'jump' to a different spot.
* @param config - The walk configuration
* @param config.pathCount- The number of independent paths to make from the start position. Default 1.
* @param config.start Vector2 - The starting position. Default random.
* @param config.stepsMin number - The minimum number of steps to take for each walk (inclusive)
* @param config.stepsMax number - The maximum number of steps to take for each walk (exclusive)
* @param config.maxCoverage number - Stops walking if this much of the map is explored. Range [0.0, 1.0], default 1.0
* @returns Vector2[][] - The paths walked
*/
walk(config: {
pathCount?: number;
stepsMin: number;
stepsMax: number;
start?: Vector2;
maxCoverage?: number;
}): Vector2[][];
private getRandPoint;
private getRandomNeighbor;
}