summaryrefslogtreecommitdiff
path: root/graphs/cpp/caste_or_cast/colony.hh
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/cpp/caste_or_cast/colony.hh
add: graphs et rushs
Diffstat (limited to 'graphs/cpp/caste_or_cast/colony.hh')
-rw-r--r--graphs/cpp/caste_or_cast/colony.hh43
1 files changed, 43 insertions, 0 deletions
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 <vector>
+
+#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> 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<std::shared_ptr<Worker>> workers_;
+ //! unique queen, only its colony have the ownership of it.
+ std::unique_ptr<Queen> queen_ = nullptr;
+
+ //! friend classes
+ friend class Ant;
+ friend class Nurturer;
+};