Skip to content

Commit d08f650

Browse files
authored
Merge pull request #130 from AsPJT/feature-Hokkaido202505
シミュレーション結果のRegionテキスト出力機能追加
2 parents 7d2da55 + 1b9d408 commit d08f650

File tree

5 files changed

+106
-17
lines changed

5 files changed

+106
-17
lines changed

Library/PAX_GRAPHICA/Key.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@ namespace paxs {
349349
// 中央の座標を指定
350350
Coordinate center = Coordinate(
351351
200.0,
352-
paxs::EquirectangularDeg(paxs::Vector2<double>(135, 35)) // 韓国 128, 37
352+
paxs::EquirectangularDeg(paxs::Vector2<double>(146, 46)) // 韓国 128, 37 // 135, 35
353353
//paxs::Vector2(135.0, getLatitudeToMercatorY(35.0))
354354
); // マップ座標の中央
355-
double height = 12.0; // マップの高さ
355+
double height = 16.0; // マップの高さ
356356

357357
// 平城京
358358
//Coordinate center = Coordinate(135.807, 37.009/*getLatitudeToMercatorY(35)*/, 200.0); // マップ座標の中央

Library/PAX_MAHOROBA/LocationPoint.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ namespace paxs {
797797

798798
const std::uint_least8_t pop = (pop_original >= 75) ? 75 : static_cast<std::uint_least8_t>(pop_original);
799799
paxg::Circle(draw_pos,
800-
1.0f + (settlement.getPopulation() / 40.0f)//2.0f
800+
1.0f + (settlement.getPopulation() / 10.0f)//2.0f
801801
).draw(getColor(pop));
802802
}
803803
else {
@@ -821,7 +821,7 @@ namespace paxs {
821821
break;
822822
}
823823
paxg::Circle(draw_pos,
824-
1.0f + (settlement.getPopulation() / 40.0f)//2.0f
824+
1.0f + (settlement.getPopulation() / 10.0f)//2.0f
825825
).draw(language_color);
826826
}
827827

Library/PAX_SAPIENTICA/Simulation/SettlementSimulator.hpp

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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\thabitable_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

Library/PAX_SAPIENTICA/Version.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
// PAX_SAPIENTICA 微修正バージョン [v6.0.a.a.X]
3636
#ifndef PAX_SAPIENTICA_LIBRARY_PATCHLEVEL
37-
#define PAX_SAPIENTICA_LIBRARY_PATCHLEVEL (0)
37+
#define PAX_SAPIENTICA_LIBRARY_PATCHLEVEL (10)
3838
#endif
3939

4040
// バージョン名 ( https://github.com/AsPJT/PAX_SAPIENTICA )
@@ -51,6 +51,16 @@
5151
更新履歴
5252
バージョン | 更新日 | 概要
5353
6.0.1.0.X | 2024/0X/XX | コピペ用
54+
6.0.1.3.10 | 2025/05/14 | シミュレーション結果のRegionテキスト出力機能追加 #130
55+
6.0.1.3.9 | 2025/04/24 | SFML3.0.0対応(Mac) #129
56+
6.0.1.3.8 | 2025/04/23 | CMR46 & CMR49 #127 #128
57+
6.0.1.3.7 | 2025/04/23 | Added LifeSpanCMR47 #125 #126
58+
6.0.1.3.6 | 2025/03/13 | Fixed population estimates #124
59+
6.0.1.3.5 | 2025/03/13 | Added population estimates for regions in Ryukyu and Hokkaido #123
60+
6.0.1.3.4 | 2025/03/13 | Changes to Childbearing.tsv and District.tsv #122
61+
6.0.1.3.3 | 2025/03/13 | シミュレーションのファイルパス指定機能・合成地図のTSV出力プログラムを追加 #121
62+
6.0.1.3.2 | 2025/01/29 | Fixed birth rate #120
63+
6.0.1.3.1 | 2025/01/28 | Fixed Childbearing.tsv #118 #119
5464
6.0.1.3.0 | 2025/01/10 | 画面に表示する情報を追加 #117
5565
6.0.1.2.16 | 2024/12/14 | 生活に関するTSVデータ入力の追加 #116
5666
6.0.1.2.15 | 2024/12/13 | 婚姻処理の高速化 #115

Projects/MicrosoftVisualStudio/ImageToData/main20250303.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace xyz_tiles_conv {
5656
std::string input{};
5757
};
5858
//const std::string output = path + "Data/XYZTiles/Test20250313/{z}/{x}/{y}";
59-
const std::string output = path + "Data/XYZTiles/Test20250313/zxy_{z}_{x}_{y}";
59+
const std::string output = path + "Data/XYZTiles/Test20250512/zxy_{z}_{x}_{y}";
6060

6161
constexpr std::size_t width0{ 256 }, height0{ 256 }; //幅と高さ
6262
}
@@ -214,22 +214,37 @@ bool ToTSV(const xyz_tiles_conv::XYZTilesConv& conv_data) {
214214

215215
int main() {
216216

217+
//zxy_10_840_432_40_72
217218
std::vector<xyz_tiles_conv::XYZTilesConv> conv_data_list;
218219
conv_data_list.emplace_back(
219-
/*z*/ 10,/*min_x*/ 908,/*min_y*/ 326,/*len_x*/ 50,/*len_y*/ 59,
220-
/*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/zxy3_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
221-
);
222-
conv_data_list.emplace_back(
223-
/*z*/ 10,/*min_x*/ 853,/*min_y*/ 385,/*len_x*/ 64,/*len_y*/ 64,
224-
/*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/zxy3_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
220+
/*z*/ 7,/*min_x*/ 105,/*min_y*/ 54,/*len_x*/ 5,/*len_y*/ 9,
221+
/*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/zxy_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
225222
);
226223

224+
//zxy_10_840_432_40_72
225+
//std::vector<xyz_tiles_conv::XYZTilesConv> conv_data_list;
226+
//conv_data_list.emplace_back(
227+
// /*z*/ 10,/*min_x*/ 840,/*min_y*/ 432,/*len_x*/ 40,/*len_y*/ 72,
228+
// /*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/zxy_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
229+
//);
230+
231+
//// 北海道・サハリン南部
232+
//std::vector<xyz_tiles_conv::XYZTilesConv> conv_data_list;
233+
//conv_data_list.emplace_back(
234+
// /*z*/ 10,/*min_x*/ 908,/*min_y*/ 326,/*len_x*/ 50,/*len_y*/ 59,
235+
// /*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/zxy5_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
236+
//);
237+
//conv_data_list.emplace_back(
238+
// /*z*/ 10,/*min_x*/ 853,/*min_y*/ 385,/*len_x*/ 64,/*len_y*/ 64,
239+
// /*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/zxy3_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
240+
//);
241+
227242
//conv_data_list.emplace_back(
228243
// /*z*/ 10,/*min_x*/ 872,/*min_y*/ 360,/*len_x*/ 64,/*len_y*/ 64,
229244
// /*std::string*/ path + "Data/Map/XYZTile/Union/ColorCodingByProvincesOfJapan/ColorCodingByProvincesOfJapan_{z}_{min_x}_{min_y}_{len_x}_{len_y}.png"
230245
//);
231246

232247
ToTSV(conv_data_list[0]);
233-
ToTSV(conv_data_list[1]);
248+
//ToTSV(conv_data_list[1]);
234249

235250
}

0 commit comments

Comments
 (0)