Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ scripts/rcssserver
logs/
__pycache__/
utils/__pycache__/
scripts/binary/
scripts/binary/
service_pb2_grpc.py
service_pb2.py
service_pb2.pyi
352 changes: 0 additions & 352 deletions service_pb2.py

This file was deleted.

2,479 changes: 0 additions & 2,479 deletions service_pb2.pyi

This file was deleted.

600 changes: 0 additions & 600 deletions service_pb2_grpc.py

This file was deleted.

4 changes: 3 additions & 1 deletion src/behaviors/bhv_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior

class Bhv_Block:

class Bhv_Block(IBehavior):
"""
Bhv_Block is a behavior class that determines whether an agent should block the ball based on the predicted future positions of the ball and the players.
Methods
Expand Down
87 changes: 87 additions & 0 deletions src/behaviors/bhv_kick_planner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from src.interfaces.IBehavior import IBehavior
from src.interfaces.IAgent import IAgent
from pyrusgeom.soccer_math import *
from pyrusgeom.geom_2d import *
from service_pb2 import *


class BhvKickPlanner(IBehavior):
"""
Decision maker class for an agent with the ball.

Methods
-------
__init__():
Initializes the WithBallDecisionMaker instance.

execute(agent: IAgent):
Makes a decision for the agent when it has the ball.

_get_helios_offensive_planner():
Returns an instance of HeliosOffensivePlanner.

_get_planner_evaluation(agent: IAgent):
Returns an instance of PlannerEvaluation.

_get_planner_evaluation_effector(agent: IAgent):
Returns an instance of PlannerEvaluationEffector.

_get_opponent_effector(agent: IAgent):
Determines the opponent effector based on the agent's world model.
"""

def __init__(self):
pass

def execute(self, agent: IAgent):
agent.logger.debug("--- WithBallDecisionMaker ---")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)

agent.add_action(
PlayerAction(helios_offensive_planner=self._get_helios_offensive_planner(agent))
)

def _get_helios_offensive_planner(self, agent):
""" Summary
In this function you can create an instance of HeliosOffensivePlanner and set its attributes.
The HeliosOffensivePlanner is a message that ask proxy to create a tree and find the best chain of actions and execute the first action of the chain.

Returns:
_type_: HeliosOffensivePlanner
"""
res = HeliosOffensivePlanner(evaluation=self._get_planner_evaluation(agent))
res.lead_pass = True
res.direct_pass = True
res.through_pass = True
res.simple_pass = True
res.short_dribble = True
res.long_dribble = True
res.simple_shoot = True
res.simple_dribble = True
res.cross = True

return res

def _get_planner_evaluation(self, agent: IAgent):
return PlannerEvaluation(
effectors=self._get_planner_evaluation_effector(agent),
)

def _get_planner_evaluation_effector(self, agent: IAgent):
return PlannerEvaluationEffector(
opponent_effector=self._get_opponent_effector(agent),
)

def _get_opponent_effector(self, agent: IAgent):
wm = agent.wm

if wm.ball.position.x > 30:
negetive_effect_by_distance = [-5, -4, -3, -2, -1]
else:
negetive_effect_by_distance = [-30, -25, -20, -15, -10, -4, -3, -2, -1]

return OpponentEffector(
negetive_effect_by_distance=negetive_effect_by_distance,
negetive_effect_by_distance_based_on_first_layer=False,
)
18 changes: 18 additions & 0 deletions src/behaviors/bhv_penalty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from src.interfaces.IAgent import IAgent
from src.utils.convertor import Convertor
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior


class BhvPenalty(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent) -> bool:
agent.logger.debug("BhvPenalty.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
agent.add_action(PlayerAction(helios_penalty=HeliosPenalty()))
18 changes: 18 additions & 0 deletions src/behaviors/bhv_setplay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from src.interfaces.IAgent import IAgent
from src.utils.convertor import Convertor
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior


class BhvSetPlay(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent) -> bool:
agent.logger.debug("BhvSetPlay.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
agent.add_action(PlayerAction(helios_set_play=HeliosSetPlay()))
16 changes: 16 additions & 0 deletions src/behaviors/bhv_starter_kick_planner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from src.interfaces.IBehavior import IBehavior
from src.interfaces.IAgent import IAgent
from pyrusgeom.soccer_math import *
from pyrusgeom.geom_2d import *
from service_pb2 import *


class BhvStarterKickPlanner(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent):
agent.logger.debug("BhvStarterKickPlanner.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
raise NotImplementedError("BhvStarterKickPlanner.execute not implemented")
18 changes: 18 additions & 0 deletions src/behaviors/bhv_starter_penalty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from src.interfaces.IAgent import IAgent
from src.utils.convertor import Convertor
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior


class BhvStarterPenalty(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent) -> bool:
agent.logger.debug("BhvStarterPenalty.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
raise NotImplementedError("BhvStarterPenalty.execute not implemented")
18 changes: 18 additions & 0 deletions src/behaviors/bhv_starter_setplay.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from src.interfaces.IAgent import IAgent
from src.utils.convertor import Convertor
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior


class BhvStarterSetPlay(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent) -> bool:
agent.logger.debug("BhvSetPlay.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
raise NotImplementedError("BhvStarterSetPlay.execute not implemented")
18 changes: 18 additions & 0 deletions src/behaviors/bhv_starter_tackle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from src.interfaces.IAgent import IAgent
from src.utils.convertor import Convertor
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior


class BhvStarterTackle(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent) -> bool:
agent.logger.debug("BhvStarterTackle.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
raise NotImplementedError("BhvStarterTackle.execute not implemented")
18 changes: 18 additions & 0 deletions src/behaviors/bhv_tackle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

from src.interfaces.IAgent import IAgent
from src.utils.convertor import Convertor
from pyrusgeom.geom_2d import *
from pyrusgeom.soccer_math import *
from service_pb2 import *
from src.interfaces.IBehavior import IBehavior


class BhvTackle(IBehavior):
def __init__(self):
pass

def execute(self, agent: IAgent) -> bool:
agent.logger.debug("BhvTackle.execute")
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
agent.add_action(PlayerAction(helios_basic_tackle=HeliosBasicTackle(min_prob=0.8, body_thr=100.0)))
80 changes: 7 additions & 73 deletions src/decision_makers/kick_decision_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,83 +3,17 @@
from pyrusgeom.soccer_math import *
from pyrusgeom.geom_2d import *
from service_pb2 import *
from src.behaviors.bhv_kick_planner import BhvKickPlanner
from src.behaviors.bhv_starter_kick_planner import BhvStarterKickPlanner


class KickDecisionMaker(IDecisionMaker):
"""
Decision maker class for an agent with the ball.

Methods
-------
__init__():
Initializes the WithBallDecisionMaker instance.

make_decision(agent: IAgent):
Makes a decision for the agent when it has the ball.

_get_helios_offensive_planner():
Returns an instance of HeliosOffensivePlanner.

_get_planner_evaluation(agent: IAgent):
Returns an instance of PlannerEvaluation.

_get_planner_evaluation_effector(agent: IAgent):
Returns an instance of PlannerEvaluationEffector.

_get_opponent_effector(agent: IAgent):
Determines the opponent effector based on the agent's world model.
"""

def __init__(self):
pass
self.bhv_kick_planner = BhvKickPlanner()
# self.bhv_kick_planner = BhvStarterKickPlanner()

def make_decision(self, agent: IAgent):
agent.logger.debug("--- WithBallDecisionMaker ---")

agent.add_action(
PlayerAction(helios_offensive_planner=self._get_helios_offensive_planner(agent))
)

def _get_helios_offensive_planner(self, agent):
""" Summary
In this function you can create an instance of HeliosOffensivePlanner and set its attributes.
The HeliosOffensivePlanner is a message that ask proxy to create a tree and find the best chain of actions and execute the first action of the chain.

Returns:
_type_: HeliosOffensivePlanner
"""
res = HeliosOffensivePlanner(evaluation=self._get_planner_evaluation(agent))
res.lead_pass = True
res.direct_pass = True
res.through_pass = True
res.simple_pass = True
res.short_dribble = True
res.long_dribble = True
res.simple_shoot = True
res.simple_dribble = True
res.cross = True

return res

def _get_planner_evaluation(self, agent: IAgent):
return PlannerEvaluation(
effectors=self._get_planner_evaluation_effector(agent),
)

def _get_planner_evaluation_effector(self, agent: IAgent):
return PlannerEvaluationEffector(
opponent_effector=self._get_opponent_effector(agent),
)

def _get_opponent_effector(self, agent: IAgent):
wm = agent.wm

if wm.ball.position.x > 30:
negetive_effect_by_distance = [-5, -4, -3, -2, -1]
else:
negetive_effect_by_distance = [-30, -25, -20, -15, -10, -4, -3, -2, -1]

return OpponentEffector(
negetive_effect_by_distance=negetive_effect_by_distance,
negetive_effect_by_distance_based_on_first_layer=False,
)
from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import
assert isinstance(agent, SamplePlayerAgent)
self.bhv_kick_planner.execute(agent)
Loading