Skip to content

Commit

Permalink
add: Human
Browse files Browse the repository at this point in the history
  • Loading branch information
guinpen98 committed Jun 22, 2023
1 parent d7e5529 commit 1164d7d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

#include <cmath>

#include <PAX_SAPIENTICA/Simulation/SimulationConst.hpp>
#include <PAX_SAPIENTICA/Type/Vector2.hpp>

namespace paxs {
template <typename T>
Vector2<double> convertToMercatorCoordinate(const Vector2<T>& start_position, const Vector2<T>& position, const int z, const int pixel_size) {
Vector2<double> convertToMercatorCoordinate(const Vector2<T>& start_position, const Vector2<T>& position, const int z) {
const double n = std::pow(2, z);
const double pixel_sum = pixel_size * n;
const double u = (double)position.x / pixel_sum + start_position.x / n;
Expand Down
3 changes: 1 addition & 2 deletions Library/PAX_SAPIENTICA/Simulation/Data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <PAX_SAPIENTICA/CuiOutput/Graphic.hpp>
#include <PAX_SAPIENTICA/FileRead/Convert.hpp>
#include <PAX_SAPIENTICA/FileRead/Read.hpp>
#include <PAX_SAPIENTICA/Simulation/SimulationConst.hpp>
#include <PAX_SAPIENTICA/Type/Vector2.hpp>

#include <iostream>
Expand Down Expand Up @@ -72,8 +73,6 @@ namespace paxs {
return itr->second;
}
private:
const int pixel_size = 256;

Vector2 start_position;
Vector2 end_position;
std::string name;
Expand Down
3 changes: 1 addition & 2 deletions Library/PAX_SAPIENTICA/Simulation/Environment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <PAX_SAPIENTICA/FileRead/Split.hpp>
#include <PAX_SAPIENTICA/Simulation/Data.hpp>
#include <PAX_SAPIENTICA/Simulation/GeographicInformation.hpp>
#include <PAX_SAPIENTICA/Simulation/SimulationConst.hpp>
#include <PAX_SAPIENTICA/Type/Vector2.hpp>

namespace paxs {
Expand All @@ -37,8 +38,6 @@ namespace paxs {
public:
using Vector2 = paxs::Vector2<T>;

int pixel_size = 256;

using DataVariant = std::variant<Data<std::uint_least8_t>, Data<std::uint_least32_t>, Data<float>>;
std::unordered_map<std::string, DataVariant> data_map;

Expand Down
39 changes: 39 additions & 0 deletions Library/PAX_SAPIENTICA/Simulation/Human.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*##########################################################################################
PAX SAPIENTICA Library 💀🌿🌏
[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/
##########################################################################################*/

#ifndef PAX_SAPIENTICA_SIMULATION_HUMAN_HPP
#define PAX_SAPIENTICA_SIMULATION_HUMAN_HPP

/*##########################################################################################
##########################################################################################*/

#include <PAX_SAPIENTICA/Simulation/Human.hpp>

namespace paxs {
template <typename T>
class Human : public Agent<T> {
public:
using Vector2 = paxs::Vector2<T>;
using Environment = paxs::Environment<T>;

Human(const std::string& id, const std::string& name, const Vector2& pos, const std::uint_least8_t gen, const std::uint_least8_t age, const std::uint_least8_t life_exp, Environment* env)
: Agent<T>(id, name, pos, gen, age, life_exp, env) {}

bool operator==(const paxs::Human<T>& a) {
return Agent<T>::operator==(a);
}
protected:

};
}

#endif // !PAX_SAPIENTICA_SIMULATION_HUMAN_HPP
23 changes: 23 additions & 0 deletions Library/PAX_SAPIENTICA/Simulation/SimulationConst.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*##########################################################################################
PAX SAPIENTICA Library 💀🌿🌏
[Planning] 2023 As Project
[Production] 2023 As Project
[Contact Us] wanotaitei@gmail.com https://github.com/AsPJT/PAX_SAPIENTICA
[License] Distributed under the CC0 1.0. https://creativecommons.org/publicdomain/zero/1.0/
##########################################################################################*/

#ifndef PAX_SAPIENTICA_SIMULATION_SIMULATION_CONST_HPP
#define PAX_SAPIENTICA_SIMULATION_SIMULATION_CONST_HPP

/*##########################################################################################
##########################################################################################*/

namespace paxs {
static int pixel_size = 256;
}

#endif // !PAX_SAPIENTICA_SIMULATION_SIMULATION_CONST_HPP
5 changes: 3 additions & 2 deletions Library/PAX_SAPIENTICA/Simulation/Simulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <PAX_SAPIENTICA/Simulation/Agent.hpp>
#include <PAX_SAPIENTICA/Simulation/Environment.hpp>
#include <PAX_SAPIENTICA/Simulation/SimulationConst.hpp>

namespace paxs {
template <typename T>
Expand Down Expand Up @@ -74,8 +75,8 @@ namespace paxs {

void randomizeAgents(const int agent_count) {
const Vector2& offset = environment.getEndPosition() - environment.getStartPosition();
std::uniform_int_distribution<> x_dist(0, environment.pixel_size * offset.x);
std::uniform_int_distribution<> y_dist(0, environment.pixel_size * offset.y);
std::uniform_int_distribution<> x_dist(0, pixel_size * offset.x);
std::uniform_int_distribution<> y_dist(0, pixel_size * offset.y);
std::uniform_int_distribution<> age_dist(0, 20);
std::cout << "Randomizing agents..." << std::endl;
for(int i = 0;i < agent_count;++i) {
Expand Down

0 comments on commit 1164d7d

Please sign in to comment.