Skip to content
Snippets Groups Projects
Commit f04b75f6 authored by shinedday's avatar shinedday
Browse files

Fix call private method

parent c4f35beb
Branches
Tags
No related merge requests found
......@@ -7,10 +7,10 @@ from typing import List
import sys
import pathlib
from pyAmakCore.exception.override import ToOverrideWarning
sys.path.insert(0, str(pathlib.Path(__file__).parent))
from pyAmakCore.exception.override import ToOverrideWarning
from pyAmakCore.enumeration.agent_phase import Phase
from pyAmakCore.enumeration.executionPolicy import ExecutionPolicy
......@@ -163,24 +163,24 @@ class Agent:
"""
ToOverrideWarning("on_act")
def __phase1(self) -> None:
def _phase1(self) -> None:
"""
this is the first phase of a cycle
"""
self.on_perceive()
self.compute_criticality()
self.__next_phase()
self._next_phase()
def __phase2(self) -> None:
def _phase2(self) -> None:
"""
this is the second phase of a cycle
"""
self.on_decide()
self.on_act()
self.compute_criticality()
self.__next_phase()
self._next_phase()
def __next_phase(self):
def _next_phase(self):
next_phase = {
Phase.INITIALIZING: Phase.PERCEPTION,
Phase.PERCEPTION: Phase.PERCEPTION_DONE,
......@@ -194,26 +194,26 @@ class Agent:
"""
Full cycle of an agent
"""
self.__next_phase()
self._next_phase()
execution_policy = self.__amas.get_execution_policy()
if execution_policy == ExecutionPolicy.TWO_PHASES:
if self.__phase == Phase.PERCEPTION:
self.on_cycle_begin()
self.__phase1()
self._phase1()
return
if self.__phase == Phase.DECISION_AND_ACTION:
self.__phase2()
self._phase2()
self.on_cycle_end()
return
if execution_policy == ExecutionPolicy.ONE_PHASE:
self.on_cycle_begin()
self.__phase1()
self.__next_phase()
self.__phase2()
self._phase1()
self._next_phase()
self._phase2()
self.on_cycle_end()
def __eq__(self, other: 'Agent') -> bool:
......
......@@ -101,17 +101,17 @@ class CommunicatingAgent(Agent):
"""
self.__mailbox.receive_mail(mail)
def __phase1(self):
def _phase1(self):
"""
Override of phase 1 agent so he read mail before he perceive
this is the first phase of a cycle
"""
self.read_mails()
self._read_mails()
self.on_perceive()
self.compute_criticality()
self.__next_phase()
self._next_phase()
def read_mails(self) -> None:
def _read_mails(self) -> None:
"""
method that open all mail in the mailbox
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment