From 9ebd7c5bcba9b417b4cbc70b5a7df7c501b03619 Mon Sep 17 00:00:00 2001 From: shinedday <shinedday@gmail.com> Date: Mon, 17 May 2021 17:19:43 +0200 Subject: [PATCH] Fuse all ant example into 1 --- ant_example/__init__.py | 0 ant_example/agent/__init__.py | 0 .../agent/communicating.py | 7 +- ant_example/agent/proof_of_concept.py | 45 ++++++++ ant_example/agent/v1.py | 47 +++++++++ ant_example/agent/v2.py | 57 ++++++++++ ant_example/antExample.py | 50 ++++----- ant_example/antHillExample.py | 25 ++++- ant_example/antsLaunchExample.py | 12 ++- .../comportement.txt | 2 +- ant_example/controleurAntsExample.py | 7 +- ant_example/worldExample.py | 2 +- ant_example_2_phases/antExample.py | 80 -------------- ant_example_2_phases/antHillExample.py | 16 --- ant_example_2_phases/antsLaunchExample.py | 25 ----- ant_example_2_phases/color.py | 7 -- ant_example_2_phases/controleurAntsExample.py | 42 -------- ant_example_2_phases/images/blackAnt.png | Bin 537 -> 0 bytes ant_example_2_phases/images/blueAnt.png | Bin 630 -> 0 bytes ant_example_2_phases/images/greenAnt.png | Bin 627 -> 0 bytes ant_example_2_phases/images/redAnt.png | Bin 629 -> 0 bytes ant_example_2_phases/images/yellowAnt.png | Bin 630 -> 0 bytes ant_example_2_phases/worldExample.py | 17 --- ant_examplev2/antExample.py | 98 ------------------ ant_examplev2/antHillExample.py | 16 --- ant_examplev2/antsLaunchExample.py | 25 ----- ant_examplev2/color.py | 7 -- ant_examplev2/controleurAntsExample.py | 42 -------- ant_examplev2/images/blackAnt.png | Bin 537 -> 0 bytes ant_examplev2/images/blueAnt.png | Bin 630 -> 0 bytes ant_examplev2/images/greenAnt.png | Bin 627 -> 0 bytes ant_examplev2/images/redAnt.png | Bin 629 -> 0 bytes ant_examplev2/images/yellowAnt.png | Bin 630 -> 0 bytes ant_examplev2/worldExample.py | 17 --- communicating_agent_example/antHillExample.py | 16 --- .../antsLaunchExample.py | 25 ----- communicating_agent_example/color.py | 7 -- .../controleurAntsExample.py | 42 -------- .../images/blackAnt.png | Bin 537 -> 0 bytes .../images/blueAnt.png | Bin 630 -> 0 bytes .../images/greenAnt.png | Bin 627 -> 0 bytes communicating_agent_example/images/redAnt.png | Bin 629 -> 0 bytes .../images/yellowAnt.png | Bin 630 -> 0 bytes communicating_agent_example/worldExample.py | 17 --- .../2_phases_agent_cycle/antExample.py | 77 -------------- .../2_phases_agent_cycle/antHillExample.py | 16 --- .../2_phases_agent_cycle/antsLaunchExample.py | 25 ----- .../2_phases_agent_cycle/color.py | 7 -- .../controleurAntsExample.py | 45 -------- .../2_phases_agent_cycle/images/blackAnt.png | Bin 537 -> 0 bytes .../2_phases_agent_cycle/images/blueAnt.png | Bin 630 -> 0 bytes .../2_phases_agent_cycle/images/greenAnt.png | Bin 627 -> 0 bytes .../2_phases_agent_cycle/images/redAnt.png | Bin 629 -> 0 bytes .../2_phases_agent_cycle/images/yellowAnt.png | Bin 630 -> 0 bytes .../2_phases_agent_cycle/worldExample.py | 16 --- 55 files changed, 209 insertions(+), 730 deletions(-) create mode 100644 ant_example/__init__.py create mode 100644 ant_example/agent/__init__.py rename communicating_agent_example/antExample.py => ant_example/agent/communicating.py (94%) create mode 100644 ant_example/agent/proof_of_concept.py create mode 100644 ant_example/agent/v1.py create mode 100644 ant_example/agent/v2.py rename {ant_examplev2 => ant_example}/comportement.txt (99%) delete mode 100644 ant_example_2_phases/antExample.py delete mode 100644 ant_example_2_phases/antHillExample.py delete mode 100644 ant_example_2_phases/antsLaunchExample.py delete mode 100644 ant_example_2_phases/color.py delete mode 100644 ant_example_2_phases/controleurAntsExample.py delete mode 100644 ant_example_2_phases/images/blackAnt.png delete mode 100644 ant_example_2_phases/images/blueAnt.png delete mode 100644 ant_example_2_phases/images/greenAnt.png delete mode 100644 ant_example_2_phases/images/redAnt.png delete mode 100644 ant_example_2_phases/images/yellowAnt.png delete mode 100644 ant_example_2_phases/worldExample.py delete mode 100644 ant_examplev2/antExample.py delete mode 100644 ant_examplev2/antHillExample.py delete mode 100644 ant_examplev2/antsLaunchExample.py delete mode 100644 ant_examplev2/color.py delete mode 100644 ant_examplev2/controleurAntsExample.py delete mode 100644 ant_examplev2/images/blackAnt.png delete mode 100644 ant_examplev2/images/blueAnt.png delete mode 100644 ant_examplev2/images/greenAnt.png delete mode 100644 ant_examplev2/images/redAnt.png delete mode 100644 ant_examplev2/images/yellowAnt.png delete mode 100644 ant_examplev2/worldExample.py delete mode 100644 communicating_agent_example/antHillExample.py delete mode 100644 communicating_agent_example/antsLaunchExample.py delete mode 100644 communicating_agent_example/color.py delete mode 100644 communicating_agent_example/controleurAntsExample.py delete mode 100644 communicating_agent_example/images/blackAnt.png delete mode 100644 communicating_agent_example/images/blueAnt.png delete mode 100644 communicating_agent_example/images/greenAnt.png delete mode 100644 communicating_agent_example/images/redAnt.png delete mode 100644 communicating_agent_example/images/yellowAnt.png delete mode 100644 communicating_agent_example/worldExample.py delete mode 100644 proof_of_concept/2_phases_agent_cycle/antExample.py delete mode 100644 proof_of_concept/2_phases_agent_cycle/antHillExample.py delete mode 100644 proof_of_concept/2_phases_agent_cycle/antsLaunchExample.py delete mode 100644 proof_of_concept/2_phases_agent_cycle/color.py delete mode 100644 proof_of_concept/2_phases_agent_cycle/controleurAntsExample.py delete mode 100644 proof_of_concept/2_phases_agent_cycle/images/blackAnt.png delete mode 100644 proof_of_concept/2_phases_agent_cycle/images/blueAnt.png delete mode 100644 proof_of_concept/2_phases_agent_cycle/images/greenAnt.png delete mode 100644 proof_of_concept/2_phases_agent_cycle/images/redAnt.png delete mode 100644 proof_of_concept/2_phases_agent_cycle/images/yellowAnt.png delete mode 100644 proof_of_concept/2_phases_agent_cycle/worldExample.py diff --git a/ant_example/__init__.py b/ant_example/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/ant_example/agent/__init__.py b/ant_example/agent/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/communicating_agent_example/antExample.py b/ant_example/agent/communicating.py similarity index 94% rename from communicating_agent_example/antExample.py rename to ant_example/agent/communicating.py index e3eb023..3035409 100644 --- a/communicating_agent_example/antExample.py +++ b/ant_example/agent/communicating.py @@ -6,10 +6,15 @@ from random import randint from pyAmakCore.classes.communicating_agent import CommunicatingAgent +import sys +import pathlib + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) + from color import Color -class AntExample(CommunicatingAgent): +class CommunicatingAnt(CommunicatingAgent): def __init__(self, amas: 'antHillExample', diff --git a/ant_example/agent/proof_of_concept.py b/ant_example/agent/proof_of_concept.py new file mode 100644 index 0000000..dff5f04 --- /dev/null +++ b/ant_example/agent/proof_of_concept.py @@ -0,0 +1,45 @@ +from random import randint + +import sys +import pathlib + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) + +from antExample import AntExample +from color import Color + + + +class AntTest(AntExample): + + def __init__(self, + amas: 'antHillExample', + startX: float, + startY: float + ) -> None: + super().__init__(amas, startX, startY) + self.majority_color = Color.BLACK + + def on_perceive(self) -> None: + self.reset_neighbour() + for agent in self.get_amas().get_agents(): + if self != agent: + self.add_neighbour(agent) + self.find_the_majority_color() + + def on_act(self) -> None: + # couleur + if self.majority_color != self._color: + self._color = self.majority_color + elif randint(1, 50) <= 4: + self._color = AntExample.int_to_color.get(randint(0, 4)) + + # déplacement + self.make_random_move() + + def find_the_majority_color(self) -> Color: + couleurs_voisin = [0, 0, 0, 0, 0] + for agent in self.get_neighbour(): + couleurs_voisin[AntExample.color_to_int.get(agent.get_color())] += 1 + + self.majority_color = AntExample.int_to_color.get(couleurs_voisin.index(max(couleurs_voisin))) \ No newline at end of file diff --git a/ant_example/agent/v1.py b/ant_example/agent/v1.py new file mode 100644 index 0000000..e76b41c --- /dev/null +++ b/ant_example/agent/v1.py @@ -0,0 +1,47 @@ +from random import randint + +from math import sqrt + +import sys +import pathlib + + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) + +from antExample import AntExample +from color import Color + + +class AntExampleV1(AntExample): + def __init__(self, + amas: 'antHillExample', + startX: float, + startY: float + ) -> None: + super().__init__(amas, startX, startY) + self.majority_color = Color.BLACK + + def on_perceive(self) -> None: + self.reset_neighbour() + for agent in self.get_amas().get_agents(): + length = sqrt(pow(self._dx - agent.get_dx(), 2) + pow(self._dy - agent.get_dy(), 2)) + if length < self.get_environment().field_of_view and self != agent: + self.add_neighbour(agent) + self.find_the_majority_color() + + def on_act(self) -> None: + # couleur + if self.majority_color != self._color: + self._color = self.majority_color + elif randint(1, 1000) <= 4: + self._color = AntExample.int_to_color.get(randint(0, 4)) + + # déplacement + self.make_random_move() + + def find_the_majority_color(self) -> Color: + couleurs_voisin = [0, 0, 0, 0, 0] + for agent in self.get_neighbour(): + couleurs_voisin[AntExample.color_to_int.get(agent.get_color())] += 1 + + self.majority_color = AntExample.int_to_color.get(couleurs_voisin.index(max(couleurs_voisin))) \ No newline at end of file diff --git a/ant_example/agent/v2.py b/ant_example/agent/v2.py new file mode 100644 index 0000000..f99b65f --- /dev/null +++ b/ant_example/agent/v2.py @@ -0,0 +1,57 @@ +from random import randint + +from math import sqrt + +import sys +import pathlib + +sys.path.insert(0, str(pathlib.Path(__file__).parent)) + +from antExample import AntExample +from color import Color + +class AntExampleV2(AntExample): + def __init__(self, + amas: 'antHillExample', + startX: float, + startY: float + ) -> None: + super().__init__(amas, startX, startY) + self.majority_color = Color.BLACK + self.couleurs_voisin = [0, 0, 0, 0, 0] + + def on_perceive(self) -> None: + self.reset_neighbour() + neighbours = [] + + for agent in self.get_amas().get_agents(): + length = sqrt(pow(self._dx - agent.get_dx(), 2) + pow(self._dy - agent.get_dy(), 2)) + if length < self.get_environment().field_of_view: + neighbours.append([length, agent]) + + sorted(neighbours, key=lambda x: x[0]) + + for i in range(min(5, len(neighbours))): + self.add_neighbour(neighbours[i][1]) + self.find_the_majority_color() + + def on_act(self) -> None: + # couleur + if self.majority_color != self._color: + if self.couleurs_voisin.index(max(self.couleurs_voisin)) == 5 and self._color != Color.BLACK: + self.remove_agent() + if self.couleurs_voisin.index(max(self.couleurs_voisin)) >= 3 and self._color == Color.BLACK: + self._color = self.majority_color + elif randint(1, 1000) <= 4: + self._color = AntExample.int_to_color.get(randint(0, 4)) + + # déplacement + self.make_random_move() + + def find_the_majority_color(self) -> Color: + self.couleurs_voisin = [0, 0, 0, 0, 0] + for agent in self.get_neighbour(): + self.couleurs_voisin[AntExample.color_to_int.get(agent.get_color())] += 1 + + self.majority_color = AntExample.int_to_color.get(self.couleurs_voisin.index(max(self.couleurs_voisin))) + diff --git a/ant_example/antExample.py b/ant_example/antExample.py index 112a5c2..6007e45 100644 --- a/ant_example/antExample.py +++ b/ant_example/antExample.py @@ -1,7 +1,6 @@ """ class antExample """ -from math import * from random import randint from pyAmakCore.classes.agent import Agent @@ -10,6 +9,21 @@ from color import Color class AntExample(Agent): + int_to_color = { + 0: Color.BLUE, + 1: Color.BLACK, + 2: Color.RED, + 3: Color.YELLOW, + 4: Color.GREEN + } + + color_to_int = { + Color.BLUE: 0, + Color.BLACK: 1, + Color.RED: 2, + Color.YELLOW: 3, + Color.GREEN: 4 + } def __init__(self, amas: 'antHillExample', @@ -34,33 +48,10 @@ class AntExample(Agent): def get_old_color(self): return self._old_color - def on_perceive(self) -> None: - self.reset_neighbour() - for agent in self.get_amas().get_agents(): - length = sqrt(pow(self._dx - agent.get_dx(), 2) + pow(self._dy - agent.get_dy(), 2)) - if length < self.get_environment().field_of_view: - self.add_neighbour(agent) - - def on_act(self) -> None: - # couleur - color_changed = False - for agent in self.get_neighbour(): - if agent.get_color() != Color.BLACK: - self._color = agent.get_color() - color_changed = True - - if not color_changed: - color = { - 1: Color.BLUE, - 2: Color.BLACK, - 3: Color.RED, - 4: Color.YELLOW, - 5: Color.GREEN - } - if randint(1, 1000) <= 4: - self._color = color.get(randint(1, 5)) - - # déplacement + def on_cycle_begin(self): + self._old_color = self._color + + def make_random_move(self): self._dx += (randint(-1, 1) * self.get_environment().coef_deplacement) self._dy += (randint(-1, 1) * self.get_environment().coef_deplacement) @@ -75,6 +66,3 @@ class AntExample(Agent): if self._dy > self.get_environment().ymax: self._dy = self.get_environment().ymax - - def on_cycle_begin(self): - self._old_color = self._color diff --git a/ant_example/antHillExample.py b/ant_example/antHillExample.py index 467f293..ecf9e59 100644 --- a/ant_example/antHillExample.py +++ b/ant_example/antHillExample.py @@ -1,16 +1,31 @@ """ class antHillExample """ -from pyAmakCore.classes.tools.amasIHM import AmasIHM +from ant_example.agent.communicating import CommunicatingAnt +from ant_example.agent.proof_of_concept import AntTest +from ant_example.agent.v1 import AntExampleV1 +from ant_example.agent.v2 import AntExampleV2 -from antExample import AntExample +from pyAmakCore.classes.tools.amasIHM import AmasIHM +from pyAmakCore.enumeration.executionPolicy import ExecutionPolicy class AntHillExample(AmasIHM): - def __init__(self, env): + def __init__(self, env, nbr_ants): + self.nbr_ants = nbr_ants super().__init__(env) + def on_initialization(self) -> None: + # self.set_execution_policy(ExecutionPolicy.ONE_PHASE) + self.set_execution_policy(ExecutionPolicy.TWO_PHASES) + + self.set_do_log(True) + + def on_initial_agents_creation(self) -> None: - for i in range(50): - self.add_agent(AntExample(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) \ No newline at end of file + for i in range(self.nbr_ants): + # self.add_agent(AntExampleV1(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) + # self.add_agent(AntExampleV2(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) + self.add_agent(CommunicatingAnt(self, self.get_environment().xmax / 2, self.get_environment().ymax / 2)) + # self.add_agent(AntTest(self, self.get_environment().xmax / 2, self.get_environment().ymax / 2)) diff --git a/ant_example/antsLaunchExample.py b/ant_example/antsLaunchExample.py index b584539..d3d4884 100644 --- a/ant_example/antsLaunchExample.py +++ b/ant_example/antsLaunchExample.py @@ -8,14 +8,18 @@ from controleurAntsExample import ControleurAntsExample from worldExample import WorldExample from antHillExample import * -fenetre = Fenetre("Prototype Ants") +from pyAmakCore.exception.override import ToOverrideWarning seed() -env = WorldExample(0, fenetre.get_canvas_width(), 0, fenetre.get_canvas_height(), 5, 7) -amas = AntHillExample(env) +nbr_ants = 50 + +ToOverrideWarning.enable_warning(False) -controleur = ControleurAntsExample(fenetre, amas) +fenetre = Fenetre("Prototype Ants") +env = WorldExample(0, fenetre.get_canvas_width(), 0, fenetre.get_canvas_height(), 50, 7) +amas = AntHillExample(env, nbr_ants) +controleur = ControleurAntsExample(fenetre, amas, nbr_ants) def main(): diff --git a/ant_examplev2/comportement.txt b/ant_example/comportement.txt similarity index 99% rename from ant_examplev2/comportement.txt rename to ant_example/comportement.txt index 3a9ad89..29cce9b 100644 --- a/ant_examplev2/comportement.txt +++ b/ant_example/comportement.txt @@ -1,4 +1,4 @@ - +V2 : Init : * Les fourmis partent toutes du centre de l'écran diff --git a/ant_example/controleurAntsExample.py b/ant_example/controleurAntsExample.py index ac7ded7..6416d72 100644 --- a/ant_example/controleurAntsExample.py +++ b/ant_example/controleurAntsExample.py @@ -4,10 +4,10 @@ from pyAmakIHM.classes.controleur import Controleur class ControleurAntsExample(Controleur): - def __init__(self, fenetre, amas): + def __init__(self, fenetre, amas, nbr_ants): super().__init__(fenetre, amas) self.__ants = [] - self.__numberAnts = 50 + self.__numberAnts = nbr_ants def initialisation(self): @@ -39,4 +39,7 @@ class ControleurAntsExample(Controleur): elif color == Color.YELLOW: self.__ants[i] = self.draw_image(x, y, 'images/yellowAnt.png') + elif color == Color.BLACK: + self.__ants[i] = self.draw_image(x, y, 'images/blackAnt.png') + self.move_image(self.__ants[i], x, y) diff --git a/ant_example/worldExample.py b/ant_example/worldExample.py index 838564c..bec8fb4 100644 --- a/ant_example/worldExample.py +++ b/ant_example/worldExample.py @@ -7,7 +7,6 @@ from pyAmakCore.classes.environment import Environment class WorldExample(Environment): def __init__(self, xmin, xmax, ymin, ymax, field_of_view, coef_deplacement): - super().__init__() self.xmin = xmin self.xmax = xmax self.ymin = ymin @@ -15,3 +14,4 @@ class WorldExample(Environment): self.field_of_view = field_of_view self.coef_deplacement = coef_deplacement + super().__init__() diff --git a/ant_example_2_phases/antExample.py b/ant_example_2_phases/antExample.py deleted file mode 100644 index 112a5c2..0000000 --- a/ant_example_2_phases/antExample.py +++ /dev/null @@ -1,80 +0,0 @@ -""" -class antExample -""" -from math import * -from random import randint - -from pyAmakCore.classes.agent import Agent - -from color import Color - - -class AntExample(Agent): - - def __init__(self, - amas: 'antHillExample', - startX: float, - startY: float - ) -> None: - super().__init__(amas) - self._dx = startX - self._dy = startY - self._color = Color.BLACK - self._old_color = Color.BLACK - - def get_color(self): - return self._color - - def get_dx(self): - return self._dx - - def get_dy(self): - return self._dy - - def get_old_color(self): - return self._old_color - - def on_perceive(self) -> None: - self.reset_neighbour() - for agent in self.get_amas().get_agents(): - length = sqrt(pow(self._dx - agent.get_dx(), 2) + pow(self._dy - agent.get_dy(), 2)) - if length < self.get_environment().field_of_view: - self.add_neighbour(agent) - - def on_act(self) -> None: - # couleur - color_changed = False - for agent in self.get_neighbour(): - if agent.get_color() != Color.BLACK: - self._color = agent.get_color() - color_changed = True - - if not color_changed: - color = { - 1: Color.BLUE, - 2: Color.BLACK, - 3: Color.RED, - 4: Color.YELLOW, - 5: Color.GREEN - } - if randint(1, 1000) <= 4: - self._color = color.get(randint(1, 5)) - - # déplacement - self._dx += (randint(-1, 1) * self.get_environment().coef_deplacement) - self._dy += (randint(-1, 1) * self.get_environment().coef_deplacement) - - if self._dx < self.get_environment().xmin: - self._dx = self.get_environment().xmin - - if self._dx > self.get_environment().xmax: - self._dx = self.get_environment().xmax - - if self._dy < self.get_environment().ymin: - self._dy = self.get_environment().ymin - - if self._dy > self.get_environment().ymax: - self._dy = self.get_environment().ymax - - def on_cycle_begin(self): - self._old_color = self._color diff --git a/ant_example_2_phases/antHillExample.py b/ant_example_2_phases/antHillExample.py deleted file mode 100644 index 467f293..0000000 --- a/ant_example_2_phases/antHillExample.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -class antHillExample -""" -from pyAmakCore.classes.tools.amasIHM import AmasIHM - -from antExample import AntExample - - -class AntHillExample(AmasIHM): - - def __init__(self, env): - super().__init__(env) - - def on_initial_agents_creation(self) -> None: - for i in range(50): - self.add_agent(AntExample(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) \ No newline at end of file diff --git a/ant_example_2_phases/antsLaunchExample.py b/ant_example_2_phases/antsLaunchExample.py deleted file mode 100644 index c08eb76..0000000 --- a/ant_example_2_phases/antsLaunchExample.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Class antsLaunchExample -""" -from random import seed - -from pyAmakIHM.classes.fenetre import Fenetre -from controleurAntsExample import ControleurAntsExample -from worldExample import WorldExample -from antHillExample import * -from threading import Thread - -fenetre = Fenetre("Prototype Ants") - -seed() - -env = WorldExample(0, fenetre.get_canvas_width(), 0, fenetre.get_canvas_height(), 5, 7) -amas = AntHillExample(env) - -controleur = ControleurAntsExample(fenetre, amas) - - -def main(): - controleur.start() - -main() diff --git a/ant_example_2_phases/color.py b/ant_example_2_phases/color.py deleted file mode 100644 index 939b45f..0000000 --- a/ant_example_2_phases/color.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import * -class Color(Enum): - BLACK= auto() - RED=auto() - BLUE=auto() - GREEN=auto() - YELLOW=auto() \ No newline at end of file diff --git a/ant_example_2_phases/controleurAntsExample.py b/ant_example_2_phases/controleurAntsExample.py deleted file mode 100644 index ac7ded7..0000000 --- a/ant_example_2_phases/controleurAntsExample.py +++ /dev/null @@ -1,42 +0,0 @@ -from color import Color -from pyAmakIHM.classes.controleur import Controleur - - -class ControleurAntsExample(Controleur): - - def __init__(self, fenetre, amas): - super().__init__(fenetre, amas) - self.__ants = [] - self.__numberAnts = 50 - - def initialisation(self): - - widthCanvas = self.get_fenetre().get_canvas_width() - heightCanvas = self.get_fenetre().get_canvas_height() - - for i in range(self.__numberAnts): - self.__ants.append(self.draw_image(widthCanvas / 2, heightCanvas / 2, 'images/blackAnt.png')) - - def updateWindow(self, env, amas): - ants = amas.get_Agents_Sorted() - - for i in range(len(ants)): - x = ants[i].get_dx() - y = ants[i].get_dy() - color = ants[i].get_color() - - if color != ants[i].get_old_color(): - self.remove_element(self.__ants[i]) - if color == Color.BLUE: - self.__ants[i] = self.draw_image(x, y, 'images/blueAnt.png') - - elif color == Color.GREEN: - self.__ants[i] = self.draw_image(x, y, 'images/greenAnt.png') - - elif color == Color.RED: - self.__ants[i] = self.draw_image(x, y, 'images/redAnt.png') - - elif color == Color.YELLOW: - self.__ants[i] = self.draw_image(x, y, 'images/yellowAnt.png') - - self.move_image(self.__ants[i], x, y) diff --git a/ant_example_2_phases/images/blackAnt.png b/ant_example_2_phases/images/blackAnt.png deleted file mode 100644 index ab4c4d0b27b9e43ed2f26f10d7566526363a59ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 537 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_tsA9%VrhE&A8y>+pxDS?4C zvHE{|-bW_^bC0EU>VJ0KK6>|<q`&Hy88$&|a+*>GlNC00I|w)?u_alEDS4c6;5qKZ z(ka>TFrq`jkl9d%TTmrUp)Fal=?Kq}0v(qLGa4oOS~-M_1rBe-qiJX1gy$xIe=mFT zt$cl7r{-_Hb1zyuJ}rCxLc#dl?$A3`s^P3N51%=2dpcfjeO+9<|LKk42KC=dvy>BW zOwMI`Q+dzzUv8N3r>yApiT*ub4V5kXH`RXmF;TtB?1aa${!_M}&%4cgb5r5;@3S*M z|K7P@QZnUdOR3AG?-P`_`N{46x8+IjHMd7ET6gew-j&!D%+D&Ad_4P)sD7mNhIiE+ p3LC#Q5%d9B-ll^l51kY8KX?>V%jF!*85kHCJYD@<);T3K0RWDp&?Eo= diff --git a/ant_example_2_phases/images/blueAnt.png b/ant_example_2_phases/images/blueAnt.png deleted file mode 100644 index 4605bb5fd406aa8ff24943d60949e67e421871bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9lPQRTi9Vl|- z4O5WItzySaeb*%oEWbA%IA-Xe+3<3s>t9caguWBi-#-4ilHPUT^A!``&r>FBbe=Gw zrAJUgdO5G>35mvyg}125br=2g_xSqz_VN4vmNLZs{}z_kbA5OJ;yjO_8_TtxNVIQz zbaDF==N6fyzSGwk|JxYn*Y2OU-1zseO~=#U6|06QhBIzYuzF~J=~{-<yQzhu->z<d z^eg^(tIeby=QDdIe6A}#t@=(o#YFMB@HN{DyV~zKzqa3eefiRPoBp+~$n$uwSko1% zxOXK#rzhL#fccy9q?b>rI>}`&?7?9iB+MCDSRCmzW8y52j;`6Kg%0&xad8T{6EjU9 zZHb!DqDRj*wHPRyP81L|pRU>>xw5lm#g3giif250Ra}mqP325<%TiL*%G2{6;zoUB ZzrDF7_0EAU+zbp144$rjF6*2UngFJh5i<Y) diff --git a/ant_example_2_phases/images/greenAnt.png b/ant_example_2_phases/images/greenAnt.png deleted file mode 100644 index 331944103fbebe237d5f9351bf0b8111aa16b20b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 627 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCtUO&DLn`9lPWR0dP84C8 z{ClH<dMoR9=Cesl6kW8WHK+Q;+`E~za{lUl=Jx0PYnO4@`1@Wq@aL4YX5sWaA<?+8 z@YaNu9zhA|<-AnnR)#3vudDh0_x01~@$3)2=I5s#tJwS7;#HeUYwaqhzQPP`xms^K zmlKN5cGSpzIB)#<+V|I$R-4!BSJynV3wIJN5-s3fCj3u1w^!{+oMd=ne69An|D|y! zluue5Im2!F-h6w^qkT?p!bNt8cbV5#pRnEX&$zla>Xqi}_>Na?U*rxgj}W~y``3gC zDI0jcYQEl9=(TeCngZj-76WC|i2|bL(^Xp}S9Z3n*s)Vb@r;MBip$Znsho*!SxSmp zd3xR)#zDfIfrZ79PBSLX^62QAeOl;H&lMM^kUKHc1k#qM2`zf`Y|~ITs-D3*xg~Y$ Tads011_lOCS3j3^P6<r_c>@0c diff --git a/ant_example_2_phases/images/redAnt.png b/ant_example_2_phases/images/redAnt.png deleted file mode 100644 index 23e635766fc329daa4e828a3e56c8d1159b165f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 629 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&=~YLn`9lPCuI~ohWkT zP4z2J=5^M*OXl4Xev{bPo7@n@a5=eqm#0L+yc6%=p8p&?Uz6#4@MV)T!A{5c9G!%W z+!Au;n5ifxvm85?=}bkgT<D4Q)8Fsk|M$nw>x>nDZ%5BGjC*g_w@cA8asH|a$uhUP z-0x4~7cA<q)Qe~T^ZCr4uYarNoqO~8wA}oi=cfj=#<1RLdfD>dBYH9C&hTTQH^T3C zy{?}t{>j6L&+xO;x!-4Xr|(!l;bO}i|A_AnujPvP*Zw~fH-B2ysbAuYb}8;{|DYMx z`em7&ii)I;bM2{JxpRVEscPTxQBXYN;j7|u^lU0;qFa`dqE?=sH-~YMFlS(4air6X ziL*R9x@MmiI@EK;#VO=Y%rt?tC2B&89zEOCVxVj~Q9#sux@wE$%FdP*J9g>}aifmN ZmmF?MZ8~HzgMop8!PC{xWt~$(69BX+1&{y$ diff --git a/ant_example_2_phases/images/yellowAnt.png b/ant_example_2_phases/images/yellowAnt.png deleted file mode 100644 index 24676979b2ced1242739507a5bd5215d6abf94e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9l&bpX&C_sSq z?Em^Ls;v%N4!LZ+yjJr5l;-rgJEfI(#8mYtZRnY`EK!eBvW!D$(u72ow%*HaDk&0; ziI2A^a!R@-+_1>?aB35jF!Ph9Ou8sc@%rnhyL7hypR%X^ZD5+j`gnQwyAzgd@DDv< z#g}{Z=JqH4Eo+jloxaXhZ*AN^@BR79)AsIv^Ks_yc+SuhaR&r_r2iP__NqOJl&nsi zzfaVB{?`+pweHVC71JkutktY%f1~{V<Eja7e?Rj$uAX9|cw6?G@r7S}m2KC$Z~na- zR32%sxJvrcdjY$nt0vT~<QJO6Gi~9$R9WfeQ>spKnG1Vx7zYV+1{M}aI?b3k%cG-f z_GzI*Jy%?uLhi&&6G&U4Cba0$vrR1q%BB+qM9rtGwn(n*Y+12mr;g$o4__6Rqi0h& n6Wy|u6t(j7yob0^A6c81B&S-bum8Znz`)??>gTe~DWM4fti%O! diff --git a/ant_example_2_phases/worldExample.py b/ant_example_2_phases/worldExample.py deleted file mode 100644 index 838564c..0000000 --- a/ant_example_2_phases/worldExample.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -Class worldExample -""" -from pyAmakCore.classes.environment import Environment - - -class WorldExample(Environment): - - def __init__(self, xmin, xmax, ymin, ymax, field_of_view, coef_deplacement): - super().__init__() - self.xmin = xmin - self.xmax = xmax - self.ymin = ymin - self.ymax = ymax - - self.field_of_view = field_of_view - self.coef_deplacement = coef_deplacement diff --git a/ant_examplev2/antExample.py b/ant_examplev2/antExample.py deleted file mode 100644 index c456050..0000000 --- a/ant_examplev2/antExample.py +++ /dev/null @@ -1,98 +0,0 @@ -""" -class antExample -""" -from math import * -from random import randint - -from pyAmakCore.classes.agent import Agent -from color import Color - - -class AntExample(Agent): - - def __init__(self, - amas: 'antHillExample', - startX: float, - startY: float - ) -> None: - super().__init__(amas) - self._dx = startX - self._dy = startY - self._color = Color.BLACK - self._old_color = Color.BLACK - - def get_color(self): - return self._color - - def get_dx(self): - return self._dx - - def get_dy(self): - return self._dy - - def get_old_color(self): - return self._old_color - - def on_perceive(self) -> None: - self.reset_neighbour() - neighbours = [] - - for agent in self.get_amas().get_agents(): - length = sqrt(pow(self._dx - agent.get_dx(), 2) + pow(self._dy - agent.get_dy(), 2)) - if length < self.get_environment().field_of_view: - neighbours.append([length, agent]) - - sorted(neighbours, key=lambda x: x[0]) - - for i in range(min(5, len(neighbours))): - self.add_neighbour(neighbours[i][1]) - - def on_act(self) -> None: - int_to_color = { - 0: Color.BLUE, - 1: Color.BLACK, - 2: Color.RED, - 3: Color.YELLOW, - 4: Color.GREEN - } - - color_to_int = { - Color.BLUE: 0, - Color.BLACK: 1, - Color.RED: 2, - Color.YELLOW: 3, - Color.GREEN: 4 - } - # couleur - couleurs_voisin = [0, 0, 0, 0, 0] - for agent in self.get_neighbour(): - couleurs_voisin[color_to_int.get(agent.get_color())] += 1 - - for i in range(len(couleurs_voisin)): - if couleurs_voisin[i] == 5 and self._color != Color.BLACK: - self.remove_agent() - if couleurs_voisin[i] >= 3 and self._color == Color.BLACK: - self._color = int_to_color.get(i) - - if self._color == Color.BLACK: - if randint(1, 100) <= 1: - self._color = int_to_color.get(randint(0, 4)) - - # déplacement - self._dx += (randint(-1, 1) * self.get_environment().coef_deplacement) - self._dy += (randint(-1, 1) * self.get_environment().coef_deplacement) - - if self._dx < self.get_environment().xmin: - self._dx = self.get_environment().xmin - - if self._dx > self.get_environment().xmax: - self._dx = self.get_environment().xmax - - if self._dy < self.get_environment().ymin: - self._dy = self.get_environment().ymin - - if self._dy > self.get_environment().ymax: - self._dy = self.get_environment().ymax - - def on_cycle_begin(self): - self._old_color = self._color diff --git a/ant_examplev2/antHillExample.py b/ant_examplev2/antHillExample.py deleted file mode 100644 index 467f293..0000000 --- a/ant_examplev2/antHillExample.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -class antHillExample -""" -from pyAmakCore.classes.tools.amasIHM import AmasIHM - -from antExample import AntExample - - -class AntHillExample(AmasIHM): - - def __init__(self, env): - super().__init__(env) - - def on_initial_agents_creation(self) -> None: - for i in range(50): - self.add_agent(AntExample(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) \ No newline at end of file diff --git a/ant_examplev2/antsLaunchExample.py b/ant_examplev2/antsLaunchExample.py deleted file mode 100644 index c08eb76..0000000 --- a/ant_examplev2/antsLaunchExample.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Class antsLaunchExample -""" -from random import seed - -from pyAmakIHM.classes.fenetre import Fenetre -from controleurAntsExample import ControleurAntsExample -from worldExample import WorldExample -from antHillExample import * -from threading import Thread - -fenetre = Fenetre("Prototype Ants") - -seed() - -env = WorldExample(0, fenetre.get_canvas_width(), 0, fenetre.get_canvas_height(), 5, 7) -amas = AntHillExample(env) - -controleur = ControleurAntsExample(fenetre, amas) - - -def main(): - controleur.start() - -main() diff --git a/ant_examplev2/color.py b/ant_examplev2/color.py deleted file mode 100644 index 939b45f..0000000 --- a/ant_examplev2/color.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import * -class Color(Enum): - BLACK= auto() - RED=auto() - BLUE=auto() - GREEN=auto() - YELLOW=auto() \ No newline at end of file diff --git a/ant_examplev2/controleurAntsExample.py b/ant_examplev2/controleurAntsExample.py deleted file mode 100644 index ac7ded7..0000000 --- a/ant_examplev2/controleurAntsExample.py +++ /dev/null @@ -1,42 +0,0 @@ -from color import Color -from pyAmakIHM.classes.controleur import Controleur - - -class ControleurAntsExample(Controleur): - - def __init__(self, fenetre, amas): - super().__init__(fenetre, amas) - self.__ants = [] - self.__numberAnts = 50 - - def initialisation(self): - - widthCanvas = self.get_fenetre().get_canvas_width() - heightCanvas = self.get_fenetre().get_canvas_height() - - for i in range(self.__numberAnts): - self.__ants.append(self.draw_image(widthCanvas / 2, heightCanvas / 2, 'images/blackAnt.png')) - - def updateWindow(self, env, amas): - ants = amas.get_Agents_Sorted() - - for i in range(len(ants)): - x = ants[i].get_dx() - y = ants[i].get_dy() - color = ants[i].get_color() - - if color != ants[i].get_old_color(): - self.remove_element(self.__ants[i]) - if color == Color.BLUE: - self.__ants[i] = self.draw_image(x, y, 'images/blueAnt.png') - - elif color == Color.GREEN: - self.__ants[i] = self.draw_image(x, y, 'images/greenAnt.png') - - elif color == Color.RED: - self.__ants[i] = self.draw_image(x, y, 'images/redAnt.png') - - elif color == Color.YELLOW: - self.__ants[i] = self.draw_image(x, y, 'images/yellowAnt.png') - - self.move_image(self.__ants[i], x, y) diff --git a/ant_examplev2/images/blackAnt.png b/ant_examplev2/images/blackAnt.png deleted file mode 100644 index ab4c4d0b27b9e43ed2f26f10d7566526363a59ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 537 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_tsA9%VrhE&A8y>+pxDS?4C zvHE{|-bW_^bC0EU>VJ0KK6>|<q`&Hy88$&|a+*>GlNC00I|w)?u_alEDS4c6;5qKZ z(ka>TFrq`jkl9d%TTmrUp)Fal=?Kq}0v(qLGa4oOS~-M_1rBe-qiJX1gy$xIe=mFT zt$cl7r{-_Hb1zyuJ}rCxLc#dl?$A3`s^P3N51%=2dpcfjeO+9<|LKk42KC=dvy>BW zOwMI`Q+dzzUv8N3r>yApiT*ub4V5kXH`RXmF;TtB?1aa${!_M}&%4cgb5r5;@3S*M z|K7P@QZnUdOR3AG?-P`_`N{46x8+IjHMd7ET6gew-j&!D%+D&Ad_4P)sD7mNhIiE+ p3LC#Q5%d9B-ll^l51kY8KX?>V%jF!*85kHCJYD@<);T3K0RWDp&?Eo= diff --git a/ant_examplev2/images/blueAnt.png b/ant_examplev2/images/blueAnt.png deleted file mode 100644 index 4605bb5fd406aa8ff24943d60949e67e421871bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9lPQRTi9Vl|- z4O5WItzySaeb*%oEWbA%IA-Xe+3<3s>t9caguWBi-#-4ilHPUT^A!``&r>FBbe=Gw zrAJUgdO5G>35mvyg}125br=2g_xSqz_VN4vmNLZs{}z_kbA5OJ;yjO_8_TtxNVIQz zbaDF==N6fyzSGwk|JxYn*Y2OU-1zseO~=#U6|06QhBIzYuzF~J=~{-<yQzhu->z<d z^eg^(tIeby=QDdIe6A}#t@=(o#YFMB@HN{DyV~zKzqa3eefiRPoBp+~$n$uwSko1% zxOXK#rzhL#fccy9q?b>rI>}`&?7?9iB+MCDSRCmzW8y52j;`6Kg%0&xad8T{6EjU9 zZHb!DqDRj*wHPRyP81L|pRU>>xw5lm#g3giif250Ra}mqP325<%TiL*%G2{6;zoUB ZzrDF7_0EAU+zbp144$rjF6*2UngFJh5i<Y) diff --git a/ant_examplev2/images/greenAnt.png b/ant_examplev2/images/greenAnt.png deleted file mode 100644 index 331944103fbebe237d5f9351bf0b8111aa16b20b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 627 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCtUO&DLn`9lPWR0dP84C8 z{ClH<dMoR9=Cesl6kW8WHK+Q;+`E~za{lUl=Jx0PYnO4@`1@Wq@aL4YX5sWaA<?+8 z@YaNu9zhA|<-AnnR)#3vudDh0_x01~@$3)2=I5s#tJwS7;#HeUYwaqhzQPP`xms^K zmlKN5cGSpzIB)#<+V|I$R-4!BSJynV3wIJN5-s3fCj3u1w^!{+oMd=ne69An|D|y! zluue5Im2!F-h6w^qkT?p!bNt8cbV5#pRnEX&$zla>Xqi}_>Na?U*rxgj}W~y``3gC zDI0jcYQEl9=(TeCngZj-76WC|i2|bL(^Xp}S9Z3n*s)Vb@r;MBip$Znsho*!SxSmp zd3xR)#zDfIfrZ79PBSLX^62QAeOl;H&lMM^kUKHc1k#qM2`zf`Y|~ITs-D3*xg~Y$ Tads011_lOCS3j3^P6<r_c>@0c diff --git a/ant_examplev2/images/redAnt.png b/ant_examplev2/images/redAnt.png deleted file mode 100644 index 23e635766fc329daa4e828a3e56c8d1159b165f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 629 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&=~YLn`9lPCuI~ohWkT zP4z2J=5^M*OXl4Xev{bPo7@n@a5=eqm#0L+yc6%=p8p&?Uz6#4@MV)T!A{5c9G!%W z+!Au;n5ifxvm85?=}bkgT<D4Q)8Fsk|M$nw>x>nDZ%5BGjC*g_w@cA8asH|a$uhUP z-0x4~7cA<q)Qe~T^ZCr4uYarNoqO~8wA}oi=cfj=#<1RLdfD>dBYH9C&hTTQH^T3C zy{?}t{>j6L&+xO;x!-4Xr|(!l;bO}i|A_AnujPvP*Zw~fH-B2ysbAuYb}8;{|DYMx z`em7&ii)I;bM2{JxpRVEscPTxQBXYN;j7|u^lU0;qFa`dqE?=sH-~YMFlS(4air6X ziL*R9x@MmiI@EK;#VO=Y%rt?tC2B&89zEOCVxVj~Q9#sux@wE$%FdP*J9g>}aifmN ZmmF?MZ8~HzgMop8!PC{xWt~$(69BX+1&{y$ diff --git a/ant_examplev2/images/yellowAnt.png b/ant_examplev2/images/yellowAnt.png deleted file mode 100644 index 24676979b2ced1242739507a5bd5215d6abf94e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9l&bpX&C_sSq z?Em^Ls;v%N4!LZ+yjJr5l;-rgJEfI(#8mYtZRnY`EK!eBvW!D$(u72ow%*HaDk&0; ziI2A^a!R@-+_1>?aB35jF!Ph9Ou8sc@%rnhyL7hypR%X^ZD5+j`gnQwyAzgd@DDv< z#g}{Z=JqH4Eo+jloxaXhZ*AN^@BR79)AsIv^Ks_yc+SuhaR&r_r2iP__NqOJl&nsi zzfaVB{?`+pweHVC71JkutktY%f1~{V<Eja7e?Rj$uAX9|cw6?G@r7S}m2KC$Z~na- zR32%sxJvrcdjY$nt0vT~<QJO6Gi~9$R9WfeQ>spKnG1Vx7zYV+1{M}aI?b3k%cG-f z_GzI*Jy%?uLhi&&6G&U4Cba0$vrR1q%BB+qM9rtGwn(n*Y+12mr;g$o4__6Rqi0h& n6Wy|u6t(j7yob0^A6c81B&S-bum8Znz`)??>gTe~DWM4fti%O! diff --git a/ant_examplev2/worldExample.py b/ant_examplev2/worldExample.py deleted file mode 100644 index b91b88a..0000000 --- a/ant_examplev2/worldExample.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -Class worldExample -""" -from pyAmakCore.classes.environment import Environment - - -class WorldExample(Environment): - - def __init__(self, xmin, xmax, ymin, ymax, field_of_view, coef_deplacement): - super().__init__() - self.xmin = xmin - self.xmax = xmax - self.ymin = ymin - self.ymax = ymax - - self.field_of_view = field_of_view - self.coef_deplacement = coef_deplacement \ No newline at end of file diff --git a/communicating_agent_example/antHillExample.py b/communicating_agent_example/antHillExample.py deleted file mode 100644 index 467f293..0000000 --- a/communicating_agent_example/antHillExample.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -class antHillExample -""" -from pyAmakCore.classes.tools.amasIHM import AmasIHM - -from antExample import AntExample - - -class AntHillExample(AmasIHM): - - def __init__(self, env): - super().__init__(env) - - def on_initial_agents_creation(self) -> None: - for i in range(50): - self.add_agent(AntExample(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) \ No newline at end of file diff --git a/communicating_agent_example/antsLaunchExample.py b/communicating_agent_example/antsLaunchExample.py deleted file mode 100644 index 225febd..0000000 --- a/communicating_agent_example/antsLaunchExample.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Class antsLaunchExample -""" -from random import seed - -from pyAmakIHM.classes.fenetre import Fenetre -from controleurAntsExample import ControleurAntsExample -from worldExample import WorldExample -from antHillExample import * -from threading import Thread - -fenetre = Fenetre("Prototype Ants") - -seed() - -env = WorldExample(0, fenetre.get_canvas_width(), 0, fenetre.get_canvas_height(), 3, 7) -amas = AntHillExample(env) - -controleur = ControleurAntsExample(fenetre, amas) - - -def main(): - controleur.start() - -main() diff --git a/communicating_agent_example/color.py b/communicating_agent_example/color.py deleted file mode 100644 index 939b45f..0000000 --- a/communicating_agent_example/color.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import * -class Color(Enum): - BLACK= auto() - RED=auto() - BLUE=auto() - GREEN=auto() - YELLOW=auto() \ No newline at end of file diff --git a/communicating_agent_example/controleurAntsExample.py b/communicating_agent_example/controleurAntsExample.py deleted file mode 100644 index ac7ded7..0000000 --- a/communicating_agent_example/controleurAntsExample.py +++ /dev/null @@ -1,42 +0,0 @@ -from color import Color -from pyAmakIHM.classes.controleur import Controleur - - -class ControleurAntsExample(Controleur): - - def __init__(self, fenetre, amas): - super().__init__(fenetre, amas) - self.__ants = [] - self.__numberAnts = 50 - - def initialisation(self): - - widthCanvas = self.get_fenetre().get_canvas_width() - heightCanvas = self.get_fenetre().get_canvas_height() - - for i in range(self.__numberAnts): - self.__ants.append(self.draw_image(widthCanvas / 2, heightCanvas / 2, 'images/blackAnt.png')) - - def updateWindow(self, env, amas): - ants = amas.get_Agents_Sorted() - - for i in range(len(ants)): - x = ants[i].get_dx() - y = ants[i].get_dy() - color = ants[i].get_color() - - if color != ants[i].get_old_color(): - self.remove_element(self.__ants[i]) - if color == Color.BLUE: - self.__ants[i] = self.draw_image(x, y, 'images/blueAnt.png') - - elif color == Color.GREEN: - self.__ants[i] = self.draw_image(x, y, 'images/greenAnt.png') - - elif color == Color.RED: - self.__ants[i] = self.draw_image(x, y, 'images/redAnt.png') - - elif color == Color.YELLOW: - self.__ants[i] = self.draw_image(x, y, 'images/yellowAnt.png') - - self.move_image(self.__ants[i], x, y) diff --git a/communicating_agent_example/images/blackAnt.png b/communicating_agent_example/images/blackAnt.png deleted file mode 100644 index ab4c4d0b27b9e43ed2f26f10d7566526363a59ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 537 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_tsA9%VrhE&A8y>+pxDS?4C zvHE{|-bW_^bC0EU>VJ0KK6>|<q`&Hy88$&|a+*>GlNC00I|w)?u_alEDS4c6;5qKZ z(ka>TFrq`jkl9d%TTmrUp)Fal=?Kq}0v(qLGa4oOS~-M_1rBe-qiJX1gy$xIe=mFT zt$cl7r{-_Hb1zyuJ}rCxLc#dl?$A3`s^P3N51%=2dpcfjeO+9<|LKk42KC=dvy>BW zOwMI`Q+dzzUv8N3r>yApiT*ub4V5kXH`RXmF;TtB?1aa${!_M}&%4cgb5r5;@3S*M z|K7P@QZnUdOR3AG?-P`_`N{46x8+IjHMd7ET6gew-j&!D%+D&Ad_4P)sD7mNhIiE+ p3LC#Q5%d9B-ll^l51kY8KX?>V%jF!*85kHCJYD@<);T3K0RWDp&?Eo= diff --git a/communicating_agent_example/images/blueAnt.png b/communicating_agent_example/images/blueAnt.png deleted file mode 100644 index 4605bb5fd406aa8ff24943d60949e67e421871bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9lPQRTi9Vl|- z4O5WItzySaeb*%oEWbA%IA-Xe+3<3s>t9caguWBi-#-4ilHPUT^A!``&r>FBbe=Gw zrAJUgdO5G>35mvyg}125br=2g_xSqz_VN4vmNLZs{}z_kbA5OJ;yjO_8_TtxNVIQz zbaDF==N6fyzSGwk|JxYn*Y2OU-1zseO~=#U6|06QhBIzYuzF~J=~{-<yQzhu->z<d z^eg^(tIeby=QDdIe6A}#t@=(o#YFMB@HN{DyV~zKzqa3eefiRPoBp+~$n$uwSko1% zxOXK#rzhL#fccy9q?b>rI>}`&?7?9iB+MCDSRCmzW8y52j;`6Kg%0&xad8T{6EjU9 zZHb!DqDRj*wHPRyP81L|pRU>>xw5lm#g3giif250Ra}mqP325<%TiL*%G2{6;zoUB ZzrDF7_0EAU+zbp144$rjF6*2UngFJh5i<Y) diff --git a/communicating_agent_example/images/greenAnt.png b/communicating_agent_example/images/greenAnt.png deleted file mode 100644 index 331944103fbebe237d5f9351bf0b8111aa16b20b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 627 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCtUO&DLn`9lPWR0dP84C8 z{ClH<dMoR9=Cesl6kW8WHK+Q;+`E~za{lUl=Jx0PYnO4@`1@Wq@aL4YX5sWaA<?+8 z@YaNu9zhA|<-AnnR)#3vudDh0_x01~@$3)2=I5s#tJwS7;#HeUYwaqhzQPP`xms^K zmlKN5cGSpzIB)#<+V|I$R-4!BSJynV3wIJN5-s3fCj3u1w^!{+oMd=ne69An|D|y! zluue5Im2!F-h6w^qkT?p!bNt8cbV5#pRnEX&$zla>Xqi}_>Na?U*rxgj}W~y``3gC zDI0jcYQEl9=(TeCngZj-76WC|i2|bL(^Xp}S9Z3n*s)Vb@r;MBip$Znsho*!SxSmp zd3xR)#zDfIfrZ79PBSLX^62QAeOl;H&lMM^kUKHc1k#qM2`zf`Y|~ITs-D3*xg~Y$ Tads011_lOCS3j3^P6<r_c>@0c diff --git a/communicating_agent_example/images/redAnt.png b/communicating_agent_example/images/redAnt.png deleted file mode 100644 index 23e635766fc329daa4e828a3e56c8d1159b165f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 629 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&=~YLn`9lPCuI~ohWkT zP4z2J=5^M*OXl4Xev{bPo7@n@a5=eqm#0L+yc6%=p8p&?Uz6#4@MV)T!A{5c9G!%W z+!Au;n5ifxvm85?=}bkgT<D4Q)8Fsk|M$nw>x>nDZ%5BGjC*g_w@cA8asH|a$uhUP z-0x4~7cA<q)Qe~T^ZCr4uYarNoqO~8wA}oi=cfj=#<1RLdfD>dBYH9C&hTTQH^T3C zy{?}t{>j6L&+xO;x!-4Xr|(!l;bO}i|A_AnujPvP*Zw~fH-B2ysbAuYb}8;{|DYMx z`em7&ii)I;bM2{JxpRVEscPTxQBXYN;j7|u^lU0;qFa`dqE?=sH-~YMFlS(4air6X ziL*R9x@MmiI@EK;#VO=Y%rt?tC2B&89zEOCVxVj~Q9#sux@wE$%FdP*J9g>}aifmN ZmmF?MZ8~HzgMop8!PC{xWt~$(69BX+1&{y$ diff --git a/communicating_agent_example/images/yellowAnt.png b/communicating_agent_example/images/yellowAnt.png deleted file mode 100644 index 24676979b2ced1242739507a5bd5215d6abf94e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9l&bpX&C_sSq z?Em^Ls;v%N4!LZ+yjJr5l;-rgJEfI(#8mYtZRnY`EK!eBvW!D$(u72ow%*HaDk&0; ziI2A^a!R@-+_1>?aB35jF!Ph9Ou8sc@%rnhyL7hypR%X^ZD5+j`gnQwyAzgd@DDv< z#g}{Z=JqH4Eo+jloxaXhZ*AN^@BR79)AsIv^Ks_yc+SuhaR&r_r2iP__NqOJl&nsi zzfaVB{?`+pweHVC71JkutktY%f1~{V<Eja7e?Rj$uAX9|cw6?G@r7S}m2KC$Z~na- zR32%sxJvrcdjY$nt0vT~<QJO6Gi~9$R9WfeQ>spKnG1Vx7zYV+1{M}aI?b3k%cG-f z_GzI*Jy%?uLhi&&6G&U4Cba0$vrR1q%BB+qM9rtGwn(n*Y+12mr;g$o4__6Rqi0h& n6Wy|u6t(j7yob0^A6c81B&S-bum8Znz`)??>gTe~DWM4fti%O! diff --git a/communicating_agent_example/worldExample.py b/communicating_agent_example/worldExample.py deleted file mode 100644 index 838564c..0000000 --- a/communicating_agent_example/worldExample.py +++ /dev/null @@ -1,17 +0,0 @@ -""" -Class worldExample -""" -from pyAmakCore.classes.environment import Environment - - -class WorldExample(Environment): - - def __init__(self, xmin, xmax, ymin, ymax, field_of_view, coef_deplacement): - super().__init__() - self.xmin = xmin - self.xmax = xmax - self.ymin = ymin - self.ymax = ymax - - self.field_of_view = field_of_view - self.coef_deplacement = coef_deplacement diff --git a/proof_of_concept/2_phases_agent_cycle/antExample.py b/proof_of_concept/2_phases_agent_cycle/antExample.py deleted file mode 100644 index 7afcb15..0000000 --- a/proof_of_concept/2_phases_agent_cycle/antExample.py +++ /dev/null @@ -1,77 +0,0 @@ -""" -class antExample -""" -from math import * -from random import randint - -from pyAmakCore.classes.agent import Agent - -from color import Color - - -class AntExample(Agent): - - def __init__(self, - amas: 'antHillExample', - startX: float, - startY: float - ) -> None: - super().__init__(amas) - self._dx = startX - self._dy = startY - self._color = Color.BLACK - self._old_color = Color.BLACK - - self.__my_next_color = self._color - - def get_color(self): - return self._color - - def get_dx(self): - return self._dx - - def get_dy(self): - return self._dy - - def get_old_color(self): - return self._old_color - - def on_perceive(self) -> None: - self.reset_neighbour() - for agent in self.get_amas().get_agents(): - if agent != self : - self.__my_next_color = agent.get_color() - - def on_act(self) -> None: - # couleur - if self.__my_next_color == self._color: - color = { - 1: Color.BLUE, - 2: Color.BLACK, - 3: Color.RED, - 4: Color.YELLOW, - 5: Color.GREEN - } - if randint(1, 100) <= 4: - self._color = color.get(randint(1, 5)) - else : - self._color = self.__my_next_color - - # déplacement - self._dx += (randint(-1, 1) * self.get_environment().coef_deplacement) - self._dy += (randint(-1, 1) * self.get_environment().coef_deplacement) - - if self._dx < self.get_environment().xmin: - self._dx = self.get_environment().xmin - - if self._dx > self.get_environment().xmax: - self._dx = self.get_environment().xmax - - if self._dy < self.get_environment().ymin: - self._dy = self.get_environment().ymin - - if self._dy > self.get_environment().ymax: - self._dy = self.get_environment().ymax - - def on_cycle_begin(self): - self._old_color = self._color diff --git a/proof_of_concept/2_phases_agent_cycle/antHillExample.py b/proof_of_concept/2_phases_agent_cycle/antHillExample.py deleted file mode 100644 index adc03e9..0000000 --- a/proof_of_concept/2_phases_agent_cycle/antHillExample.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -class antHillExample -""" -from pyAmakCore.classes.tools.amasIHM import AmasIHM - -from antExample import AntExample - - -class AntHillExample(AmasIHM): - - def __init__(self, env): - super().__init__(env) - - def on_initial_agents_creation(self) -> None: - for i in range(2): - self.add_agent(AntExample(self, self.get_environment().xmax/2, self.get_environment().ymax/2)) \ No newline at end of file diff --git a/proof_of_concept/2_phases_agent_cycle/antsLaunchExample.py b/proof_of_concept/2_phases_agent_cycle/antsLaunchExample.py deleted file mode 100644 index beb64e6..0000000 --- a/proof_of_concept/2_phases_agent_cycle/antsLaunchExample.py +++ /dev/null @@ -1,25 +0,0 @@ -""" -Class antsLaunchExample -""" -from random import seed - -from pyAmakIHM.classes.fenetre import Fenetre -from controleurAntsExample import ControleurAntsExample -from worldExample import WorldExample -from antHillExample import * -from threading import Thread - -fenetre = Fenetre("Prototype Ants") - -seed() - -env = WorldExample(0, fenetre.get_canvas_width(), 0, fenetre.get_canvas_height(), 7) -amas = AntHillExample(env) - -controleur = ControleurAntsExample(fenetre, amas) - - -def main(): - controleur.start() - -main() diff --git a/proof_of_concept/2_phases_agent_cycle/color.py b/proof_of_concept/2_phases_agent_cycle/color.py deleted file mode 100644 index 939b45f..0000000 --- a/proof_of_concept/2_phases_agent_cycle/color.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import * -class Color(Enum): - BLACK= auto() - RED=auto() - BLUE=auto() - GREEN=auto() - YELLOW=auto() \ No newline at end of file diff --git a/proof_of_concept/2_phases_agent_cycle/controleurAntsExample.py b/proof_of_concept/2_phases_agent_cycle/controleurAntsExample.py deleted file mode 100644 index b512c2e..0000000 --- a/proof_of_concept/2_phases_agent_cycle/controleurAntsExample.py +++ /dev/null @@ -1,45 +0,0 @@ -from color import Color -from pyAmakIHM.classes.controleur import Controleur - - -class ControleurAntsExample(Controleur): - - def __init__(self, fenetre, amas): - super().__init__(fenetre, amas) - self.__ants = [] - self.__numberAnts = 2 - - def initialisation(self): - - widthCanvas = self.get_fenetre().get_canvas_width() - heightCanvas = self.get_fenetre().get_canvas_height() - - for i in range(self.__numberAnts): - self.__ants.append(self.draw_image(widthCanvas / 2, heightCanvas / 2, 'images/blackAnt.png')) - - def updateWindow(self, env, amas): - ants = amas.get_Agents_Sorted() - - for i in range(len(ants)): - x = ants[i].get_dx() - y = ants[i].get_dy() - color = ants[i].get_color() - - if color != ants[i].get_old_color(): - self.remove_element(self.__ants[i]) - if color == Color.BLUE: - self.__ants[i] = self.draw_image(x, y, 'images/blueAnt.png') - - elif color == Color.GREEN: - self.__ants[i] = self.draw_image(x, y, 'images/greenAnt.png') - - elif color == Color.RED: - self.__ants[i] = self.draw_image(x, y, 'images/redAnt.png') - - elif color == Color.YELLOW: - self.__ants[i] = self.draw_image(x, y, 'images/yellowAnt.png') - - elif color == Color.BLACK: - self.__ants[i] = self.draw_image(x, y, 'images/blackAnt.png') - - self.move_image(self.__ants[i], x, y) diff --git a/proof_of_concept/2_phases_agent_cycle/images/blackAnt.png b/proof_of_concept/2_phases_agent_cycle/images/blackAnt.png deleted file mode 100644 index ab4c4d0b27b9e43ed2f26f10d7566526363a59ed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 537 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_tsA9%VrhE&A8y>+pxDS?4C zvHE{|-bW_^bC0EU>VJ0KK6>|<q`&Hy88$&|a+*>GlNC00I|w)?u_alEDS4c6;5qKZ z(ka>TFrq`jkl9d%TTmrUp)Fal=?Kq}0v(qLGa4oOS~-M_1rBe-qiJX1gy$xIe=mFT zt$cl7r{-_Hb1zyuJ}rCxLc#dl?$A3`s^P3N51%=2dpcfjeO+9<|LKk42KC=dvy>BW zOwMI`Q+dzzUv8N3r>yApiT*ub4V5kXH`RXmF;TtB?1aa${!_M}&%4cgb5r5;@3S*M z|K7P@QZnUdOR3AG?-P`_`N{46x8+IjHMd7ET6gew-j&!D%+D&Ad_4P)sD7mNhIiE+ p3LC#Q5%d9B-ll^l51kY8KX?>V%jF!*85kHCJYD@<);T3K0RWDp&?Eo= diff --git a/proof_of_concept/2_phases_agent_cycle/images/blueAnt.png b/proof_of_concept/2_phases_agent_cycle/images/blueAnt.png deleted file mode 100644 index 4605bb5fd406aa8ff24943d60949e67e421871bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9lPQRTi9Vl|- z4O5WItzySaeb*%oEWbA%IA-Xe+3<3s>t9caguWBi-#-4ilHPUT^A!``&r>FBbe=Gw zrAJUgdO5G>35mvyg}125br=2g_xSqz_VN4vmNLZs{}z_kbA5OJ;yjO_8_TtxNVIQz zbaDF==N6fyzSGwk|JxYn*Y2OU-1zseO~=#U6|06QhBIzYuzF~J=~{-<yQzhu->z<d z^eg^(tIeby=QDdIe6A}#t@=(o#YFMB@HN{DyV~zKzqa3eefiRPoBp+~$n$uwSko1% zxOXK#rzhL#fccy9q?b>rI>}`&?7?9iB+MCDSRCmzW8y52j;`6Kg%0&xad8T{6EjU9 zZHb!DqDRj*wHPRyP81L|pRU>>xw5lm#g3giif250Ra}mqP325<%TiL*%G2{6;zoUB ZzrDF7_0EAU+zbp144$rjF6*2UngFJh5i<Y) diff --git a/proof_of_concept/2_phases_agent_cycle/images/greenAnt.png b/proof_of_concept/2_phases_agent_cycle/images/greenAnt.png deleted file mode 100644 index 331944103fbebe237d5f9351bf0b8111aa16b20b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 627 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCtUO&DLn`9lPWR0dP84C8 z{ClH<dMoR9=Cesl6kW8WHK+Q;+`E~za{lUl=Jx0PYnO4@`1@Wq@aL4YX5sWaA<?+8 z@YaNu9zhA|<-AnnR)#3vudDh0_x01~@$3)2=I5s#tJwS7;#HeUYwaqhzQPP`xms^K zmlKN5cGSpzIB)#<+V|I$R-4!BSJynV3wIJN5-s3fCj3u1w^!{+oMd=ne69An|D|y! zluue5Im2!F-h6w^qkT?p!bNt8cbV5#pRnEX&$zla>Xqi}_>Na?U*rxgj}W~y``3gC zDI0jcYQEl9=(TeCngZj-76WC|i2|bL(^Xp}S9Z3n*s)Vb@r;MBip$Znsho*!SxSmp zd3xR)#zDfIfrZ79PBSLX^62QAeOl;H&lMM^kUKHc1k#qM2`zf`Y|~ITs-D3*xg~Y$ Tads011_lOCS3j3^P6<r_c>@0c diff --git a/proof_of_concept/2_phases_agent_cycle/images/redAnt.png b/proof_of_concept/2_phases_agent_cycle/images/redAnt.png deleted file mode 100644 index 23e635766fc329daa4e828a3e56c8d1159b165f1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 629 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&=~YLn`9lPCuI~ohWkT zP4z2J=5^M*OXl4Xev{bPo7@n@a5=eqm#0L+yc6%=p8p&?Uz6#4@MV)T!A{5c9G!%W z+!Au;n5ifxvm85?=}bkgT<D4Q)8Fsk|M$nw>x>nDZ%5BGjC*g_w@cA8asH|a$uhUP z-0x4~7cA<q)Qe~T^ZCr4uYarNoqO~8wA}oi=cfj=#<1RLdfD>dBYH9C&hTTQH^T3C zy{?}t{>j6L&+xO;x!-4Xr|(!l;bO}i|A_AnujPvP*Zw~fH-B2ysbAuYb}8;{|DYMx z`em7&ii)I;bM2{JxpRVEscPTxQBXYN;j7|u^lU0;qFa`dqE?=sH-~YMFlS(4air6X ziL*R9x@MmiI@EK;#VO=Y%rt?tC2B&89zEOCVxVj~Q9#sux@wE$%FdP*J9g>}aifmN ZmmF?MZ8~HzgMop8!PC{xWt~$(69BX+1&{y$ diff --git a/proof_of_concept/2_phases_agent_cycle/images/yellowAnt.png b/proof_of_concept/2_phases_agent_cycle/images/yellowAnt.png deleted file mode 100644 index 24676979b2ced1242739507a5bd5215d6abf94e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 630 zcmeAS@N?(olHy`uVBq!ia0y~yU`PRB4mJh`hJr^^Ll_vCY&~5ZLn`9l&bpX&C_sSq z?Em^Ls;v%N4!LZ+yjJr5l;-rgJEfI(#8mYtZRnY`EK!eBvW!D$(u72ow%*HaDk&0; ziI2A^a!R@-+_1>?aB35jF!Ph9Ou8sc@%rnhyL7hypR%X^ZD5+j`gnQwyAzgd@DDv< z#g}{Z=JqH4Eo+jloxaXhZ*AN^@BR79)AsIv^Ks_yc+SuhaR&r_r2iP__NqOJl&nsi zzfaVB{?`+pweHVC71JkutktY%f1~{V<Eja7e?Rj$uAX9|cw6?G@r7S}m2KC$Z~na- zR32%sxJvrcdjY$nt0vT~<QJO6Gi~9$R9WfeQ>spKnG1Vx7zYV+1{M}aI?b3k%cG-f z_GzI*Jy%?uLhi&&6G&U4Cba0$vrR1q%BB+qM9rtGwn(n*Y+12mr;g$o4__6Rqi0h& n6Wy|u6t(j7yob0^A6c81B&S-bum8Znz`)??>gTe~DWM4fti%O! diff --git a/proof_of_concept/2_phases_agent_cycle/worldExample.py b/proof_of_concept/2_phases_agent_cycle/worldExample.py deleted file mode 100644 index 6393f82..0000000 --- a/proof_of_concept/2_phases_agent_cycle/worldExample.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -Class worldExample -""" -from pyAmakCore.classes.environment import Environment - - -class WorldExample(Environment): - - def __init__(self, xmin, xmax, ymin, ymax, coef_deplacement): - super().__init__() - self.xmin = xmin - self.xmax = xmax - self.ymin = ymin - self.ymax = ymax - - self.coef_deplacement = coef_deplacement -- GitLab