Skip to content

Commit

Permalink
fix: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPJT committed May 31, 2024
1 parent 4170850 commit 2c71dcb
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Library/PAX_GRAPHICA/Circle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ namespace paxg {
void draw(const paxg::Color&) const {}
#endif

void drawAt(const Vec2f& pos) const override {}
void drawAt(const Vec2i& pos) const override {}
void drawAt(const Vec2f&) const override {}
void drawAt(const Vec2i&) const override {}
};
}

Expand Down
16 changes: 8 additions & 8 deletions Library/PAX_MAHOROBA/Mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace s3d

struct Vec2
{
double x, y;
double x{}, y{};
Vec2() {}
Vec2(int, int) {}
Vec2(double _x, double _y) : x(_x), y(_y) {}
Expand Down Expand Up @@ -264,9 +264,9 @@ namespace s3d
class Font
{
public:
FontMethod method;
int w;
String path;
FontMethod method{};
int w{};
String path{};
Font operator()([[maybe_unused]] String path_) const { return Font(); }
Font region() const { return Font(); }
int height() const { return 0; }
Expand Down Expand Up @@ -374,9 +374,9 @@ namespace s3d
class MSRenderTexture
{
public:
Size size;
TextureFormat format;
HasDepth hasDepth;
Size size{};
TextureFormat format{};
HasDepth hasDepth{};

MSRenderTexture clear([[maybe_unused]] const ColorF& color) const { return MSRenderTexture(); }
void resolve() {}
Expand Down Expand Up @@ -420,7 +420,7 @@ namespace s3d
class ScopedRenderStates2D
{
public:
SamplerState samplerState;
SamplerState samplerState{};
ScopedRenderStates2D() {}
ScopedRenderStates2D(SamplerState) {}
ScopedRenderStates2D(BlendState) {}
Expand Down
2 changes: 1 addition & 1 deletion Library/PAX_SAPIENTICA/Simulation/Chromosome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ namespace paxs {

Chromosome random_chromosome;
for (std::uint_least8_t i = 0; i < chromosome_length; ++i) {
random_chromosome.set(i, dist(engine));
random_chromosome.set(i, static_cast<std::uint_least8_t>(dist(engine)));
}
random_chromosome.setGender(dist(engine) % 2);
return random_chromosome;
Expand Down
22 changes: 11 additions & 11 deletions Library/PAX_SAPIENTICA/Simulation/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ namespace paxs {
bi.calc(tmp_data);

const Vector2 default_position = Vector2(x, y) * pixel_size - start_xyz_position;
for(std::size_t y = 0;y < pixel_size;++y) {
for(std::size_t x = 0;x < pixel_size;++x) {
const Vector2 position = default_position + Vector2((GridType)x, (GridType)y);
data[position.toU64()] = static_cast<DataType>(tmp_data[y * pixel_size + x]);
for(std::size_t py = 0;py < pixel_size;++py) {
for(std::size_t px = 0;px < pixel_size;++px) {
const Vector2 position = default_position + Vector2((GridType)px, (GridType)py);
data[position.toU64()] = static_cast<DataType>(tmp_data[py * pixel_size + px]);
}
}

Expand Down Expand Up @@ -249,22 +249,22 @@ namespace paxs {


const Vector2 default_position = Vector2(x, y) * pixel_size - start_xyz_position;
for(std::size_t y = 0;y < file.size();++y) {
for(std::size_t py = 0;py < file.size();++py) {
// タブ区切り
const std::vector<std::string> values = StringExtensions::split(file[y], '\t');
for(std::size_t x = 0;x < values.size();++x) {
const Vector2 position = default_position + Vector2((GridType)x, (GridType)y);
if(values[x] == "") {
const std::vector<std::string> values = StringExtensions::split(file[py], '\t');
for(std::size_t px = 0;px < values.size();++px) {
const Vector2 position = default_position + Vector2((GridType)px, (GridType)py);
if(values[px] == "") {
continue;
}
// T型に変換
try {
if constexpr (std::is_same<DataType, std::uint_least8_t>::value || std::is_same<DataType, std::uint_least32_t>::value) {
int value = std::stoi(values[x]);
int value = std::stoi(values[px]);
if(value == 0) continue;
data[position.toU64()] = static_cast<DataType>(value);
} else if constexpr (std::is_same<DataType, float>::value) {
data[position.toU64()] = static_cast<DataType>(std::stod(values[x]));
data[position.toU64()] = static_cast<DataType>(std::stod(values[px]));
}
} catch (const std::invalid_argument&/*ia*/) {
PAXS_WARNING("File contains invalid value: " + file_name);
Expand Down
4 changes: 2 additions & 2 deletions Library/PAX_SAPIENTICA/Simulation/Genome.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ namespace paxs {
std::random_device seed_gen;
std::mt19937 engine(seed_gen());
std::uniform_int_distribution<> dist((std::numeric_limits<std::uint_least8_t>::min)(), (std::numeric_limits<std::uint_least8_t>::max)());
genome.setMtDNA(dist(engine));
genome.setYDNA(dist(engine));
genome.setMtDNA(static_cast<std::uint_least8_t>(dist(engine)));
genome.setYDNA(static_cast<std::uint_least8_t>(dist(engine)));
return genome;
}

Expand Down
18 changes: 9 additions & 9 deletions Library/PAX_SAPIENTICA/Simulation/JapanProvinces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ namespace paxs {
/// @brief A struct that represents a region in Japan.
/// @brief 日本の地方区分を表す構造体
struct JapanRegion {
std::uint_least8_t id;
std::string name;
std::uint_least32_t population; // 人口
std::uint_least8_t id = 0;
std::string name = "";
std::uint_least32_t population = 0; // 人口
};

/// @brief A struct that represents a prefecture in Japan.
/// @brief 日本の令制国を表す構造体
struct Ryoseikoku {
std::uint_least8_t id;
std::string name;
std::uint_least8_t region_id; // 対応する地方区分ID
std::uint_least32_t settlement_population_min_ad200;
std::uint_least32_t settlement_population_max_ad200;
std::uint_least32_t population[4];
std::uint_least8_t id = 0;
std::string name = "";
std::uint_least8_t region_id = 0; // 対応する地方区分ID
std::uint_least32_t settlement_population_min_ad200 = 0;
std::uint_least32_t settlement_population_max_ad200 = 0;
std::uint_least32_t population[4] = {};
};

/// @brief A class that represents a prefecture in Japan.
Expand Down
12 changes: 6 additions & 6 deletions Library/PAX_SAPIENTICA/Simulation/SettlementAgent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace paxs {

constexpr const Genome& cgetGenome() const noexcept { return genome; }

constexpr void setPartnerGenome(const Genome& genome) noexcept { partner_genome = genome; }
constexpr void setPartnerGenome(const Genome& genome_) noexcept { partner_genome = genome_; }

constexpr const Genome& cgetPartnerGenome() const noexcept { return partner_genome; }

Expand Down Expand Up @@ -169,15 +169,15 @@ namespace paxs {
std::uint_least8_t partner_farming = 0; // 結婚相手の農耕文化
std::uint_least8_t partner_hunter_gatherer = 0; // 結婚相手の狩猟採集文化

std::uint_least32_t age; // 年齢
std::uint_least32_t life_span; // 寿命
std::uint_least32_t age = 0; // 年齢
std::uint_least32_t life_span = 0; // 寿命
//std::uint_least32_t name_id; // 名前のID

std::uint_least32_t id; // ID
std::uint_least32_t id = 0; // ID
std::uint_least32_t partner_id = 0; // 結婚相手のID

Genome genome; // ゲノム
Genome partner_genome; // 結婚相手のゲノム
Genome genome{}; // ゲノム
Genome partner_genome{}; // 結婚相手のゲノム
};
}

Expand Down
10 changes: 5 additions & 5 deletions Library/PAX_SAPIENTICA/Simulation/SettlementGrid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ namespace paxs {
}

private:
std::vector<Settlement> settlements;
std::shared_ptr<Environment> environment;
Vector2 grid_position;
std::mt19937* gen; // 乱数生成器
std::vector<std::uint_least8_t> ryoseikoku_list;
std::vector<Settlement> settlements{};
std::shared_ptr<Environment> environment{};
Vector2 grid_position{};
std::mt19937* gen{}; // 乱数生成器
std::vector<std::uint_least8_t> ryoseikoku_list{};
};

}
Expand Down

0 comments on commit 2c71dcb

Please sign in to comment.