generate_dungeon | R Documentation |
Procedurally generate a tile-based ASCII-character dungeon map. Creates a
tile-based map of user-specified size; places randomly a user-specified
number of rooms; connects them with a continuous corridor; and iteratively
expands the interior space by sampling from adjacent tiles. Note: much of
this function has been absorbed into the start_game
function,
but generate_dungeon
will continue to be exported for now.
generate_dungeon( iterations = 5, n_row = 30, n_col = 50, n_rooms = 5, is_snake = FALSE, is_organic = TRUE, seed = NULL, colour = TRUE )
iterations |
Numeric. How many times to 'grow' iteratively the dungeon
rooms, where tiles adjacent to current floor tiles ( |
n_row |
Numeric. Number of row tiles in the dungeon, i.e. its height. |
n_col |
Numeric. Number of column tiles in the dungeon, i.e. its width. |
n_rooms |
Numeric. Number of rooms to place randomly on the map as starting points for iterative growth. |
is_snake |
Logical. Should the room start points be connected randomly
( |
is_organic |
Logical. Join the room start points with corridors before
iterative growth steps ( |
seed |
Numeric. Seed to reproduce a dungeon. |
colour |
Logical. Should the characters be coloured using
|
You'll have to experiment to find the 'best' argument values for
your needs. Typically, a larger dungeon should have a higher
n_rooms
value and can be grown through more iterations
.
Use is_snake
and is_organic
to play with dungeon
appearance and connectedness.
For argument is_snake
, TRUE
will create a single
continuous, winding cavern from left to right, while FALSE
will create a more maze-like cavern.
For argument is_organic
, TRUE
will generally create
what looks like a natural cavern, since the room start points and
corridors are subject to iterative growth. When FALSE
and
is_snake
is FALSE
, the dungeon's caverns are more
square, or more 'artificial' looking. When FALSE
and
is_snake
is TRUE
, the result is more likely to be a
series of discrete roundish rooms connected by a narrow (one
tile-width) corridor.
A matrix, invisibly. Output via cat
to the
console.
## Not run: # A 'natural' cavern with default arguments generate_dungeon(seed = 23456) # Rooms connected sequentially by narrow corridors generate_dungeon( iterations = 8, # iterate room growth 8 times n_rooms = 4, # randomly place 4 room tiles to start is_snake = TRUE, # connect rooms from left- to right-most is_organic = FALSE, # add single tile-width corridors after growth seed = 2 ) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.