From d4163fcde35e813dbe7d5355dbd351a7bc18ea55 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 3 Feb 2012 11:43:13 +0400 Subject: [PATCH 1/2] Improve results of the embark-time prospector. --- plugins/prospector.cpp | 53 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index d550132a5..25ff08cb3 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -280,33 +280,40 @@ static command_result embark_prospector(DFHack::Core *c, df::viewscreen_choose_s { auto layer = geo_biome->layers[i]; - for (int z = layer->bottom_height; z <= layer->top_height; z++) - { - layerMats[layer->mat_index].add(z, 48*48*cnt); + layerMats[layer->mat_index].add(layer->bottom_height, 0); - for (unsigned j = 0; j < layer->vein_mat.size(); j++) - { - // TODO: find out how to estimate the real density - int bias = 100; - switch (layer->vein_type[j]) - { - case inclusion_type::VEIN: - bias = 360; - break; - case inclusion_type::CLUSTER: - bias = 1800; - break; - case inclusion_type::CLUSTER_SMALL: - bias = 18; - break; - case inclusion_type::CLUSTER_ONE: - bias = 3; - break; - } + int level_cnt = layer->top_height - layer->bottom_height + 1; + int layer_size = 48*48*cnt*level_cnt; - veinMats[layer->vein_mat[j]].add(z, layer->vein_unk_38[j]*bias*cnt/100); + for (unsigned j = 0; j < layer->vein_mat.size(); j++) + { + // TODO: find out how to estimate the real density + int bias = 100; + switch (layer->vein_type[j]) + { + case inclusion_type::VEIN: + bias = 200; + break; + case inclusion_type::CLUSTER: + bias = 1000; + break; + case inclusion_type::CLUSTER_SMALL: + bias = 15; + break; + case inclusion_type::CLUSTER_ONE: + bias = 2; + break; } + + int size = layer->vein_unk_38[j]*bias*cnt*level_cnt/100; + + veinMats[layer->vein_mat[j]].add(layer->bottom_height, 0); + veinMats[layer->vein_mat[j]].add(layer->top_height, size); + + layer_size -= size; } + + layerMats[layer->mat_index].add(layer->top_height, std::max(0,layer_size)); } } From 6bf55978a499df204ada6da2aac56ecb72305d2b Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Fri, 3 Feb 2012 12:48:38 +0400 Subject: [PATCH 2/2] Modify embark-time prospect using the randomized material hypothesis. Assume that the game generates a fixed number of veins of each type, but randomly chooses the material, using unk_38 as weight. This seems to bring some numbers closer to the real counts. --- plugins/prospector.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index 25ff08cb3..b7ade149d 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -285,28 +285,41 @@ static command_result embark_prospector(DFHack::Core *c, df::viewscreen_choose_s int level_cnt = layer->top_height - layer->bottom_height + 1; int layer_size = 48*48*cnt*level_cnt; + int sums[ENUM_LAST_ITEM(inclusion_type)+1] = { 0 }; + + for (unsigned j = 0; j < layer->vein_mat.size(); j++) + if (inclusion_type::is_valid(layer->vein_type[j])) + sums[layer->vein_type[j]] += layer->vein_unk_38[j]; + for (unsigned j = 0; j < layer->vein_mat.size(); j++) { // TODO: find out how to estimate the real density - int bias = 100; - switch (layer->vein_type[j]) + // this code assumes that vein_unk_38 is the weight + // used when choosing the vein material + int size = layer->vein_unk_38[j]*cnt*level_cnt; + df::inclusion_type type = layer->vein_type[j]; + + switch (type) { case inclusion_type::VEIN: - bias = 200; + // 3 veins of 80 tiles avg + size = size * 80 * 3 / sums[type]; break; case inclusion_type::CLUSTER: - bias = 1000; + // 1 cluster of 700 tiles avg + size = size * 700 * 1 / sums[type]; break; case inclusion_type::CLUSTER_SMALL: - bias = 15; + size = size * 6 * 7 / sums[type]; break; case inclusion_type::CLUSTER_ONE: - bias = 2; + size = size * 1 * 5 / sums[type]; break; + default: + // shouldn't actually happen + size = cnt*level_cnt; } - int size = layer->vein_unk_38[j]*bias*cnt*level_cnt/100; - veinMats[layer->vein_mat[j]].add(layer->bottom_height, 0); veinMats[layer->vein_mat[j]].add(layer->top_height, size);