diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..40c5e4e
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+douwco_hivemind
\ No newline at end of file
diff --git a/.idea/editor.xml b/.idea/editor.xml
new file mode 100644
index 0000000..ead1d8a
--- /dev/null
+++ b/.idea/editor.xml
@@ -0,0 +1,248 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..df87cf9
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..03d9549
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0b76fe5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..af391e9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/screeps.iml b/.idea/screeps.iml
new file mode 100644
index 0000000..f08604b
--- /dev/null
+++ b/.idea/screeps.iml
@@ -0,0 +1,2 @@
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..cc407db
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..552a6ab
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,119 @@
+
+
+
+
+
+
+
+
+
+
+ {
+ "useNewFormat": true
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "customColor": "",
+ "associatedIndex": 4
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1765843941573
+
+
+ 1765843941573
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/douwco_hivemind/src/Spawn.cpp b/douwco_hivemind/src/Spawn.cpp
index 6317129..2580046 100644
--- a/douwco_hivemind/src/Spawn.cpp
+++ b/douwco_hivemind/src/Spawn.cpp
@@ -1,5 +1,10 @@
+#include
+
#include
#include
+#include
+#include
+#include
#include "Creeps/CreepBase.hpp"
#include "Structures/Spawn.hpp"
@@ -10,13 +15,25 @@ void DouwcoHivemind::Spawn::loop()
if (Screeps::Game.time() % 50 != 0)
return;
- int energyAvailable = spawn.room().energyAvailable();
- int energyCapacityAvailable = spawn.room().energyCapacityAvailable();
+ auto room = spawn.room();
+ int energyAvailable = room.energyAvailable();
+ int energyCapacityAvailable = room.energyCapacityAvailable();
+ int constructionSiteCount = room.find(Screeps::FIND_MY_CONSTRUCTION_SITES).size();
+ auto structures = room.find(Screeps::FIND_STRUCTURES);
+ int repairableStructureCount, extensionCount;
+ for (auto& roomObj : structures)
+ {
+ auto structure = dynamic_cast(roomObj.get());
+ std::string type = structure->structureType();
+ if (type == Screeps::STRUCTURE_CONTROLLER || type == Screeps::STRUCTURE_SPAWN) continue;
+ repairableStructureCount++;
+ if (type == Screeps::STRUCTURE_EXTENSION) extensionCount++;
+ }
- int required_upgraders = 1;
- int required_suppliers = 1;
- int required_maintainers = spawn.room().find(Screeps::FIND_MY_STRUCTURES).size() <= 2 ? 0 : 1;;
- int required_builders = spawn.room().find(Screeps::FIND_MY_CONSTRUCTION_SITES).size() == 0 ? 0 : 1;
+ int required_suppliers = std::clamp(extensionCount/5, 1, 2);
+ int required_maintainers = std::clamp(repairableStructureCount, 0, 1);
+ int required_builders = std::clamp(constructionSiteCount, 0, 5);
+ int required_upgraders = std::clamp(5-required_builders-required_maintainers-required_suppliers, 1, 3);
for (auto &creep : Screeps::Game.creeps())
{
@@ -32,7 +49,7 @@ void DouwcoHivemind::Spawn::loop()
required_builders--;
}
- if (energyAvailable < energyCapacityAvailable && required_suppliers < 2)
+ if (energyAvailable < energyCapacityAvailable && required_suppliers == 0)
return;
std::string name;
JSON opts;