From a128ffaff079bb3d7297890d667536b2ca11fe11 Mon Sep 17 00:00:00 2001 From: Lola Date: Fri, 31 May 2024 17:21:37 +0200 Subject: [PATCH] Instruction --- Readme | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Readme diff --git a/Readme b/Readme new file mode 100644 index 0000000..7d7c6a2 --- /dev/null +++ b/Readme @@ -0,0 +1,107 @@ +Here is all the explanation of the code that we created/modified for the final project of OOP: + + +Implemented Click Handling: Added functionality to handle clicks on the simulation grid. Depending on the current click action, agents like Sheep, Wolf, Grass, or cell states are updated accordingly. + +Simulation Step Execution: Implemented logic to execute a single step of the simulation, applying the specified rules based on the current variant. + +Pause and Resume: Added functionality to pause and resume the simulation, allowing users to control the simulation speed. +Load and save: added load and save functionality for agents, world and rules + +The Simulator class is responsible for simulating a cellular automaton, managing the agents within the simulation, handling user interactions, and applying the rules of the simulation. Here are the responsibilities of the Simulator class: + +Simulation Management: +Runs the simulation loop (run method) that continuously updates the state of the simulation at each step. +Provides methods to start (run) and stop (stopSimu) the simulation. +Handles pausing and resuming the simulation (togglePause method). + +Agent Management: +Manages the collection of agents (ArrayList agents) representing entities in the simulation, such as Sheep, Wolves, and Grass. +Implements methods to add, remove, and retrieve agents (getAnimals method). +Handles actions related to individual agents, such as their behavior during each step of the simulation (makeStep method). + +Grid Management: +Manages the grid (field array) representing the environment where the simulation takes place. +Provides methods to retrieve the state of cells in the grid (getCell method) and update the state of cells (setCell method). +Implements functionality to generate a random initial state for the grid (generateRandom method) and load/save grid states (getSaveState, loadSaveState methods). + +User Interaction: +Handles user interactions with the simulation interface, such as clicking on cells to add agents (clickCell method) and toggling the current click action (toggleClickAction method). +Provides methods to retrieve and set the current click action (clickActionName method). + +Rule Management: +Manages the rules of the cellular automaton simulation, including loading and applying rule sets (RuleManager instance). +Implements functionality to retrieve and load rule sets (getRule, loadRule methods). + +Neighborhood Analysis: +Implements methods to analyze the neighborhood of cells in the grid, such as counting the number of alive neighbors (countAliveNeighbors method), prey neighbors (countPreyNeighbors method), and predator neighbors (countPredatorNeighbors method). + +Border Handling: +Handles border conditions, such as looping borders (loopingBorder flag), which determines whether cells on the edge of the grid wrap around to the opposite edge. + +Simulation Speed: +Allows adjusting the speed of the simulation (loopDelay variable), controlling the delay between simulation steps. + +1. Rules Save File: + +Description: The rules save file stores the ruleset used for the cellular automaton simulation. It specifies how cells evolve based on their neighbors. +How to Create: To create interesting patterns using different rulesets, you can experiment with variations of Conway's Game of Life rules or explore custom rulesets. For example, altering the survival and birth conditions can lead to different patterns, such as gliders, oscillators, and stable structures. Some interesting rulesets to try include HighLife, replicator, and seeds. +2. World States Save File: + +Description: The world states save file stores the current state of the grid in the cellular automaton simulation. It represents the arrangement of cells, including living and dead cells. +How to Create: To create interesting patterns in the world state, you can manually design specific configurations of living cells or use predefined patterns. Some classic patterns to try include gliders, blinkers, spaceships, and still lifes. Experimenting with different initial configurations can lead to the emergence of complex behaviors and evolving structures over time. +3.Agent Populations Save File: + +Description: The agent populations save file stores the positions and types of agents (such as Sheep, Wolves, and Grass) in the simulation. It represents the ecosystem dynamics within the cellular automaton. +How to Create: To create interesting patterns in agent populations, you can manipulate the initial distribution of agents and their interactions. For example, introducing predator-prey dynamics between Wolves and Sheep can lead to cyclic population oscillations. Similarly, altering the distribution of Grass can affect the carrying capacity of the environment and influence population dynamics. Experimenting with different agent densities, spatial arrangements, and behavioral rules can result in emergent patterns of cooperation, competition, and ecological stability. + + +***Other Classes**** +Sheep.java +Description: Represents sheep agents in the simulation. +Functionality: Handles sheep behavior such as eating grass, moving randomly, and determining lifespan. +Wolf.java +Description: Represents wolf agents in the simulation. +Functionality: Implements wolf behavior such as hunting sheep, moving randomly, and managing hunger levels. +Grass.java +Description: Represents grass agents in the simulation. +Functionality: Defines grass behavior such as being eaten by sheep and not affecting other agents. +ClickAction.java +Description: Enumerates the possible click actions in the simulation. +Functionality: Allows switching between different actions for clicking on the simulation grid, such as adding agents or modifying cell states. + + + +RuleManager.java +Description: Manages the rules of the simulation variants. +Functionality: Allows resetting rules to defaults, loading custom rules from a file, and determining the current simulation variant. +The isStandardLife, isHighLife, isPreyPredatorModel, and isMixingPopulations methods in the RuleManager class are used to check if the loaded rules match specific variants of cellular automata. Here's a detailed description of each: + +isStandardLife Method: +Purpose: This method checks if the loaded rules match the standard Life variant. +Rules: In standard Life, cells survive with 2 or 3 neighbors and give birth with 3 neighbors. +Implementation: It compares the fieldSurviveValues list with the list [2, 3] and the fieldBirthValues list with the list [3]. +Return Value: Returns true if the loaded rules match the standard Life variant; otherwise, returns false. + +isHighLife Method: +Purpose: This method checks if the loaded rules match the HighLife variant. +Rules: In HighLife, cells survive with 2 or 3 neighbors and give birth with 3 or 6 neighbors. +Implementation: It compares the fieldSurviveValues list with the list [2, 3] and the fieldBirthValues list with the list [3, 6]. +Return Value: Returns true if the loaded rules match the HighLife variant; otherwise, returns false. + +isPreyPredatorModel Method: +Purpose: This method checks if the loaded rules match the Prey/Predator Model variant. +Rules: In the Prey/Predator Model, prey cells survive with 2 or 3 neighbors and give birth with 3 neighbors. Predator cells survive with 1 to 4 neighbors. +Implementation: It checks if the survival and birth rules for both prey and predator cells match the specified conditions. +Return Value: Returns true if the loaded rules match the Prey/Predator Model variant; otherwise, returns false. + +isMixingPopulations Method: +Purpose: This method checks if the loaded rules match the Mixing Populations variant. +Rules: In Mixing Populations, each cell that is "born" inherits the dominant type of its three living neighbors. +Implementation: It checks if the birth rule matches the condition where a cell is born with 3 neighbors. +Return Value: Returns true if the loaded rules match the Mixing Populations variant; otherwise, returns false. + +If you have any question you can send us an email on the ecam mail. +jules.monin@ecam.com +alexis.hatton@ecam.com +lola.georges@ecam.com \ No newline at end of file