summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-29 08:01:34 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-29 08:01:34 +0000
commit4acd88735bc13d574620a4c154a0e0adf9057726 (patch)
treecd19b38a16bc632d71fb408f7982ee0c04ae2275
parent86dd3a54bf5985566f112fe220482b8acc1e70af (diff)
downloadcrawl-ref-4acd88735bc13d574620a4c154a0e0adf9057726.tar.gz
crawl-ref-4acd88735bc13d574620a4c154a0e0adf9057726.zip
Trunk->0.3 merge (2653): Added dummy vault to correct non-dungeon vault probabilities.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2654 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/dat/float.des14
-rw-r--r--crawl-ref/source/debug.cc120
-rw-r--r--crawl-ref/source/maps.cc77
-rw-r--r--crawl-ref/source/maps.h5
4 files changed, 176 insertions, 40 deletions
diff --git a/crawl-ref/source/dat/float.des b/crawl-ref/source/dat/float.des
index e1b174818d..8c2a13586c 100644
--- a/crawl-ref/source/dat/float.des
+++ b/crawl-ref/source/dat/float.des
@@ -33,6 +33,20 @@ x
ENDMAP
##############################################################################
+# Dummy probability balancer vault for non-dungeon branches.
+#
+NAME: dummy_balancer_other
+DEPTH: 1-, !D
+# Vaults tagged "dummy" are no-ops when the dungeon builder is looking for maps
+# by depth.
+TAGS: dummy
+ORIENT: float
+CHANCE: 60
+MAP
+x
+ENDMAP
+
+##############################################################################
# Cavepeople
#
NAME: erik_1
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index cd922de58c..532448dbc5 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -2816,16 +2816,19 @@ void mapgen_report_map_veto()
static bool mg_do_build_level(int niters)
{
- mesclr();
- mprf("On %s (%d); %d g, %d fail, %d err%s, %d uniq, "
- "%d try, %d (%.2lf%%) vetos",
- level_id::current().describe().c_str(), niters,
- mg_levels_tried, mg_levels_failed, mapgen_errors.size(),
- mapgen_last_error.empty()? ""
- : (" (" + mapgen_last_error + ")").c_str(),
- mapgen_use_count.size(),
- mg_build_attempts, mg_vetoes,
- mg_build_attempts? mg_vetoes * 100.0 / mg_build_attempts : 0.0);
+ if (niters > 1)
+ {
+ mesclr();
+ mprf("On %s (%d); %d g, %d fail, %d err%s, %d uniq, "
+ "%d try, %d (%.2lf%%) vetos",
+ level_id::current().describe().c_str(), niters,
+ mg_levels_tried, mg_levels_failed, mapgen_errors.size(),
+ mapgen_last_error.empty()? ""
+ : (" (" + mapgen_last_error + ")").c_str(),
+ mapgen_use_count.size(),
+ mg_build_attempts, mg_vetoes,
+ mg_build_attempts? mg_vetoes * 100.0 / mg_build_attempts : 0.0);
+ }
no_messages mx;
for (int i = 0; i < niters; ++i)
@@ -2833,8 +2836,6 @@ static bool mg_do_build_level(int niters)
if (kbhit() && getch() == ESCAPE)
return (false);
- you.uniq_map_tags.clear();
- you.uniq_map_names.clear();
++mg_levels_tried;
if (!builder(you.your_level, you.level_type))
++mg_levels_failed;
@@ -2842,11 +2843,9 @@ static bool mg_do_build_level(int niters)
return (true);
}
-static void mg_build_levels(int niters)
+static std::vector<level_id> mg_dungeon_places()
{
- mesclr();
- mprf("Generating dungeon map stats");
-
+ std::vector<level_id> places;
for (int br = BRANCH_MAIN_DUNGEON; br < NUM_BRANCHES; ++br)
{
if (branches[br].depth == -1)
@@ -2854,32 +2853,56 @@ static void mg_build_levels(int niters)
const branch_type branch = static_cast<branch_type>(br);
for (int depth = 1; depth <= branches[br].depth; ++depth)
- {
- you.your_level = absdungeon_depth(branch, depth);
- you.where_are_you = branch;
- you.level_type = LEVEL_DUNGEON;
+ places.push_back( level_id(branch, depth) );
+ }
- int iters = niters;
- if (branch == BRANCH_MAIN_DUNGEON && depth == 1)
- iters *= 10;
- if (!mg_do_build_level(iters))
- return;
- }
+ places.push_back(LEVEL_ABYSS);
+ places.push_back(LEVEL_LABYRINTH);
+ places.push_back(LEVEL_PANDEMONIUM);
+ places.push_back(LEVEL_PORTAL_VAULT);
+
+ return (places);
+}
+
+static void mg_build_dungeon()
+{
+ const std::vector<level_id> places = mg_dungeon_places();
+
+ for (int i = 0, size = places.size(); i < size; ++i)
+ {
+ const level_id &lid = places[i];
+ you.your_level = absdungeon_depth(lid.branch, lid.depth);
+ you.where_are_you = lid.branch;
+ you.level_type = lid.level_type;
+ if (you.level_type == LEVEL_PORTAL_VAULT)
+ you.level_type_name = "bazaar";
+ if (!mg_do_build_level(1))
+ return;
}
+}
- you.level_type = LEVEL_ABYSS;
- if (!mg_do_build_level(niters))
- return;
- you.level_type = LEVEL_LABYRINTH;
- if (!mg_do_build_level(niters))
- return;
- you.level_type = LEVEL_PANDEMONIUM;
- if (!mg_do_build_level(niters))
- return;
- you.level_type = LEVEL_PORTAL_VAULT;
- you.level_type_name = "bazaar";
- if (!mg_do_build_level(niters))
- return;
+static void mg_build_levels(int niters)
+{
+ mesclr();
+ mprf("Generating dungeon map stats");
+
+ for (int i = 0; i < niters; ++i)
+ {
+ mesclr();
+ mprf("On %d of %d; %d g, %d fail, %d err%s, %d uniq, "
+ "%d try, %d (%.2lf%%) vetos",
+ i, niters,
+ mg_levels_tried, mg_levels_failed, mapgen_errors.size(),
+ mapgen_last_error.empty()? ""
+ : (" (" + mapgen_last_error + ")").c_str(),
+ mapgen_use_count.size(),
+ mg_build_attempts, mg_vetoes,
+ mg_build_attempts? mg_vetoes * 100.0 / mg_build_attempts : 0.0);
+
+ you.uniq_map_tags.clear();
+ you.uniq_map_names.clear();
+ mg_build_dungeon();
+ }
}
void mapgen_report_map_try(const map_def &map)
@@ -2900,6 +2923,23 @@ void mapgen_report_error(const map_def &map, const std::string &err)
mapgen_last_error = err;
}
+static void mapgen_report_avaiable_random_vaults(FILE *outf)
+{
+ you.uniq_map_tags.clear();
+ you.uniq_map_names.clear();
+
+ const std::vector<level_id> places = mg_dungeon_places();
+ fprintf(outf, "\n\nRandom vaults available by dungeon level:\n");
+
+ for (std::vector<level_id>::const_iterator i = places.begin();
+ i != places.end(); ++i)
+ {
+ fprintf(outf, "\n%s -------------\n", i->describe().c_str());
+ mg_report_random_maps(outf, *i);
+ fprintf(outf, "---------------------------------\n");
+ }
+}
+
static void check_mapless(const level_id &lid, std::vector<level_id> &mapless)
{
if (mapgen_level_mapsused.find(lid) == mapgen_level_mapsused.end())
@@ -2951,6 +2991,8 @@ static void write_mapgen_stats()
fprintf(outf, "%3d) %s\n", i + 1, mapless[i].describe().c_str());
}
+ mapgen_report_avaiable_random_vaults(outf);
+
std::vector<std::string> unused_maps;
for (int i = 0, size = map_count(); i < size; ++i)
{
diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc
index dc1d66155d..02b45e4744 100644
--- a/crawl-ref/source/maps.cc
+++ b/crawl-ref/source/maps.cc
@@ -342,7 +342,6 @@ std::vector<std::string> find_map_matches(const std::string &name)
return (matches);
}
-
// Returns a map for which PLACE: matches the given place.
int random_map_for_place(const level_id &place, bool want_minivault)
{
@@ -717,3 +716,79 @@ void run_map_preludes()
}
}
}
+
+///////////////////////////////////////////////////////////////////////////
+// Debugging code
+
+#ifdef DEBUG_DIAGNOSTICS
+
+typedef std::pair<std::string, int> weighted_map_name;
+typedef std::vector<weighted_map_name> weighted_map_names;
+
+static weighted_map_names mg_find_random_vaults(
+ const level_id &place, bool wantmini)
+{
+ weighted_map_names wms;
+
+ if (!place.is_valid())
+ return (wms);
+
+ for (unsigned i = 0, size = vdefs.size(); i < size; ++i)
+ {
+ if (vdefs[i].is_minivault() == wantmini
+ && !vdefs[i].place.is_valid()
+ && vdefs[i].is_usable_in(place)
+ // Some tagged levels cannot be selected by depth. This is
+ // the only thing preventing Pandemonium demon vaults from
+ // showing up in the main dungeon.
+ && !vdefs[i].has_tag_suffix("entry")
+ && !vdefs[i].has_tag("pan")
+ && !vdefs[i].has_tag("unrand")
+ && !vdefs[i].has_tag("bazaar"))
+ {
+ wms.push_back(
+ weighted_map_name( vdefs[i].name, vdefs[i].chance ) );
+ }
+ }
+
+ return (wms);
+}
+
+static void mg_report_random_vaults(
+ FILE *outf, const level_id &place, bool wantmini)
+{
+ weighted_map_names wms = mg_find_random_vaults(place, wantmini);
+ int weightsum = 0;
+ for (int i = 0, size = wms.size(); i < size; ++i)
+ weightsum += wms[i].second;
+
+ std::string line;
+ for (int i = 0, size = wms.size(); i < size; ++i)
+ {
+ std::string curr =
+ make_stringf("%s (%.2f%%)",
+ wms[i].first.c_str(),
+ 100.0 * wms[i].second / weightsum);
+ if (i < size - 1)
+ curr += ", ";
+ if (line.length() + curr.length() > 80u)
+ {
+ fprintf(outf, "%s\n", line.c_str());
+ line.clear();
+ }
+
+ line += curr;
+ }
+ if (!line.empty())
+ fprintf(outf, "%s\n", line.c_str());
+}
+
+void mg_report_random_maps(FILE *outf, const level_id &place)
+{
+ fprintf(outf, "---------------- Mini\n");
+ mg_report_random_vaults(outf, place, true);
+ fprintf(outf, "------------- Regular\n");
+ mg_report_random_vaults(outf, place, false);
+}
+
+#endif
diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h
index e5ce87220d..5e0f56b40f 100644
--- a/crawl-ref/source/maps.h
+++ b/crawl-ref/source/maps.h
@@ -75,4 +75,9 @@ extern bool lc_run_global_prelude;
const int MAP_CACHE_VERSION = 1007;
+
+#ifdef DEBUG_DIAGNOSTICS
+void mg_report_random_maps(FILE *outf, const level_id &place);
+#endif
+
#endif