Generates dungeons with connected rooms.
Rooms are connected by paths, using a modified Prim's algorithm which expands the MST to the room closest to a room in the MST.
Paths are drawn by splitting them into two straight parts, which are easier to draw.
Written in Python 3.
Run in a terminal using python dungeon.py [-h] --height HEIGHT --width WIDTH [--density DENSITY] [--seed SEED | --random]
.
Density is represents the total area of placed rooms, as a fraction of the area of the dungeon array.
Density defaults to 0.25, and seed defaults to 0.
Rooms can overlap.
Can also be included in other projects. Then, getDungeon(xlength, ylength, density, random_seed)
returns a dungeon[x][y]
.
Example input:
* == Stone
[] == Wall
Whitespace == Room/path
Only dimensions supplied:
me@my-computer:~/Folder$ python dungeon.py --height 25 --width 25
**************************************************
****************[][][][][]********[][][][][]******
****************[] [][][][]**[] []******
****************[] [][][] []******
****************[] [][] []******
****************[][] []******
******************[] [][][] [][]******
**************[][][] [][]**[] []********
**************[] [][]**[][] [][][]****
********[][][][] [][]****[] []****
****[][][] [][][] [][][]******[] []****
****[] [][][] []**********[][][] [][]****
****[] [][][]**********[] [][][][]
****[] [][][] []**********[] [] []
****[][] [] [][][] []**********[] []
****[] [][][][][][][][][][] []
****[] [][][] [][] [][][][] []
****[][][][][][]**[][] [][][] []
************[][][][] [][][] [][][][][][]
************[] []**[][] [][][][][][][]
************[] [][]**[] []**[] []
************[] [][][]****[] [][][] []
************[][][][][]********[] []
******************************[] [][][][][][][]
******************************[][][][]************
Dimensions and density supplied:
me@my-computer:~/Folder$ python dungeon.py --height 25 --width 25 --density 0.25
**************************************************
****************[][][][][]************************
****************[] [][][][]******************
****************[] [][]****************
****************[] []****************
****************[][] []****************
******************[] []****************
******************[] [][]****************
******************[] [][]**[][][][][][]****
********[][][][]**[][][] [][]****[] []****
********[] []******[] []******[] []****
********[] [][][][][] []******[][][] [][]****
********[] []**********[] []******
********[] [][][] []**********[] []******
********[][] [][][] []**********[] []******
**********[] [][][][][][][] []******
**********[][][][][] [][] [] []******
******************[][] []******
************[][][][][] [][][][][] [][][][]******
************[] [] []******[] []**[][][][][]
************[] []******[] [][][] []
************[] [][][]******[] []
************[][][][][]**********[][][][][] []
****************************************[][][][][]
**************************************************
Dimensions, density, and seed supplied:
me@my-computer:~/Folder$ python dungeon.py --height 25 --width 25 --density 0.25 --seed 123456
********************************[][][][]**********
****************[][][][]****[][][] []**********
********[][][][][] []****[] []**********
********[] [][] []**[][] []**********
********[] [][][] []**********
[][][][][] []**********
[] [][] [][][][][][][] []**********
[] [][][][][]**********[] [][][][][]**
[] [][][][][]******************[] [][] []**
[][][][]********************[][][][] []**
**********************[][][][] [][][] []**
**********************[] []**
**[][][][][][][][][][][] [][][][][]**
**[] [][] [][] [][]**********
**[] [][][][][]********
**[] [][][] [][][][] [][] []********
**[][][][][][][][] [][][][] [][] []********
**[][][] [][] []********
**[] [][] []********
**[] [][][][][][][][][][]********
**[][][] [][] [][][][][]******************
******[][][][][][][] [] []******************
******************[] []******************
******************[][][][][][][]******************
**************************************************