forked from crawl/crawl
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathuniquegen.lua
55 lines (47 loc) · 1.36 KB
/
uniquegen.lua
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
-- Test that randomly generated monsters aren't uniques.
local place = dgn.point(20, 20)
local place2 = dgn.point(50, 50) -- out-of-view of place, to avoid message spam
local count = 100
local function test_place_random_monster()
dgn.dismiss_monsters()
dgn.grid(place.x, place.y, "floor")
-- Try several times, because MONS_NO_MONSTER may be on the random list.
for attempt = 1, 100 do
m = dgn.create_monster(place.x, place.y, "random")
if m then
break
end
end
assert(m,
"could not place random monster")
assert(not m.unique,
"random monster is unique " .. m.name)
end
local function test_random_unique(branch, depth)
crawl.message("Running random monster unique tests in branch " .. branch
.. " through depth " .. depth)
debug.flush_map_memory()
for d = 1, depth do
debug.goto_place(branch .. ":" .. d)
dgn.grid(place2.x, place2.y, "floor")
you.moveto(place2.x, place2.y)
for i = 1, count do
test_place_random_monster()
end
end
end
local function run_random_unique_tests()
for depth = 1, 15 do
test_random_unique("D", depth, 3)
end
for depth = 1, 5 do
test_random_unique("Depths", depth, 3)
end
for depth = 1, 7 do
test_random_unique("Dis", depth, 3)
end
for depth = 1, 4 do
test_random_unique("Swamp", depth, 5)
end
end
run_random_unique_tests()