Skip to content

Commit

Permalink
Let mapstat report vetoes at the map level.
Browse files Browse the repository at this point in the history
This is intended to debug the scenario where the vault itself places
successfully, but places in such a fashion that it causes the level to
veto frequently, thus making it less likely to place at all.
  • Loading branch information
sgrunt committed Nov 29, 2015
1 parent 0659a06 commit 3a206a4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
15 changes: 10 additions & 5 deletions crawl-ref/source/dbg-maps.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

static map<string, int> try_count;
static map<string, int> use_count;
static map<string, int> success_count;
static vector<level_id> generated_levels;
static int branch_count;
static map<level_id, int> level_mapcounts;
Expand Down Expand Up @@ -282,6 +283,11 @@ void mapstat_report_map_use(const map_def &map)
map_levelsused[map.name].insert(level_id::current());
}

void mapstat_report_map_success(const string &map_name)
{
success_count[map_name]++;
}

void mapstat_report_error(const map_def &map, const string &err)
{
last_error = err;
Expand Down Expand Up @@ -432,7 +438,7 @@ static void _write_map_stats()
fprintf(outf, "------------\n\n");
}

fprintf(outf, "\n\nMaps used:\n\n");
fprintf(outf, "\n\nMaps used (successful, placed incl. vetoed, tried):\n\n");
multimap<int, string> usedmaps;
for (const auto &entry : try_count)
usedmaps.insert(make_pair(entry.second, entry.first));
Expand All @@ -441,10 +447,9 @@ static void _write_map_stats()
{
const int tries = entry.first;
const int uses = lookup(use_count, entry.second, 0);
if (tries == uses)
fprintf(outf, "%4d : %s\n", tries, entry.second.c_str());
else
fprintf(outf, "%4d (%4d): %s\n", uses, tries, entry.second.c_str());
const int succ = lookup(success_count, entry.second, 0);
fprintf(outf, "%4d, %4d, %4d: %s\n",
succ, uses, tries, entry.second.c_str());
}

fprintf(outf, "\n\nMaps and where used:\n\n");
Expand Down
1 change: 1 addition & 0 deletions crawl-ref/source/dbg-maps.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class map_def;
void mapstat_report_map_try(const map_def &map);
void mapstat_report_map_use(const map_def &map);
void mapstat_report_map_success(const string &map_name);
void mapstat_report_error(const map_def &map, const string &err);
void mapstat_report_map_build_start();
void mapstat_report_map_veto(const string &message);
Expand Down
15 changes: 15 additions & 0 deletions crawl-ref/source/dungeon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ static bool dgn_check_connectivity = false;
static int dgn_zones = 0;

static vector<string> _you_vault_list;
#ifdef DEBUG_STATISTICS
static vector<string> _you_all_vault_list;
#endif

struct coloured_feature
{
Expand Down Expand Up @@ -426,6 +429,11 @@ static bool _build_level_vetoable(bool enable_random_maps,
vec.insert(vec.end(), _you_vault_list.begin(), _you_vault_list.end());
}

#ifdef DEBUG_STATISTICS
for (auto vault : _you_all_vault_list)
mapstat_report_map_success(vault);
#endif

return true;
}

Expand Down Expand Up @@ -1120,6 +1128,9 @@ void dgn_reset_level(bool enable_random_maps)
you.unique_items = temp_unique_items;

_you_vault_list.clear();
#ifdef DEBUG_STATISTICS
_you_all_vault_list.clear();
#endif
env.level_build_method.clear();
env.level_layout_types.clear();
level_clear_vault_memory();
Expand Down Expand Up @@ -6746,6 +6757,10 @@ static void _remember_vault_placement(const vault_placement &place, bool extra)
else
you.vault_list[level_id::current()].push_back(place.map.name);
}

#ifdef DEBUG_STATISTICS
_you_all_vault_list.push_back(place.map.name);
#endif
}

string dump_vault_maps()
Expand Down

0 comments on commit 3a206a4

Please sign in to comment.