|
3 | 3 | from pyrusgeom.soccer_math import * |
4 | 4 | from pyrusgeom.geom_2d import * |
5 | 5 | from service_pb2 import * |
| 6 | +from src.behaviors.bhv_kick_planner import BhvKickPlanner |
| 7 | +from src.behaviors.bhv_starter_kick_planner import BhvStarterKickPlanner |
6 | 8 |
|
7 | 9 |
|
8 | 10 | class KickDecisionMaker(IDecisionMaker): |
9 | | - """ |
10 | | - Decision maker class for an agent with the ball. |
11 | | -
|
12 | | - Methods |
13 | | - ------- |
14 | | - __init__(): |
15 | | - Initializes the WithBallDecisionMaker instance. |
16 | | -
|
17 | | - make_decision(agent: IAgent): |
18 | | - Makes a decision for the agent when it has the ball. |
19 | | - |
20 | | - _get_helios_offensive_planner(): |
21 | | - Returns an instance of HeliosOffensivePlanner. |
22 | | - |
23 | | - _get_planner_evaluation(agent: IAgent): |
24 | | - Returns an instance of PlannerEvaluation. |
25 | | - |
26 | | - _get_planner_evaluation_effector(agent: IAgent): |
27 | | - Returns an instance of PlannerEvaluationEffector. |
28 | | - |
29 | | - _get_opponent_effector(agent: IAgent): |
30 | | - Determines the opponent effector based on the agent's world model. |
31 | | - """ |
32 | | - |
33 | 11 | def __init__(self): |
34 | | - pass |
| 12 | + self.bhv_kick_planner = BhvKickPlanner() |
| 13 | + # self.bhv_kick_planner = BhvStarterKickPlanner() |
35 | 14 |
|
36 | 15 | def make_decision(self, agent: IAgent): |
37 | 16 | agent.logger.debug("--- WithBallDecisionMaker ---") |
38 | | - |
39 | | - agent.add_action( |
40 | | - PlayerAction(helios_offensive_planner=self._get_helios_offensive_planner(agent)) |
41 | | - ) |
42 | | - |
43 | | - def _get_helios_offensive_planner(self, agent): |
44 | | - """ Summary |
45 | | - In this function you can create an instance of HeliosOffensivePlanner and set its attributes. |
46 | | - 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. |
47 | | -
|
48 | | - Returns: |
49 | | - _type_: HeliosOffensivePlanner |
50 | | - """ |
51 | | - res = HeliosOffensivePlanner(evaluation=self._get_planner_evaluation(agent)) |
52 | | - res.lead_pass = True |
53 | | - res.direct_pass = True |
54 | | - res.through_pass = True |
55 | | - res.simple_pass = True |
56 | | - res.short_dribble = True |
57 | | - res.long_dribble = True |
58 | | - res.simple_shoot = True |
59 | | - res.simple_dribble = True |
60 | | - res.cross = True |
61 | | - |
62 | | - return res |
63 | | - |
64 | | - def _get_planner_evaluation(self, agent: IAgent): |
65 | | - return PlannerEvaluation( |
66 | | - effectors=self._get_planner_evaluation_effector(agent), |
67 | | - ) |
68 | | - |
69 | | - def _get_planner_evaluation_effector(self, agent: IAgent): |
70 | | - return PlannerEvaluationEffector( |
71 | | - opponent_effector=self._get_opponent_effector(agent), |
72 | | - ) |
73 | | - |
74 | | - def _get_opponent_effector(self, agent: IAgent): |
75 | | - wm = agent.wm |
76 | | - |
77 | | - if wm.ball.position.x > 30: |
78 | | - negetive_effect_by_distance = [-5, -4, -3, -2, -1] |
79 | | - else: |
80 | | - negetive_effect_by_distance = [-30, -25, -20, -15, -10, -4, -3, -2, -1] |
81 | | - |
82 | | - return OpponentEffector( |
83 | | - negetive_effect_by_distance=negetive_effect_by_distance, |
84 | | - negetive_effect_by_distance_based_on_first_layer=False, |
85 | | - ) |
| 17 | + from src.sample_player_agent import SamplePlayerAgent # Local import to avoid circular import |
| 18 | + assert isinstance(agent, SamplePlayerAgent) |
| 19 | + self.bhv_kick_planner.execute(agent) |
0 commit comments