@@ -127,11 +127,22 @@ namespace paxs {
127127 language_ofs = std::ofstream (str + " /Language.txt" );
128128 live_ofs = std::ofstream (str + " /HabitableLand.txt" );
129129
130+ pop_region_ofs = std::ofstream (str + " /Region_Population.txt" );
131+ mtdna_region_ofs = std::ofstream (str + " /Region_mtDNA.txt" );
132+ snp_region_ofs = std::ofstream (str + " /Region_SNP.txt" );
133+ language_region_ofs = std::ofstream (str + " /Region_Language.txt" );
134+ live_region_ofs = std::ofstream (str + " /Region_HabitableLand.txt" );
135+
130136 outputResultString (pop_ofs);
131137 outputResultString (mtdna_ofs);
132138 outputResultString (snp_ofs);
133139 outputResultString (language_ofs);
134- for (std::size_t i = 0 ; i < max_number_of_districts; ++i) {
140+
141+ outputResultString (pop_region_ofs);
142+ outputResultString (mtdna_region_ofs);
143+ outputResultString (snp_region_ofs);
144+ outputResultString (language_region_ofs);
145+ for (std::size_t i = 0 ; i < max_number_of_districts - 1 ; ++i) {
135146 outputResultDistrictName (pop_ofs, i);
136147 outputResultDistrictName (mtdna_ofs, i);
137148 outputResultDistrictName (snp_ofs, i);
@@ -141,6 +152,11 @@ namespace paxs {
141152 outputResultLastString (mtdna_ofs);
142153 outputResultLastString (snp_ofs);
143154 outputResultLastString (language_ofs);
155+
156+ outputResultLastString (pop_region_ofs);
157+ outputResultLastString (mtdna_region_ofs);
158+ outputResultLastString (snp_region_ofs);
159+ outputResultLastString (language_region_ofs);
144160 }
145161
146162 // / @brief Initialize the simulator.
@@ -165,7 +181,7 @@ namespace paxs {
165181
166182 // 可住地の数を出力
167183 live_ofs << " district\t habitable_land\n " ;
168- for (std::size_t i = 0 ; i < max_number_of_districts; ++i) {
184+ for (std::size_t i = 1 ; i < max_number_of_districts; ++i) {
169185 live_ofs << japan_provinces->cgetDistrictList ()[i].name << ' \t ' << (*live_list)[i + 1 ].habitable_land_positions .size () << ' \n ' ;
170186 }
171187 }
@@ -214,6 +230,12 @@ namespace paxs {
214230 double ryosnp[max_number_of_districts]{};
215231 double ryolanguage[max_number_of_districts]{};
216232
233+ std::array<std::uint_least32_t , 10 > region_pop{};
234+ std::array<std::uint_least32_t , 10 > region_set{};
235+ std::array<std::uint_least32_t , 10 > region_snp{};
236+ std::array<std::uint_least32_t , 10 > region_language{};
237+ std::vector<std::vector<int >> mtdna_region_num (10 , std::vector<int >(256 , 0 )); // mtDNA 数
238+
217239 // 地名を描画
218240 for (const auto & agent : getSettlementGrids ()) {
219241 for (const auto & settlement : agent.second .cgetSettlements ()) {
@@ -227,9 +249,14 @@ namespace paxs {
227249 ryolanguage[ryo_id]+= settlement.getLanguage (); // 地区ごとに言語を増加させる
228250 ++(ryoset[ryo_id]);
229251
252+ // 地域区分
253+ const std::uint_least8_t region_id = japan_provinces->getJapanRegionId (ryo_id);
254+
230255 // mtDNA ごとにカウント
231256 for (int popi = 0 ; popi < settlement.cgetAgents ().size (); ++popi) {
232- mtdna_num[ryo_id][settlement.cgetAgents ()[popi].cgetGenome ().getMtDNA ()] += 1 ;
257+ const auto get_mtdna = settlement.cgetAgents ()[popi].cgetGenome ().getMtDNA ();
258+ mtdna_num[ryo_id][get_mtdna] += 1 ;
259+ if (region_id < 10 ) mtdna_region_num[region_id][get_mtdna] += 1 ;
233260 }
234261 }
235262 }
@@ -238,7 +265,21 @@ namespace paxs {
238265 mtdna_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
239266 snp_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
240267 language_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
241- for (std::size_t i = 0 ; i < max_number_of_districts; ++i) {
268+
269+ pop_region_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
270+ mtdna_region_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
271+ snp_region_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
272+ language_region_ofs << step_count << ' \t ' << sat_num << ' \t ' << pop_num << ' \t ' ;
273+
274+ for (std::size_t i = 1 ; i < max_number_of_districts; ++i) {
275+ // 地域区分
276+ const std::uint_least8_t region_id = japan_provinces->getJapanRegionId (i);
277+ if (region_id < 10 ) {
278+ region_pop[region_id] += static_cast <std::uint_least32_t >(ryopop[i]);
279+ region_set[region_id] += static_cast <std::uint_least32_t >(ryoset[i]);
280+ region_snp[region_id] += static_cast <std::uint_least32_t >(ryosnp[i]);
281+ region_language[region_id] += static_cast <std::uint_least32_t >(ryolanguage[i]);
282+ }
242283 ryosnp[i] /= static_cast <double >(ryoset[i]);
243284 ryolanguage[i] /= static_cast <double >(ryoset[i]);
244285 pop_ofs << ryopop[i] << ' \t ' ;
@@ -250,10 +291,26 @@ namespace paxs {
250291 }
251292 mtdna_ofs << ' \t ' ;
252293 }
294+ // Region
295+ for (std::size_t region_id = 0 ; region_id < 10 ; ++region_id) {
296+ pop_region_ofs << region_pop[region_id] << ' \t ' ;
297+ snp_region_ofs << static_cast <double >(region_snp[region_id]) / static_cast <double >(region_set[region_id]) << ' \t ' ;
298+ language_region_ofs << static_cast <double >(region_language[region_id]) / static_cast <double >(region_set[region_id]) << ' \t ' ;
299+ for (std::size_t j = 0 ; j < japan_provinces->getSizeMtDNA (); ++j) {
300+ if (int (mtdna_region_num[region_id][j]) == 0 ) continue ;
301+ mtdna_region_ofs << japan_provinces->getMtDNA_Name (static_cast <std::uint_least8_t >(j)) << ' :' << int (mtdna_region_num[region_id][j]) << ' /' ;
302+ }
303+ mtdna_region_ofs << ' \t ' ;
304+ }
253305 pop_ofs << step_count << ' \n ' ;
254306 mtdna_ofs << step_count << ' \n ' ;
255307 snp_ofs << step_count << ' \n ' ;
256308 language_ofs << step_count << ' \n ' ;
309+
310+ pop_region_ofs << step_count << ' \n ' ;
311+ mtdna_region_ofs << step_count << ' \n ' ;
312+ snp_region_ofs << step_count << ' \n ' ;
313+ language_region_ofs << step_count << ' \n ' ;
257314 }
258315
259316 std::vector<std::tuple<std::uint_least32_t , Vector2, Vector2>> move_list;
@@ -429,6 +486,13 @@ namespace paxs {
429486 std::ofstream snp_ofs;
430487 std::ofstream language_ofs;
431488 std::ofstream live_ofs;
489+
490+ std::ofstream pop_region_ofs;
491+ std::ofstream mtdna_region_ofs;
492+ std::ofstream snp_region_ofs;
493+ std::ofstream language_region_ofs;
494+ std::ofstream live_region_ofs;
495+
432496 // 婚姻時に移動前の位置と移動後の位置を記録
433497 std::vector<GridType4> marriage_pos_list{};
434498
0 commit comments