File: unique.lua

package info (click to toggle)
crawl 2%3A0.7.1-3
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 30,420 kB
  • ctags: 23,018
  • sloc: cpp: 244,317; ansic: 16,144; perl: 2,214; makefile: 984; python: 488; objc: 250; ruby: 200; sh: 140
file content (68 lines) | stat: -rw-r--r-- 1,754 bytes parent folder | download | duplicates (2)
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
-- Test correct handling of you.unique_creatures.

local function test_uniques()
  debug.save_uniques()
  debug.generate_level()
  assert(debug.check_uniques(),
         "you.uniques out of sync with actually placed uniques")
end

local function test_uniques_branch(branch, depth)
  crawl.message("Running unique placement tests in branch " .. branch)
  debug.flush_map_memory()
  for d = 1, depth do
    debug.goto_place(branch .. ":" .. d)
    test_uniques()
  end
end

local function test_uniques_blank(branch, depth, nlevels)
  local place = branch .. ":" .. depth
  crawl.message("Running blanked placement test at " .. place)
  debug.goto_place(place)
  for lev_i = 1, nlevels do
    debug.reset_uniques()
    debug.flush_map_memory()
    test_uniques()
  end
end

local function test_uniques_random(branch, depth, nlevels)
  local place = branch .. ":" .. depth
  crawl.message("Running randomized placement test at " .. place)
  debug.goto_place(place)
  for lev_i = 1, nlevels do
    debug.randomize_uniques()
    debug.flush_map_memory()
    test_uniques()
  end
end

local function run_unique_tests()
  test_uniques_branch("D", 27)
  test_uniques_branch("Dis", 7)

  for depth = 1, 27 do
    test_uniques_blank("D", depth, 3)
    test_uniques_random("D", depth, 3)
  end

  for depth = 1, 7 do
    test_uniques_blank("Dis", depth, 3)
    if depth < 7 then
      -- otherwise we get failures for randomly placed Dispater
      -- getting placed again
      test_uniques_random("Dis", depth, 3)
    end
  end

  for depth = 5, 1, -1 do
    test_uniques_blank("Swamp", depth, 3)
    if depth < 5 then
      -- otherwise problem with lernaean, like Dispater above
      test_uniques_random("Swamp", depth, 3)
    end
  end
end

run_unique_tests()