File size: 2,476 Bytes
87b3b3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<h2>Dungeon generators</h2>

<p>This family of map generators produces corridors and rooms. Room information can be retrieved after the map has been created by calling <code>getRooms()</code>; corridor information can be retrieved via <code>getCorridors()</code>:</p>

<div class="example">
ROT.RNG.setSeed(1234);
var map = new ROT.Map.Digger();
var display = new ROT.Display({fontSize:8});
SHOW(display.getContainer());
map.create(display.DEBUG);

var rooms = map.getRooms();
for (var i=0; i&lt;rooms.length; i++) {
	var room = rooms[i];
	SHOW("Room #%s: [%s, %s] => [%s, %s]".format(
		(i+1),
		room.getLeft(), room.getTop(),
		room.getRight(), room.getBottom()
	));
}
</div>

<h3>Digger</h3>

<p>Random dungeon generator using human-like digging patterns; based on Mike Anderson's ideas from the "Tyrant" algo, mentioned at 
<a href="http://www.roguebasin.roguelikedevelopment.org/index.php?title=Dungeon-Building_Algorithm">Roguebasin</a>. 
Third constructor argument is a configuration object; allowed options:</p>
<ul>
	<li><code>roomWidth</code> &ndash; [min, max] room size</li>
	<li><code>roomHeight</code> &ndash; [min, max] room size</li>
	<li><code>corridorLength</code> &ndash; [min, max] corridor length</li>
	<li><code>dugPercentage</code> &ndash; algorithm stops after this fraction of map area has been dug out; default = 0.2</li>
	<li><code>timeLimit</code> &ndash; algorithm stops after this amount of milliseconds has passed</li>
</ul>

<div class="example">
var w = 40, h = 25;
var map = new ROT.Map.Digger(w, h);

for (var i=0; i&lt;4; i++) {
	var display = new ROT.Display({width:w, height:h, fontSize:6});
	SHOW(display.getContainer());
	map.create(display.DEBUG);
}
</div>

<h3>Uniform</h3>

<p>Generates a set of rooms; tries to connect them afterwards. Third constructor argument is a configuration object; allowed options:</p>
<ul>
	<li><code>roomWidth</code> &ndash; [min, max] room size</li>
	<li><code>roomHeight</code> &ndash; [min, max] room size</li>
	<li><code>roomDugPercentage</code> &ndash; algorithm stops after this fraction of map area has been filled with rooms; default = 0.2</li>
	<li><code>timeLimit</code> &ndash; algorithm stops after this amount of milliseconds has passed</li>
</ul>


<div class="example">
var w = 40, h = 25;
var map = new ROT.Map.Uniform(w, h);

for (var i=0; i&lt;4; i++) {
	var display = new ROT.Display({width:w, height:h, fontSize:6});
	SHOW(display.getContainer());
	map.create(display.DEBUG);
}
</div>