Thunderbots Project
Loading...
Searching...
No Matches
attacker_fsm.h
1#pragma once
2
3#include "proto/parameters.pb.h"
4#include "software/ai/evaluation/keep_away.h"
5#include "software/ai/evaluation/shot.h"
6#include "software/ai/hl/stp/tactic/chip/chip_fsm.h"
7#include "software/ai/hl/stp/tactic/pivot_kick/pivot_kick_fsm.h"
8#include "software/ai/hl/stp/tactic/tactic.h"
9#include "software/ai/passing/pass.h"
10
12{
18 explicit AttackerFSM(const TbotsProto::AiConfig& ai_config) : ai_config(ai_config) {}
19
21 {
22 // The best pass so far
23 std::optional<Pass> best_pass_so_far = std::nullopt;
24 // whether we have committed to the pass and will be taking it
25 bool pass_committed = false;
26 // The shot to take
27 std::optional<Shot> shot = std::nullopt;
28 // The point the robot will chip towards if it is unable to shoot and is in danger
29 // of losing the ball to an enemy
30 std::optional<Point> chip_target;
31 };
32
33 DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS
34
41 void pivotKick(const Update& event,
42 boost::sml::back::process<PivotKickFSM::Update> processEvent);
43
50 void keepAway(const Update& event,
51 boost::sml::back::process<DribbleFSM::Update> processEvent);
52
61 bool shouldKick(const Update& event);
62
63
64 auto operator()()
65 {
66 using namespace boost::sml;
67
68 DEFINE_SML_STATE(PivotKickFSM)
69 DEFINE_SML_STATE(DribbleFSM)
70 DEFINE_SML_EVENT(Update)
71
72 DEFINE_SML_GUARD(shouldKick)
73 DEFINE_SML_SUB_FSM_UPDATE_ACTION(pivotKick, PivotKickFSM)
74 DEFINE_SML_SUB_FSM_UPDATE_ACTION(keepAway, DribbleFSM)
75
76 return make_transition_table(
77 // src_state + event [guard] / action = dest_state
78 *DribbleFSM_S + Update_E[shouldKick_G] / pivotKick_A = PivotKickFSM_S,
79 DribbleFSM_S + Update_E[!shouldKick_G] / keepAway_A,
80 PivotKickFSM_S + Update_E / pivotKick_A, PivotKickFSM_S = X,
81 X + Update_E / SET_STOP_PRIMITIVE_ACTION = X);
82 }
83
84 private:
85 // the attacker tactic config
86 TbotsProto::AiConfig ai_config;
87};
Definition attacker_fsm.h:21
Definition attacker_fsm.h:12
AttackerFSM(const TbotsProto::AiConfig &ai_config)
Definition attacker_fsm.h:18
void keepAway(const Update &event, boost::sml::back::process< DribbleFSM::Update > processEvent)
Definition attacker_fsm.cpp:43
DEFINE_TACTIC_UPDATE_STRUCT_WITH_CONTROL_AND_COMMON_PARAMS void pivotKick(const Update &event, boost::sml::back::process< PivotKickFSM::Update > processEvent)
Definition attacker_fsm.cpp:3
bool shouldKick(const Update &event)
Definition attacker_fsm.cpp:91
Definition dribble_fsm.h:14
Definition pivot_kick_fsm.h:9