Thunderbots Project
Loading...
Searching...
No Matches
enemy_ball_placement_play_fsm.h
1#pragma once
2
3#include "proto/parameters.pb.h"
4#include "shared/constants.h"
5#include "software/ai/hl/stp/play/play.h"
6#include "software/ai/hl/stp/tactic/crease_defender/crease_defender_tactic.h"
7#include "software/ai/hl/stp/tactic/goalie/goalie_tactic.h"
8#include "software/ai/hl/stp/tactic/move/move_tactic.h"
9#include "software/geom/algorithms/contains.h"
10#include "software/geom/algorithms/distance.h"
11#include "software/geom/stadium.h"
12#include "software/world/game_state.h"
13
46{
47 class WaitState;
48 class AvoidState;
49 class DefenseState;
50
52 {
53 };
54
55 DEFINE_PLAY_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS
56
62 explicit EnemyBallPlacementPlayFSM(TbotsProto::AiConfig ai_config);
63
69 bool hasPlacementPoint(const Update& event);
70
76 void setPlacementPoint(const Update& event);
77
83 bool isNearlyPlaced(const Update& event);
84
90 void avoid(const Update& event);
91
97 void enterDefensiveFormation(const Update& event);
98
99 auto operator()()
100 {
101 using namespace boost::sml;
102
103 DEFINE_SML_STATE(WaitState)
104 DEFINE_SML_STATE(AvoidState)
105 DEFINE_SML_STATE(DefenseState)
106
107 DEFINE_SML_EVENT(Update)
108
109 DEFINE_SML_ACTION(setPlacementPoint)
110 DEFINE_SML_ACTION(avoid)
111 DEFINE_SML_ACTION(enterDefensiveFormation)
112
113 DEFINE_SML_GUARD(hasPlacementPoint)
114 DEFINE_SML_GUARD(isNearlyPlaced)
115
116 return make_transition_table(
117 // src_state + event [guard] / action = dest_state
118 *WaitState_S + Update_E[hasPlacementPoint_G] / setPlacementPoint_A =
119 AvoidState_S,
120 WaitState_S + Update_E[!hasPlacementPoint_G] = WaitState_S,
121
122 AvoidState_S + Update_E[!isNearlyPlaced_G] / avoid_A = AvoidState_S,
123 AvoidState_S + Update_E[isNearlyPlaced_G] = DefenseState_S,
124
125 DefenseState_S + Update_E[isNearlyPlaced_G] / enterDefensiveFormation_A =
126 DefenseState_S,
127 DefenseState_S + Update_E[!isNearlyPlaced_G] = AvoidState_S);
128 }
129
130 private:
131 TbotsProto::AiConfig ai_config;
132 std::array<std::shared_ptr<CreaseDefenderTactic>, 2> crease_defender_tactics;
133 std::array<std::shared_ptr<AvoidInterferenceTactic>, 6> avoid_interference_tactics;
134 std::array<std::shared_ptr<MoveTactic>, 3> move_tactics;
135 std::shared_ptr<GoalieTactic> goalie_tactic;
136
137 Point placement_point;
138 double distance_to_keep_meters;
139 double nearly_placed_threshold_meters; // Threshold for the ball to be considered
140 // nearly placed
141};
Definition point.h:14
Definition enemy_ball_placement_play_fsm.h:52
Definition enemy_ball_placement_play_fsm.h:46
bool isNearlyPlaced(const Update &event)
Definition enemy_ball_placement_play_fsm.cpp:37
void enterDefensiveFormation(const Update &event)
Definition enemy_ball_placement_play_fsm.cpp:114
void setPlacementPoint(const Update &event)
Definition enemy_ball_placement_play_fsm.cpp:32
bool hasPlacementPoint(const Update &event)
Definition enemy_ball_placement_play_fsm.cpp:27
void avoid(const Update &event)
Definition enemy_ball_placement_play_fsm.cpp:43