Init
This commit is contained in:
45
behaviors/behavior.py
Normal file
45
behaviors/behavior.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class Behavior(ABC):
|
||||
"""
|
||||
Base interface for skills.
|
||||
Each skill must implement:
|
||||
- execute(reset: bool, *args) -> bool
|
||||
- is_ready(*args) -> bool
|
||||
"""
|
||||
|
||||
def __init__(self, agent):
|
||||
from agent.base_agent import Base_Agent # type hinting
|
||||
|
||||
self.agent: Base_Agent = agent
|
||||
|
||||
@abstractmethod
|
||||
def execute(self, reset: bool, *args, **kwargs) -> bool:
|
||||
"""
|
||||
Executes one step of the skill.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
reset : bool
|
||||
Indicates if this is the first invocation of this skill (should reset internal state).
|
||||
*args
|
||||
Skill-specific arguments.
|
||||
|
||||
Returns
|
||||
-------
|
||||
finished : bool
|
||||
True if the skill has finished execution.
|
||||
"""
|
||||
raise NotImplementedError("Method 'execute' must be implemented in the Skill.")
|
||||
|
||||
@abstractmethod
|
||||
def is_ready(self, *args) -> bool:
|
||||
"""
|
||||
Checks if the current conditions allow starting the skill.
|
||||
|
||||
Returns
|
||||
-------
|
||||
ready : bool
|
||||
"""
|
||||
raise NotImplementedError("Method 'is_ready' must be implemented in the Skill.")
|
||||
Reference in New Issue
Block a user