diff --git a/MyIsland/MyIsland.iml b/MyIsland/MyIsland.iml deleted file mode 100644 index 9465dd8..0000000 --- a/MyIsland/MyIsland.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/MyIsland/out/production/MyIsland/myisland/MyIsland.class b/MyIsland/out/production/MyIsland/myisland/MyIsland.class deleted file mode 100644 index 98de4f6..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/MyIsland.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Boar.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Boar.class deleted file mode 100644 index ba68dd9..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Boar.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Buffalo.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Buffalo.class deleted file mode 100644 index c136427..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Buffalo.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Caterpillar.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Caterpillar.class deleted file mode 100644 index 1f35f1a..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Caterpillar.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Deer.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Deer.class deleted file mode 100644 index 655aee4..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Deer.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Duck.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Duck.class deleted file mode 100644 index 81e1fe6..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Duck.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Goat.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Goat.class deleted file mode 100644 index bb8d524..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Goat.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Horse.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Horse.class deleted file mode 100644 index a663d61..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Horse.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Mouse.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Mouse.class deleted file mode 100644 index 2929db3..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Mouse.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Rabbit.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Rabbit.class deleted file mode 100644 index ba7a8f5..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Rabbit.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Sheep.class b/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Sheep.class deleted file mode 100644 index 35227b4..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/herbivores/Sheep.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/predators/Bear.class b/MyIsland/out/production/MyIsland/myisland/animals/predators/Bear.class deleted file mode 100644 index e8f1b43..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/predators/Bear.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/predators/Boa.class b/MyIsland/out/production/MyIsland/myisland/animals/predators/Boa.class deleted file mode 100644 index 6f3f969..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/predators/Boa.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/predators/Eagle.class b/MyIsland/out/production/MyIsland/myisland/animals/predators/Eagle.class deleted file mode 100644 index 5adb72f..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/predators/Eagle.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/predators/Fox.class b/MyIsland/out/production/MyIsland/myisland/animals/predators/Fox.class deleted file mode 100644 index 08585fc..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/predators/Fox.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/animals/predators/Wolf.class b/MyIsland/out/production/MyIsland/myisland/animals/predators/Wolf.class deleted file mode 100644 index 694dc21..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/animals/predators/Wolf.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/config/Settings.class b/MyIsland/out/production/MyIsland/myisland/config/Settings.class deleted file mode 100644 index c2c6a2b..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/config/Settings.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/core/Island.class b/MyIsland/out/production/MyIsland/myisland/core/Island.class deleted file mode 100644 index 88e971a..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/core/Island.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/core/Location.class b/MyIsland/out/production/MyIsland/myisland/core/Location.class deleted file mode 100644 index e5dab6e..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/core/Location.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/core/TranslationService.class b/MyIsland/out/production/MyIsland/myisland/core/TranslationService.class deleted file mode 100644 index a0606e8..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/core/TranslationService.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/entities/Animal.class b/MyIsland/out/production/MyIsland/myisland/entities/Animal.class deleted file mode 100644 index b3af65c..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/entities/Animal.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/entities/Entity.class b/MyIsland/out/production/MyIsland/myisland/entities/Entity.class deleted file mode 100644 index 683fddc..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/entities/Entity.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/entities/Herbivore.class b/MyIsland/out/production/MyIsland/myisland/entities/Herbivore.class deleted file mode 100644 index 452545c..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/entities/Herbivore.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/entities/Plant.class b/MyIsland/out/production/MyIsland/myisland/entities/Plant.class deleted file mode 100644 index 8c0a259..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/entities/Plant.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/entities/Predator.class b/MyIsland/out/production/MyIsland/myisland/entities/Predator.class deleted file mode 100644 index 42fb522..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/entities/Predator.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/plants/BerryBush.class b/MyIsland/out/production/MyIsland/myisland/plants/BerryBush.class deleted file mode 100644 index da38ba0..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/plants/BerryBush.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/plants/Grass.class b/MyIsland/out/production/MyIsland/myisland/plants/Grass.class deleted file mode 100644 index 7208855..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/plants/Grass.class and /dev/null differ diff --git a/MyIsland/out/production/MyIsland/myisland/plants/Tree.class b/MyIsland/out/production/MyIsland/myisland/plants/Tree.class deleted file mode 100644 index b9fed21..0000000 Binary files a/MyIsland/out/production/MyIsland/myisland/plants/Tree.class and /dev/null differ diff --git a/MyIsland/src/myisland/MyIsland.java b/MyIsland/src/myisland/MyIsland.java deleted file mode 100644 index 2e3f35f..0000000 --- a/MyIsland/src/myisland/MyIsland.java +++ /dev/null @@ -1,11 +0,0 @@ -package myisland; - -import myisland.core.Island; - -public class MyIsland { - public static void main(String[] args) { - System.out.println("Работу выполнил студент группы 3ИСИП522, Яцук Кирилл."); - Island island = new Island(30, 15); - island.initialize(); - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Boar.java b/MyIsland/src/myisland/animals/herbivores/Boar.java deleted file mode 100644 index 5ad5a4f..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Boar.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Boar extends Herbivore { - public Boar() { - weight = 400; - maxPerCell = 50; - maxSpeed = 2; - foodRequired = 50; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Buffalo.java b/MyIsland/src/myisland/animals/herbivores/Buffalo.java deleted file mode 100644 index 515752b..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Buffalo.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Buffalo extends Herbivore { - public Buffalo() { - weight = 700; - maxPerCell = 10; - maxSpeed = 3; - foodRequired = 100; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Caterpillar.java b/MyIsland/src/myisland/animals/herbivores/Caterpillar.java deleted file mode 100644 index 6212d01..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Caterpillar.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Caterpillar extends Herbivore { - public Caterpillar() { - weight = 0.01; - maxPerCell = 1000; - maxSpeed = 0; - foodRequired = 0.001; - satiety = 0; - canCrossRiver = false; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Deer.java b/MyIsland/src/myisland/animals/herbivores/Deer.java deleted file mode 100644 index a32bde5..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Deer.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Deer extends Herbivore { - public Deer() { - weight = 300; - maxPerCell = 20; - maxSpeed = 4; - foodRequired = 50; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Duck.java b/MyIsland/src/myisland/animals/herbivores/Duck.java deleted file mode 100644 index f3fde42..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Duck.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Duck extends Herbivore { - public Duck() { - weight = 1; - maxPerCell = 200; - maxSpeed = 4; - foodRequired = 0.15; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Goat.java b/MyIsland/src/myisland/animals/herbivores/Goat.java deleted file mode 100644 index fa80543..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Goat.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Goat extends Herbivore { - public Goat() { - weight = 60; - maxPerCell = 140; - maxSpeed = 3; - foodRequired = 10; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Horse.java b/MyIsland/src/myisland/animals/herbivores/Horse.java deleted file mode 100644 index 0246c80..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Horse.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Horse extends Herbivore { - public Horse() { - weight = 400; - maxPerCell = 20; - maxSpeed = 4; - foodRequired = 60; - satiety = foodRequired * 0.7; - canCrossRiver = false; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Mouse.java b/MyIsland/src/myisland/animals/herbivores/Mouse.java deleted file mode 100644 index a2c2746..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Mouse.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Mouse extends Herbivore { - public Mouse() { - weight = 0.05; - maxPerCell = 500; - maxSpeed = 1; - foodRequired = 0.01; - satiety = foodRequired * 0.7; - canCrossRiver = false; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Rabbit.java b/MyIsland/src/myisland/animals/herbivores/Rabbit.java deleted file mode 100644 index 18dc05a..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Rabbit.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Rabbit extends Herbivore { - public Rabbit() { - weight = 2; - maxPerCell = 150; - maxSpeed = 2; - foodRequired = 0.45; - satiety = foodRequired * 0.7; - canCrossRiver = false; - } -} diff --git a/MyIsland/src/myisland/animals/herbivores/Sheep.java b/MyIsland/src/myisland/animals/herbivores/Sheep.java deleted file mode 100644 index 9a5d09b..0000000 --- a/MyIsland/src/myisland/animals/herbivores/Sheep.java +++ /dev/null @@ -1,14 +0,0 @@ -package myisland.animals.herbivores; - -import myisland.entities.Herbivore; - -public class Sheep extends Herbivore { - public Sheep() { - weight = 70; - maxPerCell = 140; - maxSpeed = 3; - foodRequired = 15; - satiety = foodRequired * 0.7; - canCrossRiver = false; - } -} diff --git a/MyIsland/src/myisland/animals/predators/Bear.java b/MyIsland/src/myisland/animals/predators/Bear.java deleted file mode 100644 index 5fda03f..0000000 --- a/MyIsland/src/myisland/animals/predators/Bear.java +++ /dev/null @@ -1,28 +0,0 @@ -package myisland.animals.predators; -import myisland.entities.Animal; - -import myisland.entities.Predator; - -public class Bear extends Predator { - public Bear() { - weight = 500; - maxPerCell = 5; - maxSpeed = 2; - foodRequired = 80; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } - - @Override - protected double getEatingProbability(Animal prey) { - return switch (prey.getClass().getSimpleName()) { - case "Wolf" -> 0.8; - case "Rabbit" -> 0.8; - case "Mouse" -> 0.9; - case "Goat" -> 0.7; - case "Sheep" -> 0.7; - case "Boar" -> 0.5; - default -> 0.0; - }; - } -} diff --git a/MyIsland/src/myisland/animals/predators/Boa.java b/MyIsland/src/myisland/animals/predators/Boa.java deleted file mode 100644 index 3b3b9e9..0000000 --- a/MyIsland/src/myisland/animals/predators/Boa.java +++ /dev/null @@ -1,25 +0,0 @@ -package myisland.animals.predators; -import myisland.entities.Animal; - -import myisland.entities.Predator; - -public class Boa extends Predator { - public Boa() { - weight = 15; - maxPerCell = 30; - maxSpeed = 1; - foodRequired = 3; - satiety = foodRequired * 0.7; - canCrossRiver = false; - } - - @Override - protected double getEatingProbability(Animal prey) { - return switch (prey.getClass().getSimpleName()) { - case "Rabbit" -> 0.2; - case "Mouse" -> 0.4; - case "Duck" -> 0.1; - default -> 0.0; - }; - } -} diff --git a/MyIsland/src/myisland/animals/predators/Eagle.java b/MyIsland/src/myisland/animals/predators/Eagle.java deleted file mode 100644 index cb2fbc8..0000000 --- a/MyIsland/src/myisland/animals/predators/Eagle.java +++ /dev/null @@ -1,23 +0,0 @@ -package myisland.animals.predators; -import myisland.entities.Animal; -import myisland.entities.Predator; - -public class Eagle extends Predator { - public Eagle() { - weight = 6; - maxPerCell = 20; - maxSpeed = 3; - foodRequired = 1; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } - - @Override - protected double getEatingProbability(Animal prey) { - return switch (prey.getClass().getSimpleName()) { - case "Rabbit", "Mouse" -> 0.9; - case "Duck" -> 0.8; - default -> 0.0; - }; - } -} diff --git a/MyIsland/src/myisland/animals/predators/Fox.java b/MyIsland/src/myisland/animals/predators/Fox.java deleted file mode 100644 index 4726519..0000000 --- a/MyIsland/src/myisland/animals/predators/Fox.java +++ /dev/null @@ -1,26 +0,0 @@ -package myisland.animals.predators; -import myisland.entities.Animal; - -import myisland.entities.Predator; - -public class Fox extends Predator { - public Fox() { - weight = 8; - maxPerCell = 30; - maxSpeed = 2; - foodRequired = 2; - satiety = foodRequired * 0.7; - canCrossRiver = false; - } - - @Override - protected double getEatingProbability(Animal prey) { - return switch (prey.getClass().getSimpleName()) { - case "Rabbit" -> 0.7; - case "Mouse" -> 0.9; - case "Duck" -> 0.6; - case "Caterpillar" -> 0.4; - default -> 0.0; - }; - } -} diff --git a/MyIsland/src/myisland/animals/predators/Wolf.java b/MyIsland/src/myisland/animals/predators/Wolf.java deleted file mode 100644 index fc950b2..0000000 --- a/MyIsland/src/myisland/animals/predators/Wolf.java +++ /dev/null @@ -1,51 +0,0 @@ -package myisland.animals.predators; -import myisland.entities.Animal; - -import myisland.core.Location; -import myisland.entities.Predator; - -public class Wolf extends Predator { - public Wolf() { - weight = 50; - maxPerCell = 30; - maxSpeed = 3; - foodRequired = 8; - satiety = foodRequired * 0.7; - canCrossRiver = true; - } - - // Стадное поведение - @Override - public void move() { - int wolfCount = (int) location.getAnimals().stream() - .filter(a -> a instanceof Wolf) - .count(); - int steps = wolfCount > 1 ? - location.getIsland().getRandom().nextInt(maxSpeed - 1) + 1 : - location.getIsland().getRandom().nextInt(maxSpeed) + 1; - - for (int i = 0; i < steps; i++) { - int dx = location.getIsland().getRandom().nextInt(3) - 1; - int dy = location.getIsland().getRandom().nextInt(3) - 1; - Location newLocation = location.getIsland().getRelativeLocation(location, dx, dy); - if (newLocation != null && canMoveTo(newLocation) && newLocation.canAddAnimal(this.getClass())) { - location.removeAnimal(this); - newLocation.addAnimal(this); - location = newLocation; - break; - } - } - } - - @Override - protected double getEatingProbability(Animal prey) { - return switch (prey.getClass().getSimpleName()) { - case "Rabbit" -> 0.6; - case "Mouse" -> 0.8; - case "Goat" -> 0.6; - case "Sheep" -> 0.7; - case "Duck" -> 0.4; - default -> 0.0; - }; - } -} diff --git a/MyIsland/src/myisland/config/Settings.java b/MyIsland/src/myisland/config/Settings.java deleted file mode 100644 index 8d8ce54..0000000 --- a/MyIsland/src/myisland/config/Settings.java +++ /dev/null @@ -1,17 +0,0 @@ -package myisland.config; - -public class Settings { - // Размеры острова - public static final int ISLAND_WIDTH = 30; - public static final int ISLAND_HEIGHT = 15; - - // Интервалы обновления (в секундах) - public static final int PLANT_GROWTH_INTERVAL = 3; // Частота роста растений - public static final int ANIMAL_ACT_INTERVAL = 2; // Частота действий животных - public static final int STATS_UPDATE_INTERVAL = 5; // Частота вывода статистики - - // Ограничения и вероятности - public static final int MAX_PLANTS_PER_CELL = 150; // Макс. растений на клетку - public static final double PLANT_GROWTH_PROBABILITY = 0.3; // Шанс роста нового растения - public static final double REPRODUCTION_PROBABILITY = 0.25; // Шанс размножения животного -} diff --git a/MyIsland/src/myisland/core/Island.java b/MyIsland/src/myisland/core/Island.java deleted file mode 100644 index 53eb5bb..0000000 --- a/MyIsland/src/myisland/core/Island.java +++ /dev/null @@ -1,223 +0,0 @@ -package myisland.core; - -import myisland.config.Settings; -import myisland.entities.Animal; -import myisland.entities.Plant; -import myisland.entities.Predator; -import myisland.entities.Herbivore; - -import java.util.*; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; - -public class Island { - // ANSI color codes - private static final String RESET = "\u001B[0m"; - private static final String RED = "\u001B[31m"; - private static final String GREEN = "\u001B[32m"; - private static final String CYAN = "\u001B[36m"; - private static final String YELLOW = "\u001B[33m"; - private static final String BLUE = "\u001B[34m"; - private static final String PURPLE = "\u001B[35m"; - private static final String WHITE = "\u001B[37m"; - private static final String BOLD = "\u001B[1m"; - - private final Location[][] locations; - private final ScheduledExecutorService scheduler; - private final ExecutorService animalExecutor; - private final Random random = new Random(); - private int simulationStep = 0; - - public Island(int width, int height) { - this.locations = new Location[width][height]; - this.scheduler = Executors.newScheduledThreadPool(3); - this.animalExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()); - initializeTerrain(); - } - - private void initializeTerrain() { - int riverX = locations.length / 2; - for (int y = 0; y < locations[0].length; y++) { - for (int x = riverX - 1; x <= riverX + 1; x++) { - if (x >= 0 && x < locations.length) { - locations[x][y] = new Location(x, y, this, true); - } - } - } - - for (int x = 0; x < locations.length; x++) { - for (int y = 0; y < locations[x].length; y++) { - if (locations[x][y] == null) { - locations[x][y] = new Location(x, y, this, false); - } - } - } - } - - public void initialize() { - System.out.println(BLUE + BOLD + "╔════════════════════════════════════════╗"); - System.out.println("║" + YELLOW + " ИНИЦИАЛИЗАЦИЯ ОСТРОВА " + BLUE + " ║"); - System.out.println("╚════════════════════════════════════════╝" + RESET); - - // Enhanced loading animation - String[] frames = new String[] { - "[ ]", - "[█ ]", - "[██ ]", - "[███ ]", - "[████ ]", - "[█████ ]", - "[██████ ]", - "[███████ ]", - "[████████ ]", - "[█████████ ]", - "[██████████]" - }; - - String[] colors = new String[] {RED, YELLOW, GREEN, CYAN, BLUE, PURPLE}; - String[] messages = new String[] { - "Создание ландшафта...", - "Посадка растений...", - "Расселение травоядных...", - "Размещение хищников...", - "Настройка экосистемы...", - "Запуск симуляции..." - }; - - for (int i = 0; i <= 100; i++) { - int frameIndex = (i * frames.length) / 100; - if (frameIndex >= frames.length) frameIndex = frames.length - 1; - - int colorIndex = (i * colors.length) / 100; - if (colorIndex >= colors.length) colorIndex = colors.length - 1; - - int msgIndex = (i * messages.length) / 100; - if (msgIndex >= messages.length) msgIndex = messages.length - 1; - - System.out.print("\r" + colors[colorIndex] + frames[frameIndex] + " " + messages[msgIndex] + - " (" + i + "%)" + RESET); - - try { - Thread.sleep(30 + random.nextInt(40)); // Variable speed for more natural feel - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - System.out.println("\n" + GREEN + BOLD + "✓ Готово! Остров успешно инициализирован!" + RESET); - - // Initialize plants and animals - for (Location[] row : locations) { - for (Location location : row) { - for (int i = 0; i < random.nextInt(5) + 3; i++) { - location.addPlant(Plant.createRandomPlant()); - } - populateWithAnimals(location); - } - } - - scheduler.scheduleAtFixedRate(this::growPlants, 0, Settings.PLANT_GROWTH_INTERVAL, TimeUnit.SECONDS); - scheduler.scheduleAtFixedRate(this::processAnimals, 0, Settings.ANIMAL_ACT_INTERVAL, TimeUnit.SECONDS); - scheduler.scheduleAtFixedRate(this::printStatistics, 0, Settings.STATS_UPDATE_INTERVAL, TimeUnit.SECONDS); - } - - private void populateWithAnimals(Location location) { - for (int i = 0; i < random.nextInt(3); i++) { - location.addAnimal(Herbivore.createRandomHerbivore()); - } - if (random.nextDouble() < 0.3) { - location.addAnimal(Predator.createRandomPredator()); - } - } - - private void growPlants() { - for (Location[] row : locations) { - for (Location location : row) { - if (random.nextDouble() < Settings.PLANT_GROWTH_PROBABILITY) { - location.growPlants(); - } - } - } - } - - private void processAnimals() { - for (Location[] row : locations) { - for (Location location : row) { - animalExecutor.submit(location::processAnimals); - } - } - } - - private void printStatistics() { - simulationStep++; - - // Собираем статистику - Map, AtomicInteger> herbivoreStats = new TreeMap<>(Comparator.comparing(Class::getSimpleName)); - Map, AtomicInteger> predatorStats = new TreeMap<>(Comparator.comparing(Class::getSimpleName)); - Map, AtomicInteger> plantStats = new TreeMap<>(Comparator.comparing(Class::getSimpleName)); - - int totalAnimals = 0; - int totalPlants = 0; - - for (Location[] row : locations) { - for (Location location : row) { - totalPlants += location.getPlants().size(); - location.getPlants().forEach(plant -> - plantStats.computeIfAbsent(plant.getClass(), k -> new AtomicInteger()).incrementAndGet()); - - totalAnimals += location.getAnimals().size(); - location.getAnimals().forEach(animal -> { - if (animal instanceof Predator) { - predatorStats.computeIfAbsent(animal.getClass(), k -> new AtomicInteger()).incrementAndGet(); - } else { - herbivoreStats.computeIfAbsent(animal.getClass(), k -> new AtomicInteger()).incrementAndGet(); - } - }); - } - } - - // Форматированный вывод с цветами - System.out.println("\n" + BLUE + BOLD + "╔════════════════════════════════════════╗" + RESET); - System.out.printf(BLUE + BOLD + "║ " + YELLOW + "%-38s " + BLUE + "║\n" + RESET, "=== Шаг " + simulationStep + " ==="); - System.out.println(BLUE + BOLD + "╠════════════════════════════════════════╣" + RESET); - System.out.printf(BLUE + BOLD + "║ " + WHITE + "%-22s " + YELLOW + "%15d " + BLUE + "║\n" + RESET, - "Всего животных:", totalAnimals); - System.out.printf(BLUE + BOLD + "║ " + WHITE + "%-22s " + YELLOW + "%15d " + BLUE + "║\n" + RESET, - "Всего растений:", totalPlants); - System.out.println(BLUE + BOLD + "╠════════════════════════════════════════╣" + RESET); - - printCategory("ХИЩНИКИ", predatorStats, RED); - printCategory("ТРАВОЯДНЫЕ", herbivoreStats, GREEN); - printCategory("РАСТЕНИЯ", plantStats, CYAN); - - System.out.println(BLUE + BOLD + "╚════════════════════════════════════════╝" + RESET); - } - - private void printCategory(String title, Map, AtomicInteger> stats, String color) { - System.out.printf(BLUE + BOLD + "║ " + color + BOLD + "%-38s " + BLUE + "║\n" + RESET, ">>> " + title + " <<<"); - if (stats.isEmpty()) { - System.out.printf(BLUE + BOLD + "║ " + WHITE + "%-38s " + BLUE + "║\n" + RESET, " Нет данных"); - } else { - stats.forEach((clazz, count) -> { - String className = clazz.getSimpleName(); - String translatedName = TranslationService.translateEntity(className); - System.out.printf(BLUE + BOLD + "║ " + color + "%-26s " + YELLOW + "%11d " + BLUE + "║\n" + RESET, - " " + translatedName, count.get()); - }); - } - - } - - public Location getRelativeLocation(Location current, int dx, int dy) { - int newX = current.getX() + dx; - int newY = current.getY() + dy; - if (newX >= 0 && newX < locations.length && newY >= 0 && newY < locations[0].length) { - return locations[newX][newY]; - } - return null; - } - - public Random getRandom() { - return random; - } -} \ No newline at end of file diff --git a/MyIsland/src/myisland/core/Location.java b/MyIsland/src/myisland/core/Location.java deleted file mode 100644 index 4f04c47..0000000 --- a/MyIsland/src/myisland/core/Location.java +++ /dev/null @@ -1,99 +0,0 @@ -package myisland.core; - -import myisland.config.Settings; -import myisland.entities.Animal; -import myisland.entities.Plant; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -public class Location { - private final int x; - private final int y; - private final Island island; - private final boolean hasRiver; - - private final List animals = new CopyOnWriteArrayList<>(); - private final List plants = new CopyOnWriteArrayList<>(); - - public Location(int x, int y, Island island, boolean hasRiver) { - this.x = x; - this.y = y; - this.island = island; - this.hasRiver = hasRiver; - } - - public int getX() { - return x; - } - - public int getY() { - return y; - } - - public Island getIsland() { - return island; - } - - public boolean hasRiver() { - return hasRiver; - } - - public List getAnimals() { - return Collections.unmodifiableList(animals); - } - - public List getPlants() { - return Collections.unmodifiableList(plants); - } - - public void processAnimals() { - for (Animal animal : new CopyOnWriteArrayList<>(animals)) { - animal.act(); - if (animal.getSatiety() <= 0) { - animals.remove(animal); - } - } - } - - public void growPlants() { - if (plants.size() < Settings.MAX_PLANTS_PER_CELL) { - plants.add(Plant.createRandomPlant()); - } - } - - public void addAnimal(Animal animal) { - if (canAddAnimal(animal.getClass())) { - animal.setLocation(this); - animals.add(animal); - } - } - - public void removeAnimal(Animal animal) { - animals.remove(animal); - } - - public void addPlant(Plant plant) { - if (plants.size() < Settings.MAX_PLANTS_PER_CELL) { - plants.add(plant); - } - } - - public void removePlant(Plant plant) { - plants.remove(plant); - } - - public boolean canAddAnimal(Class animalClass) { - long count = animals.stream() - .filter(a -> a.getClass().equals(animalClass)) - .count(); - - try { - Animal temp = animalClass.getDeclaredConstructor().newInstance(); - return count < temp.getMaxPerCell(); - } catch (ReflectiveOperationException e) { - return false; - } - } -} diff --git a/MyIsland/src/myisland/core/TranslationService.java b/MyIsland/src/myisland/core/TranslationService.java deleted file mode 100644 index 4b2dfe4..0000000 --- a/MyIsland/src/myisland/core/TranslationService.java +++ /dev/null @@ -1,48 +0,0 @@ -package myisland.core; - -import java.util.Map; -import java.util.HashMap; - -public class TranslationService { - private static final Map ANIMAL_TRANSLATIONS = new HashMap<>(); - private static final Map PLANT_TRANSLATIONS = new HashMap<>(); - - static { - // Инициализация переводов для животных - ANIMAL_TRANSLATIONS.put("Bear", "Медведь"); - ANIMAL_TRANSLATIONS.put("Boa", "Удав"); - ANIMAL_TRANSLATIONS.put("Eagle", "Орел"); - ANIMAL_TRANSLATIONS.put("Fox", "Лиса"); - ANIMAL_TRANSLATIONS.put("Wolf", "Волк"); - ANIMAL_TRANSLATIONS.put("Boar", "Кабан"); - ANIMAL_TRANSLATIONS.put("Buffalo", "Буйвол"); - ANIMAL_TRANSLATIONS.put("Deer", "Олень"); - ANIMAL_TRANSLATIONS.put("Duck", "Утка"); - ANIMAL_TRANSLATIONS.put("Goat", "Коза"); - ANIMAL_TRANSLATIONS.put("Horse", "Лошадь"); - ANIMAL_TRANSLATIONS.put("Mouse", "Мышь"); - ANIMAL_TRANSLATIONS.put("Rabbit", "Кролик"); - ANIMAL_TRANSLATIONS.put("Sheep", "Овца"); - - // Инициализация переводов для растений - PLANT_TRANSLATIONS.put("BerryBush", "Ягодный куст"); - PLANT_TRANSLATIONS.put("Grass", "Трава"); - PLANT_TRANSLATIONS.put("Tree", "Дерево"); - } - - public static String translateAnimal(String englishName) { - return ANIMAL_TRANSLATIONS.getOrDefault(englishName, englishName); - } - - public static String translatePlant(String englishName) { - return PLANT_TRANSLATIONS.getOrDefault(englishName, englishName); - } - - public static String translateEntity(String englishName) { - String translation = ANIMAL_TRANSLATIONS.get(englishName); - if (translation == null) { - translation = PLANT_TRANSLATIONS.get(englishName); - } - return translation != null ? translation : englishName; - } -} \ No newline at end of file diff --git a/MyIsland/src/myisland/entities/Animal.java b/MyIsland/src/myisland/entities/Animal.java deleted file mode 100644 index 5a223fe..0000000 --- a/MyIsland/src/myisland/entities/Animal.java +++ /dev/null @@ -1,110 +0,0 @@ -package myisland.entities; - -import myisland.core.Location; -import myisland.config.Settings; - -import java.util.ArrayList; -import java.util.Random; - -public abstract class Animal extends Entity { - protected double weight; - protected int maxPerCell; - protected int maxSpeed; - protected double foodRequired; - protected double satiety; - protected double satietyLossRate = 0.05; - protected boolean canCrossRiver = false; - - public abstract boolean canEat(Animal animal); - public abstract boolean canEat(Plant plant); - - @Override - public void act() { - eat(); - move(); - reproduce(); - loseSatiety(); - } - - public void eat() { - if (this instanceof Predator) { - for (Animal other : new ArrayList<>(location.getAnimals())) { - if (other != this && canEat(other)) { - if (location.getIsland().getRandom().nextDouble() < getEatingProbability(other)) { - location.removeAnimal(other); - satiety = Math.min(satiety + other.getWeight(), foodRequired * 1.5); - return; - } - } - } - } - - for (Plant plant : new ArrayList<>(location.getPlants())) { - if (canEat(plant)) { - location.removePlant(plant); - satiety = Math.min(satiety + plant.getWeight(), foodRequired * 1.5); - return; - } - } - } - - protected double getEatingProbability(Animal prey) { - return 0.0; // Переопределяется в конкретных классах - } - - public void move() { - if (maxSpeed == 0) return; - int steps = location.getIsland().getRandom().nextInt(maxSpeed) + 1; - for (int i = 0; i < steps; i++) { - int dx = location.getIsland().getRandom().nextInt(3) - 1; - int dy = location.getIsland().getRandom().nextInt(3) - 1; - Location newLocation = location.getIsland().getRelativeLocation(location, dx, dy); - if (newLocation != null && canMoveTo(newLocation) && newLocation.canAddAnimal(this.getClass())) { - location.removeAnimal(this); - newLocation.addAnimal(this); - location = newLocation; - break; - } - } - } - - protected boolean canMoveTo(Location newLocation) { - return !newLocation.hasRiver() || canCrossRiver; - } - - public void reproduce() { - if (satiety < foodRequired * 0.7) return; - if (location.getIsland().getRandom().nextDouble() > Settings.REPRODUCTION_PROBABILITY) return; - - for (Animal other : location.getAnimals()) { - if (other != this && other.getClass() == this.getClass()) { - try { - Animal offspring = this.getClass().getDeclaredConstructor().newInstance(); - offspring.satiety = satiety * 0.3; - location.addAnimal(offspring); - satiety *= 0.7; - return; - } catch (ReflectiveOperationException e) { - System.err.println("Ошибка при создании потомка: " + e.getMessage()); - } - } - } - } - - public void loseSatiety() { - satiety -= satietyLossRate; - if (satiety < 0) satiety = 0; - } - - public double getWeight() { - return weight; - } - - public int getMaxPerCell() { - return maxPerCell; - } - - public double getSatiety() { - return satiety; - } -} diff --git a/MyIsland/src/myisland/entities/Entity.java b/MyIsland/src/myisland/entities/Entity.java deleted file mode 100644 index 0993306..0000000 --- a/MyIsland/src/myisland/entities/Entity.java +++ /dev/null @@ -1,17 +0,0 @@ -package myisland.entities; - -import myisland.core.Location; - -public abstract class Entity { - protected Location location; - - public abstract void act(); - - public void setLocation(Location location) { - this.location = location; - } - - public Location getLocation() { - return location; - } -} diff --git a/MyIsland/src/myisland/entities/Herbivore.java b/MyIsland/src/myisland/entities/Herbivore.java deleted file mode 100644 index 72d8f98..0000000 --- a/MyIsland/src/myisland/entities/Herbivore.java +++ /dev/null @@ -1,33 +0,0 @@ -package myisland.entities; - -import myisland.animals.herbivores.*; - -import java.util.Random; - -public abstract class Herbivore extends Animal { - - public static Herbivore createRandomHerbivore() { - Random random = new Random(); - double roll = random.nextDouble(); - if (roll < 0.15) return new Horse(); - else if (roll < 0.3) return new Deer(); - else if (roll < 0.5) return new Rabbit(); - else if (roll < 0.7) return new Mouse(); - else if (roll < 0.8) return new Goat(); - else if (roll < 0.9) return new Sheep(); - else if (roll < 0.95) return new Boar(); - else if (roll < 0.97) return new Buffalo(); - else if (roll < 0.99) return new Duck(); - else return new Caterpillar(); - } - - @Override - public boolean canEat(Animal animal) { - return (this instanceof Duck && animal instanceof Caterpillar); - } - - @Override - public boolean canEat(Plant plant) { - return true; - } -} diff --git a/MyIsland/src/myisland/entities/Plant.java b/MyIsland/src/myisland/entities/Plant.java deleted file mode 100644 index d27ade4..0000000 --- a/MyIsland/src/myisland/entities/Plant.java +++ /dev/null @@ -1,26 +0,0 @@ -package myisland.entities; - -import myisland.plants.*; - -import java.util.Random; - -public abstract class Plant extends Entity { - protected double weight; - - public static Plant createRandomPlant() { - Random random = new Random(); - double roll = random.nextDouble(); - if (roll < 0.6) return new Grass(); - else if (roll < 0.9) return new BerryBush(); - else return new Tree(); - } - - @Override - public void act() { - weight += 0.01; - } - - public double getWeight() { - return weight; - } -} diff --git a/MyIsland/src/myisland/entities/Predator.java b/MyIsland/src/myisland/entities/Predator.java deleted file mode 100644 index 6fb4b50..0000000 --- a/MyIsland/src/myisland/entities/Predator.java +++ /dev/null @@ -1,28 +0,0 @@ -package myisland.entities; - -import myisland.animals.predators.*; - -import java.util.Random; - -public abstract class Predator extends Animal { - - public static Predator createRandomPredator() { - Random random = new Random(); - double roll = random.nextDouble(); - if (roll < 0.2) return new Wolf(); - else if (roll < 0.4) return new Boa(); - else if (roll < 0.7) return new Fox(); - else if (roll < 0.85) return new Bear(); - else return new Eagle(); - } - - @Override - public boolean canEat(Plant plant) { - return false; - } - - @Override - public boolean canEat(Animal animal) { - return !(animal instanceof Predator); - } -} diff --git a/MyIsland/src/myisland/plants/BerryBush.java b/MyIsland/src/myisland/plants/BerryBush.java deleted file mode 100644 index b927b9f..0000000 --- a/MyIsland/src/myisland/plants/BerryBush.java +++ /dev/null @@ -1,9 +0,0 @@ -package myisland.plants; - -import myisland.entities.Plant; - -public class BerryBush extends Plant { - public BerryBush() { - this.weight = 1.5; - } -} diff --git a/MyIsland/src/myisland/plants/Grass.java b/MyIsland/src/myisland/plants/Grass.java deleted file mode 100644 index 4a544ce..0000000 --- a/MyIsland/src/myisland/plants/Grass.java +++ /dev/null @@ -1,9 +0,0 @@ -package myisland.plants; - -import myisland.entities.Plant; - -public class Grass extends Plant { - public Grass() { - this.weight = 0.5; - } -} diff --git a/MyIsland/src/myisland/plants/Tree.java b/MyIsland/src/myisland/plants/Tree.java deleted file mode 100644 index 34d4d25..0000000 --- a/MyIsland/src/myisland/plants/Tree.java +++ /dev/null @@ -1,9 +0,0 @@ -package myisland.plants; - -import myisland.entities.Plant; - -public class Tree extends Plant { - public Tree() { - this.weight = 3.0; - } -} diff --git a/QRApp.apk b/QRApp.apk new file mode 100644 index 0000000..dcdbef2 Binary files /dev/null and b/QRApp.apk differ diff --git a/QRapp.rar b/QRapp.rar new file mode 100644 index 0000000..5427f9d Binary files /dev/null and b/QRapp.rar differ diff --git a/Rcalc.apk b/Rcalc.apk new file mode 100644 index 0000000..02a742a Binary files /dev/null and b/Rcalc.apk differ diff --git a/Rcalc.rar b/Rcalc.rar new file mode 100644 index 0000000..1ab4f08 Binary files /dev/null and b/Rcalc.rar differ