From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/cpp/caste_or_cast/colony.hh | 43 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 graphs/cpp/caste_or_cast/colony.hh (limited to 'graphs/cpp/caste_or_cast/colony.hh') diff --git a/graphs/cpp/caste_or_cast/colony.hh b/graphs/cpp/caste_or_cast/colony.hh new file mode 100644 index 0000000..917ebf8 --- /dev/null +++ b/graphs/cpp/caste_or_cast/colony.hh @@ -0,0 +1,43 @@ +#pragma once + +#include + +#include "queen.hh" +#include "worker.hh" + +//! forward declarations +class Provider; +class Nurturer; + +/* + * Colony class that acts as one entity and manage all of its ants + */ +class Colony +{ +public: + //! constructor + Colony(uint32_t passport); + //! static method that adds a COPY of the given ant to the given colony + static bool addAnt(const Ant& ant, std::shared_ptr colony); + //! manage all the ants, can be understood as one round + void manageAnts(); + //! overall cleanliness of the colony + float cleanliness = 100; + +private: + //! manage the queen (is alive etc.) + void manageQueen(); + //! remove all the dead workers of the workers_ vector + void removeDeadWorkers(); + //! attribute used to recognise if an Ant is from the same colony + uint32_t passport_pheromone_; + //! vector of all workers of the colony, each worker is stored in a + //! shared_ptr + std::vector> workers_; + //! unique queen, only its colony have the ownership of it. + std::unique_ptr queen_ = nullptr; + + //! friend classes + friend class Ant; + friend class Nurturer; +}; -- cgit v1.2.3