+
+ // demote crowded tiles
+ for (auto &c : planet.Creatures()) {
+ if (&*c == &GetCreature()) continue;
+ if (c->GetSituation().Surface() != srf) continue;
+ glm::ivec2 coords(c->GetSituation().SurfacePosition());
+ if (coords.x < begin.x || coords.x >= end.x) continue;
+ if (coords.y < begin.y || coords.y >= end.y) continue;
+ rating[coords.y - begin.y][coords.x - begin.x] *= 0.9;
+ }
+
+ glm::ivec2 best_pos(0);
+ double best_rating = -1.0;
+
+ for (int y = begin.y; y < end.y; ++y) {
+ for (int x = begin.x; x < end.x; ++x) {
+ if (rating[y - begin.y][x - begin.x] > best_rating) {
+ best_pos = glm::ivec2(x, y);
+ best_rating = rating[y - begin.y][x - begin.x];
+ }
+ }
+ }
+
+ if (best_rating) {