From adec433bceb6a29b2b5baeca658cb0b716a503b0 Mon Sep 17 00:00:00 2001 From: "James P. Howard, II" Date: Sun, 22 Jan 2023 20:46:34 -0500 Subject: [PATCH] style(source): automatic reformatting --- src/libkami/agent.cc | 44 +++++++++++--- src/libkami/domain.cc | 5 +- src/libkami/grid1d.cc | 86 ++++++++++++++++++++------- src/libkami/grid2d.cc | 116 +++++++++++++++++++++++++++---------- src/libkami/multigrid1d.cc | 13 ++++- src/libkami/multigrid2d.cc | 15 ++++- src/libkami/population.cc | 7 ++- src/libkami/random.cc | 14 ++++- src/libkami/reporter.cc | 17 ++++-- src/libkami/sequential.cc | 14 +++-- src/libkami/sologrid1d.cc | 13 ++++- src/libkami/sologrid2d.cc | 15 ++++- src/libkami/staged.cc | 17 ++++-- 13 files changed, 281 insertions(+), 95 deletions(-) diff --git a/src/libkami/agent.cc b/src/libkami/agent.cc index 7cd442e..a23391c 100644 --- a/src/libkami/agent.cc +++ b/src/libkami/agent.cc @@ -30,32 +30,58 @@ namespace kami { - AgentID::AgentID() : _id(_id_next++) {} + AgentID::AgentID() + :_id(_id_next++) { + } - std::string AgentID::to_string() const { return std::to_string(_id); } + std::string AgentID::to_string() const { + return std::to_string(_id); + } - bool operator==(const AgentID &lhs, const AgentID &rhs) { + bool operator==( + const AgentID& lhs, + const AgentID& rhs + ) { return lhs._id == rhs._id; } - bool operator!=(const AgentID &lhs, const AgentID &rhs) { + bool operator!=( + const AgentID& lhs, + const AgentID& rhs + ) { return !(lhs == rhs); } - bool operator<(const AgentID &lhs, const AgentID &rhs) { + bool operator<( + const AgentID& lhs, + const AgentID& rhs + ) { return lhs._id < rhs._id; } - std::ostream &operator<<(std::ostream &lhs, const AgentID &rhs) { + std::ostream& operator<<( + std::ostream& lhs, + const AgentID& rhs + ) { return lhs << rhs.to_string(); } - AgentID Agent::get_agent_id() const { return this->_agent_id; } + AgentID Agent::get_agent_id() const { + return this->_agent_id; + } - bool operator==(const Agent &lhs, const Agent &rhs) { + bool operator==( + const Agent& lhs, + const Agent& rhs + ) { return lhs._agent_id == rhs._agent_id; } - bool operator!=(const Agent &lhs, const Agent &rhs) { return !(lhs == rhs); } + bool operator!=( + const Agent& lhs, + const Agent& rhs + ) { + return !(lhs == rhs); + } } // namespace kami diff --git a/src/libkami/domain.cc b/src/libkami/domain.cc index e7b5c5f..c2c1dcd 100644 --- a/src/libkami/domain.cc +++ b/src/libkami/domain.cc @@ -30,7 +30,10 @@ namespace kami { - std::ostream &operator<<(std::ostream &lhs, const Coord &rhs) { + std::ostream& operator<<( + std::ostream& lhs, + const Coord& rhs + ) { return lhs << rhs.to_string(); } diff --git a/src/libkami/grid1d.cc b/src/libkami/grid1d.cc index 6a78741..efa555d 100644 --- a/src/libkami/grid1d.cc +++ b/src/libkami/grid1d.cc @@ -39,7 +39,9 @@ namespace kami { - GridCoord1D::GridCoord1D(int x_coord) : _x_coord(x_coord) {} + GridCoord1D::GridCoord1D(int x_coord) + :_x_coord(x_coord) { + } int GridCoord1D::x() const { return _x_coord; @@ -49,41 +51,65 @@ namespace kami { return std::string("(" + std::to_string(_x_coord) + ")"); } - double GridCoord1D::distance(std::shared_ptr &p) const { + double GridCoord1D::distance(std::shared_ptr& p) const { auto p1d = std::static_pointer_cast(p); return static_cast(abs(_x_coord - p1d->_x_coord)); } - bool operator==(const GridCoord1D &lhs, const GridCoord1D &rhs) { + bool operator==( + const GridCoord1D& lhs, + const GridCoord1D& rhs + ) { return (lhs._x_coord == rhs._x_coord); } - bool operator!=(const GridCoord1D &lhs, const GridCoord1D &rhs) { + bool operator!=( + const GridCoord1D& lhs, + const GridCoord1D& rhs + ) { return !(lhs == rhs); } - std::ostream &operator<<(std::ostream &lhs, const GridCoord1D &rhs) { + std::ostream& operator<<( + std::ostream& lhs, + const GridCoord1D& rhs + ) { return lhs << rhs.to_string(); } - GridCoord1D operator+(const GridCoord1D &lhs, const GridCoord1D &rhs) { + GridCoord1D operator+( + const GridCoord1D& lhs, + const GridCoord1D& rhs + ) { return GridCoord1D(lhs._x_coord + rhs._x_coord); } - GridCoord1D operator-(const GridCoord1D &lhs, const GridCoord1D &rhs) { + GridCoord1D operator-( + const GridCoord1D& lhs, + const GridCoord1D& rhs + ) { return GridCoord1D(lhs._x_coord - rhs._x_coord); } - GridCoord1D operator*(const GridCoord1D &lhs, const double rhs) { + GridCoord1D operator*( + const GridCoord1D& lhs, + const double rhs + ) { return GridCoord1D(static_cast(lhs._x_coord * rhs)); } - GridCoord1D operator*(const double lhs, const GridCoord1D &rhs) { + GridCoord1D operator*( + const double lhs, + const GridCoord1D& rhs + ) { return GridCoord1D(static_cast(rhs._x_coord * lhs)); } - Grid1D::Grid1D(unsigned int maximum_x, bool wrap_x) { + Grid1D::Grid1D( + unsigned int maximum_x, + bool wrap_x + ) { _maximum_x = maximum_x; _wrap_x = wrap_x; @@ -95,7 +121,10 @@ namespace kami { return delete_agent(agent_id, get_location_by_agent(agent_id)); } - AgentID Grid1D::delete_agent(AgentID agent_id, const GridCoord1D &coord) { + AgentID Grid1D::delete_agent( + AgentID agent_id, + const GridCoord1D& coord + ) { for (auto test_agent_id = _agent_grid->find(coord); test_agent_id != _agent_grid->end(); test_agent_id++) if (test_agent_id->second == agent_id) { _agent_grid->erase(test_agent_id); @@ -107,35 +136,44 @@ namespace kami { fmt::format("Agent {} not found at location {}", agent_id.to_string(), coord.to_string())); } - bool Grid1D::is_location_valid(const GridCoord1D &coord) const { + bool Grid1D::is_location_valid(const GridCoord1D& coord) const { auto x = coord.x(); return (x >= 0 && x < static_cast(_maximum_x)); } - bool Grid1D::is_location_empty(const GridCoord1D &coord) const { + bool Grid1D::is_location_empty(const GridCoord1D& coord) const { auto grid_location = _agent_grid->equal_range(coord); return grid_location.first == grid_location.second; } - AgentID Grid1D::move_agent(const AgentID agent_id, const GridCoord1D &coord) { + AgentID Grid1D::move_agent( + const AgentID agent_id, + const GridCoord1D& coord + ) { return add_agent(delete_agent(agent_id, get_location_by_agent(agent_id)), coord); } std::shared_ptr> - Grid1D::get_neighborhood(const AgentID agent_id, const bool include_center) const { + Grid1D::get_neighborhood( + const AgentID agent_id, + const bool include_center + ) const { return std::move(get_neighborhood(get_location_by_agent(agent_id), include_center)); } std::shared_ptr> - Grid1D::get_neighborhood(const GridCoord1D &coord, const bool include_center) const { + Grid1D::get_neighborhood( + const GridCoord1D& coord, + const bool include_center + ) const { auto neighborhood = std::make_shared>(); // We assume our starting position is valid if (include_center) neighborhood->insert(coord); - for (auto &direction: directions) { + for (auto& direction : directions) { auto new_location = coord_wrap(coord + direction); if (is_location_valid(new_location)) @@ -145,7 +183,7 @@ namespace kami { return std::move(neighborhood); } - std::shared_ptr> Grid1D::get_location_contents(const GridCoord1D &coord) const { + std::shared_ptr> Grid1D::get_location_contents(const GridCoord1D& coord) const { auto agent_ids = std::make_shared>(); if (!is_location_valid(coord)) @@ -162,18 +200,22 @@ namespace kami { return agent_ids; } - bool Grid1D::get_wrap_x() const { return _wrap_x; } + bool Grid1D::get_wrap_x() const { + return _wrap_x; + } - unsigned int Grid1D::get_maximum_x() const { return _maximum_x; } + unsigned int Grid1D::get_maximum_x() const { + return _maximum_x; + } - GridCoord1D Grid1D::get_location_by_agent(const AgentID &agent_id) const { + GridCoord1D Grid1D::get_location_by_agent(const AgentID& agent_id) const { auto coord = _agent_index->find(agent_id); if (coord == _agent_index->end()) throw error::AgentNotFound(fmt::format("Agent {} not found on grid", agent_id.to_string())); return coord->second; } - GridCoord1D Grid1D::coord_wrap(const GridCoord1D &coord) const { + GridCoord1D Grid1D::coord_wrap(const GridCoord1D& coord) const { auto x = coord.x(); if (_wrap_x) diff --git a/src/libkami/grid2d.cc b/src/libkami/grid2d.cc index c737b96..1478533 100644 --- a/src/libkami/grid2d.cc +++ b/src/libkami/grid2d.cc @@ -50,12 +50,15 @@ namespace kami { return std::string("(" + std::to_string(_x_coord) + ", " + std::to_string(_y_coord) + ")"); } - double GridCoord2D::distance(std::shared_ptr &p) const { + double GridCoord2D::distance(std::shared_ptr& p) const { auto p2d = std::static_pointer_cast(p); return distance(p2d); } - double GridCoord2D::distance(std::shared_ptr &p, GridDistanceType distance_type) const { + double GridCoord2D::distance( + std::shared_ptr& p, + GridDistanceType distance_type + ) const { switch (distance_type) { case GridDistanceType::Chebyshev: return distance_chebyshev(p); @@ -68,51 +71,80 @@ namespace kami { } } - bool operator==(const GridCoord2D &lhs, const GridCoord2D &rhs) { + bool operator==( + const GridCoord2D& lhs, + const GridCoord2D& rhs + ) { return (lhs._x_coord == rhs._x_coord && lhs._y_coord == rhs._y_coord); } - bool operator!=(const GridCoord2D &lhs, const GridCoord2D &rhs) { + bool operator!=( + const GridCoord2D& lhs, + const GridCoord2D& rhs + ) { return !(lhs == rhs); } - std::ostream &operator<<(std::ostream &lhs, const GridCoord2D &rhs) { + std::ostream& operator<<( + std::ostream& lhs, + const GridCoord2D& rhs + ) { return lhs << rhs.to_string(); } - GridCoord2D::GridCoord2D(int x_coord, int y_coord) - : _x_coord(x_coord), _y_coord(y_coord) {} + GridCoord2D::GridCoord2D( + int x_coord, + int y_coord + ) + :_x_coord(x_coord), _y_coord(y_coord) { + } - double GridCoord2D::distance_chebyshev(std::shared_ptr &p) const { + double GridCoord2D::distance_chebyshev(std::shared_ptr& p) const { return static_cast(fmax(abs(_x_coord - p->_x_coord), abs(_x_coord - p->_x_coord))); } - double GridCoord2D::distance_euclidean(std::shared_ptr &p) const { + double GridCoord2D::distance_euclidean(std::shared_ptr& p) const { return sqrt(pow(_x_coord - p->_x_coord, 2) + pow(_x_coord - p->_x_coord, 2)); } - double GridCoord2D::distance_manhattan(std::shared_ptr &p) const { + double GridCoord2D::distance_manhattan(std::shared_ptr& p) const { return static_cast(abs(_x_coord - p->_x_coord) + abs(_x_coord - p->_x_coord)); } - GridCoord2D operator+(const GridCoord2D &lhs, const GridCoord2D &rhs) { + GridCoord2D operator+( + const GridCoord2D& lhs, + const GridCoord2D& rhs + ) { return {lhs._x_coord + rhs._x_coord, lhs._y_coord + rhs._y_coord}; } - GridCoord2D operator-(const GridCoord2D &lhs, const GridCoord2D &rhs) { + GridCoord2D operator-( + const GridCoord2D& lhs, + const GridCoord2D& rhs + ) { return {lhs._x_coord - rhs._x_coord, lhs._y_coord - rhs._y_coord}; } - GridCoord2D operator*(const GridCoord2D &lhs, const double rhs) { + GridCoord2D operator*( + const GridCoord2D& lhs, + const double rhs + ) { return {static_cast(lhs._x_coord * rhs), static_cast(lhs._y_coord * rhs)}; } - GridCoord2D operator*(const double lhs, const GridCoord2D &rhs) { + GridCoord2D operator*( + const double lhs, + const GridCoord2D& rhs + ) { return {static_cast(rhs._x_coord * lhs), static_cast(rhs._y_coord * lhs)}; } - Grid2D::Grid2D(unsigned int maximum_x, unsigned int maximum_y, bool wrap_x, - bool wrap_y) { + Grid2D::Grid2D( + unsigned int maximum_x, + unsigned int maximum_y, + bool wrap_x, + bool wrap_y + ) { _maximum_x = maximum_x; _maximum_y = maximum_y; _wrap_x = wrap_x; @@ -126,7 +158,10 @@ namespace kami { return delete_agent(agent_id, get_location_by_agent(agent_id)); } - AgentID Grid2D::delete_agent(const AgentID agent_id, const GridCoord2D &coord) { + AgentID Grid2D::delete_agent( + const AgentID agent_id, + const GridCoord2D& coord + ) { for (auto test_agent_id = _agent_grid->find(coord); test_agent_id != _agent_grid->end(); test_agent_id++) if (test_agent_id->second == agent_id) { _agent_grid->erase(test_agent_id); @@ -137,7 +172,7 @@ namespace kami { throw error::AgentNotFound("Agent not found on grid"); } - bool Grid2D::is_location_valid(const GridCoord2D &coord) const { + bool Grid2D::is_location_valid(const GridCoord2D& coord) const { auto x = coord.x(); auto y = coord.y(); @@ -145,24 +180,33 @@ namespace kami { y >= 0 && y < static_cast(_maximum_y)); } - bool Grid2D::is_location_empty(const GridCoord2D &coord) const { + bool Grid2D::is_location_empty(const GridCoord2D& coord) const { auto grid_location = _agent_grid->equal_range(coord); return grid_location.first == grid_location.second; } - AgentID Grid2D::move_agent(const AgentID agent_id, const GridCoord2D &coord) { + AgentID Grid2D::move_agent( + const AgentID agent_id, + const GridCoord2D& coord + ) { return add_agent(delete_agent(agent_id, get_location_by_agent(agent_id)), coord); } std::shared_ptr> - Grid2D::get_neighborhood(const AgentID agent_id, const bool include_center, - const GridNeighborhoodType neighborhood_type) const { + Grid2D::get_neighborhood( + const AgentID agent_id, + const bool include_center, + const GridNeighborhoodType neighborhood_type + ) const { return std::move(get_neighborhood(get_location_by_agent(agent_id), include_center, neighborhood_type)); } std::shared_ptr> - Grid2D::get_neighborhood(const GridCoord2D &coord, const bool include_center, - const GridNeighborhoodType neighborhood_type) const { + Grid2D::get_neighborhood( + const GridCoord2D& coord, + const bool include_center, + const GridNeighborhoodType neighborhood_type + ) const { auto neighborhood = std::make_unique>(); std::vector directions; @@ -181,7 +225,7 @@ namespace kami { if (include_center and is_location_valid(coord)) neighborhood->insert(coord); - for (auto &direction: directions) { + for (auto& direction : directions) { auto new_location = coord_wrap(coord + direction); if (is_location_valid(new_location)) @@ -191,7 +235,7 @@ namespace kami { return std::move(neighborhood); } - std::shared_ptr> Grid2D::get_location_contents(const GridCoord2D &coord) const { + std::shared_ptr> Grid2D::get_location_contents(const GridCoord2D& coord) const { auto agent_ids = std::make_shared>(); if (!is_location_valid(coord)) @@ -208,22 +252,30 @@ namespace kami { return agent_ids; } - bool Grid2D::get_wrap_x() const { return _wrap_x; } + bool Grid2D::get_wrap_x() const { + return _wrap_x; + } - bool Grid2D::get_wrap_y() const { return _wrap_y; } + bool Grid2D::get_wrap_y() const { + return _wrap_y; + } - unsigned int Grid2D::get_maximum_x() const { return _maximum_x; } + unsigned int Grid2D::get_maximum_x() const { + return _maximum_x; + } - unsigned int Grid2D::get_maximum_y() const { return _maximum_y; } + unsigned int Grid2D::get_maximum_y() const { + return _maximum_y; + } - GridCoord2D Grid2D::get_location_by_agent(const AgentID &agent_id) const { + GridCoord2D Grid2D::get_location_by_agent(const AgentID& agent_id) const { auto coord = _agent_index->find(agent_id); if (coord == _agent_index->end()) throw error::AgentNotFound(fmt::format("Agent {} not found on grid", agent_id.to_string())); return coord->second; } - GridCoord2D Grid2D::coord_wrap(const GridCoord2D &coord) const { + GridCoord2D Grid2D::coord_wrap(const GridCoord2D& coord) const { auto x = coord.x(); auto y = coord.y(); diff --git a/src/libkami/multigrid1d.cc b/src/libkami/multigrid1d.cc index c0b6a60..926306a 100644 --- a/src/libkami/multigrid1d.cc +++ b/src/libkami/multigrid1d.cc @@ -33,10 +33,17 @@ namespace kami { - MultiGrid1D::MultiGrid1D(unsigned int maximum_x, bool wrap_x) - : Grid1D(maximum_x, wrap_x) {} + MultiGrid1D::MultiGrid1D( + unsigned int maximum_x, + bool wrap_x + ) + :Grid1D(maximum_x, wrap_x) { + } - AgentID MultiGrid1D::add_agent(const AgentID agent_id, const GridCoord1D &coord) { + AgentID MultiGrid1D::add_agent( + const AgentID agent_id, + const GridCoord1D& coord + ) { if (!is_location_valid(coord)) throw error::LocationInvalid(fmt::format("Coordinates {} are invalid", coord.to_string())); diff --git a/src/libkami/multigrid2d.cc b/src/libkami/multigrid2d.cc index 95ed0c4..cf2049b 100644 --- a/src/libkami/multigrid2d.cc +++ b/src/libkami/multigrid2d.cc @@ -33,10 +33,19 @@ namespace kami { - MultiGrid2D::MultiGrid2D(unsigned int maximum_x, unsigned int maximum_y, bool wrap_x, bool wrap_y) - : Grid2D(maximum_x, maximum_y, wrap_x, wrap_y) {} + MultiGrid2D::MultiGrid2D( + unsigned int maximum_x, + unsigned int maximum_y, + bool wrap_x, + bool wrap_y + ) + :Grid2D(maximum_x, maximum_y, wrap_x, wrap_y) { + } - AgentID MultiGrid2D::add_agent(const AgentID agent_id, const GridCoord2D &coord) { + AgentID MultiGrid2D::add_agent( + const AgentID agent_id, + const GridCoord2D& coord + ) { if (!is_location_valid(coord)) throw error::LocationInvalid(fmt::format("Coordinates {} are invalid", coord.to_string())); diff --git a/src/libkami/population.cc b/src/libkami/population.cc index 17d7445..46d6696 100644 --- a/src/libkami/population.cc +++ b/src/libkami/population.cc @@ -33,7 +33,7 @@ namespace kami { - AgentID Population::add_agent(const std::shared_ptr &agent) noexcept { + AgentID Population::add_agent(const std::shared_ptr& agent) noexcept { auto agent_id = agent->get_agent_id(); _agent_map.insert(std::pair>(agent_id, agent)); return agent->get_agent_id(); @@ -60,7 +60,10 @@ namespace kami { } std::unique_ptr> Population::get_agent_list() const { - auto key_selector = [](auto pair) { return pair.first; }; + auto key_selector = [](auto pair) + { + return pair.first; + }; auto agent_ids = std::make_unique>(_agent_map.size()); transform(_agent_map.begin(), _agent_map.end(), agent_ids->begin(), key_selector); diff --git a/src/libkami/random.cc b/src/libkami/random.cc index d7ce8f2..040c1ae 100644 --- a/src/libkami/random.cc +++ b/src/libkami/random.cc @@ -41,7 +41,10 @@ namespace kami { } std::unique_ptr> - RandomScheduler::step(std::shared_ptr model, std::unique_ptr> agent_list) { + RandomScheduler::step( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { if (_rng == nullptr) throw error::ResourceNotAvailable("No random number generator available"); @@ -50,7 +53,10 @@ namespace kami { } std::unique_ptr> - RandomScheduler::step(std::shared_ptr model, std::unique_ptr> agent_list) { + RandomScheduler::step( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { if (_rng == nullptr) throw error::ResourceNotAvailable("No random number generator available"); @@ -63,6 +69,8 @@ namespace kami { return _rng; } - std::shared_ptr RandomScheduler::get_rng() { return (this->_rng); } + std::shared_ptr RandomScheduler::get_rng() { + return (this->_rng); + } } // namespace kami diff --git a/src/libkami/reporter.cc b/src/libkami/reporter.cc index af2df80..6f8b14f 100644 --- a/src/libkami/reporter.cc +++ b/src/libkami/reporter.cc @@ -70,23 +70,28 @@ namespace kami { } std::unique_ptr - Reporter::collect(const std::shared_ptr &model) { + Reporter::collect(const std::shared_ptr& model) { auto pop = model->get_population(); return collect(model, pop); } std::unique_ptr - Reporter::collect(const std::shared_ptr &model, const std::shared_ptr &pop) { + Reporter::collect( + const std::shared_ptr& model, + const std::shared_ptr& pop + ) { auto agent_list = pop->get_agent_list(); return collect(model, agent_list); } std::unique_ptr - Reporter::collect(const std::shared_ptr &model, - const std::unique_ptr> &agent_list) { + Reporter::collect( + const std::shared_ptr& model, + const std::unique_ptr>& agent_list + ) { auto collection_array = std::vector(); - for (auto &agent_id: *agent_list) { + for (auto& agent_id : *agent_list) { auto agent_data = nlohmann::json(); auto agent = std::static_pointer_cast(model->get_population()->get_agent_by_id(agent_id)); @@ -112,7 +117,7 @@ namespace kami { return std::move(collection); } - std::unique_ptr Reporter::report(const std::shared_ptr &model) { + std::unique_ptr Reporter::report(const std::shared_ptr& model) { auto json_data = std::make_unique(*_report_data); return std::move(json_data); } diff --git a/src/libkami/sequential.cc b/src/libkami/sequential.cc index 33b27b7..9d6ea82 100644 --- a/src/libkami/sequential.cc +++ b/src/libkami/sequential.cc @@ -43,12 +43,15 @@ namespace kami { } std::unique_ptr> - SequentialScheduler::step(std::shared_ptr model, std::unique_ptr> agent_list) { + SequentialScheduler::step( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { auto return_agent_list = std::make_unique>(); auto population = model->get_population(); Scheduler::_step_counter++; - for (auto &agent_id: *agent_list) { + for (auto& agent_id : *agent_list) { auto agent = population->get_agent_by_id(agent_id); agent->step(model); @@ -59,12 +62,15 @@ namespace kami { } std::unique_ptr> - SequentialScheduler::step(std::shared_ptr model, std::unique_ptr> agent_list) { + SequentialScheduler::step( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { auto return_agent_list = std::make_unique>(); auto population = model->get_population(); Scheduler::_step_counter++; - for (auto &agent_id: *agent_list) { + for (auto& agent_id : *agent_list) { auto agent = population->get_agent_by_id(agent_id); agent->step(model); diff --git a/src/libkami/sologrid1d.cc b/src/libkami/sologrid1d.cc index be72c84..06d4405 100644 --- a/src/libkami/sologrid1d.cc +++ b/src/libkami/sologrid1d.cc @@ -31,10 +31,17 @@ namespace kami { - SoloGrid1D::SoloGrid1D(unsigned int maximum_x, bool wrap_x) - : Grid1D(maximum_x, wrap_x) {} + SoloGrid1D::SoloGrid1D( + unsigned int maximum_x, + bool wrap_x + ) + :Grid1D(maximum_x, wrap_x) { + } - AgentID SoloGrid1D::add_agent(const AgentID agent_id, const GridCoord1D &coord) { + AgentID SoloGrid1D::add_agent( + const AgentID agent_id, + const GridCoord1D& coord + ) { if (!is_location_valid(coord)) throw error::LocationInvalid(fmt::format("Coordinates {} are invalid", coord.to_string())); if (!is_location_empty(coord)) diff --git a/src/libkami/sologrid2d.cc b/src/libkami/sologrid2d.cc index ab65044..e0f580c 100644 --- a/src/libkami/sologrid2d.cc +++ b/src/libkami/sologrid2d.cc @@ -33,10 +33,19 @@ namespace kami { - SoloGrid2D::SoloGrid2D(unsigned int maximum_x, unsigned int maximum_y, bool wrap_x, bool wrap_y) - : Grid2D(maximum_x, maximum_y, wrap_x, wrap_y) {} + SoloGrid2D::SoloGrid2D( + unsigned int maximum_x, + unsigned int maximum_y, + bool wrap_x, + bool wrap_y + ) + :Grid2D(maximum_x, maximum_y, wrap_x, wrap_y) { + } - AgentID SoloGrid2D::add_agent(const AgentID agent_id, const GridCoord2D &coord) { + AgentID SoloGrid2D::add_agent( + const AgentID agent_id, + const GridCoord2D& coord + ) { if (!is_location_valid(coord)) throw error::LocationInvalid(fmt::format("Coordinates {} are invalid", coord.to_string())); if (!is_location_empty(coord)) diff --git a/src/libkami/staged.cc b/src/libkami/staged.cc index 610be8c..bbd4213 100644 --- a/src/libkami/staged.cc +++ b/src/libkami/staged.cc @@ -35,13 +35,19 @@ namespace kami { std::unique_ptr> - StagedScheduler::step(std::shared_ptr model, std::unique_ptr> agent_list) { + StagedScheduler::step( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { auto stepped_agent_list = this->SequentialScheduler::step(model, std::move(agent_list)); return std::move(this->advance(model, std::move(stepped_agent_list))); } std::unique_ptr> - StagedScheduler::step(std::shared_ptr model, std::unique_ptr> agent_list) { + StagedScheduler::step( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { auto stepped_agent_list = this->SequentialScheduler::step(model, std::move(agent_list)); return std::move(this->advance(model, std::move(stepped_agent_list))); } @@ -57,11 +63,14 @@ namespace kami { } std::unique_ptr> - StagedScheduler::advance(std::shared_ptr model, std::unique_ptr> agent_list) { + StagedScheduler::advance( + std::shared_ptr model, + std::unique_ptr> agent_list + ) { auto return_agent_list = std::make_unique>(); auto population = model->get_population(); - for (auto &agent_id: *agent_list) { + for (auto& agent_id : *agent_list) { auto agent = std::static_pointer_cast(population->get_agent_by_id(agent_id)); agent->advance(model);