12
12
#include " ai/hl/stp/tactic/crease_defender_tactic.h"
13
13
#include " ai/hl/stp/tactic/goalie_tactic.h"
14
14
#include " ai/hl/stp/tactic/move_tactic.h"
15
+ #include " ai/hl/stp/tactic/patrol_tactic.h"
15
16
#include " ai/hl/stp/tactic/shadow_enemy_tactic.h"
16
17
#include " ai/hl/stp/tactic/shoot_goal_tactic.h"
17
18
#include " ai/hl/stp/tactic/stop_tactic.h"
@@ -31,12 +32,21 @@ std::string ShootOrChipPlay::getName() const
31
32
32
33
bool ShootOrChipPlay::isApplicable (const World &world) const
33
34
{
34
- return world.gameState ().isPlaying () &&
35
+ bool use_shoot_or_pass_instead_of_shoot_or_chip =
36
+ Util::DynamicParameters::HighLevelStrategy::
37
+ use_shoot_or_pass_instead_of_shoot_or_chip.value ();
38
+
39
+ return !use_shoot_or_pass_instead_of_shoot_or_chip && world.gameState ().isPlaying () &&
35
40
Evaluation::teamHasPossession (world, world.friendlyTeam ());
36
41
}
37
42
38
43
bool ShootOrChipPlay::invariantHolds (const World &world) const
39
44
{
45
+
46
+ // bool use_shoot_or_pass_instead_of_shoot_or_chip =
47
+ // Util::DynamicParameters::HighLevelStrategy::
48
+ // use_shoot_or_pass_instead_of_shoot_or_chip.value();
49
+
40
50
return world.gameState ().isPlaying () &&
41
51
Evaluation::teamHasPossession (world, world.friendlyTeam ());
42
52
}
@@ -65,6 +75,23 @@ void ShootOrChipPlay::getNextTactics(TacticCoroutine::push_type &yield)
65
75
CreaseDefenderTactic::LeftOrRight::RIGHT),
66
76
};
67
77
78
+ std::array<std::shared_ptr<PatrolTactic>, 2 > patrol_tactics = {
79
+ std::make_shared<PatrolTactic>(
80
+ std::vector<Point >(
81
+ {Point (world.field ().enemyCornerPos ().x () - 3 * ROBOT_MAX_RADIUS_METERS,
82
+ world.field ().enemyCornerPos ().y () - 3 * ROBOT_MAX_RADIUS_METERS),
83
+ Point (3 * ROBOT_MAX_RADIUS_METERS,
84
+ world.field ().width () / 2 - 3 * ROBOT_MAX_RADIUS_METERS)}),
85
+ .03 , 0 ),
86
+ std::make_shared<PatrolTactic>(
87
+ std::vector<Point >(
88
+ {Point (3 * ROBOT_MAX_RADIUS_METERS,
89
+ -world.field ().width () / 2 + 3 * ROBOT_MAX_RADIUS_METERS),
90
+ Point (
91
+ world.field ().enemyCornerNeg ().x () - 3 * ROBOT_MAX_RADIUS_METERS,
92
+ world.field ().enemyCornerNeg ().y () + 3 * ROBOT_MAX_RADIUS_METERS)}),
93
+ .03 , 0 )};
94
+
68
95
std::array<std::shared_ptr<MoveTactic>, 2 > move_to_open_area_tactics = {
69
96
std::make_shared<MoveTactic>(true ), std::make_shared<MoveTactic>(true )};
70
97
@@ -140,13 +167,19 @@ void ShootOrChipPlay::getNextTactics(TacticCoroutine::push_type &yield)
140
167
shoot_or_chip_tactic->addWhitelistedAvoidArea (AvoidArea::HALF_METER_AROUND_BALL);
141
168
auto shoot_goal_robot = shoot_or_chip_tactic->getAssignedRobot ();
142
169
if (shoot_goal_robot && (dist (shoot_goal_robot->position (), world.ball ().position ()) < 4 * ROBOT_MAX_RADIUS_METERS)
143
- && shoot_goal_robot->velocity ().len () < 0.75 ) {
170
+ && shoot_goal_robot->velocity ().len () < 0.5 ) {
144
171
shoot_or_chip_tactic->addWhitelistedAvoidArea (AvoidArea::ENEMY_ROBOTS);
145
172
}
146
173
147
174
// We want this second in priority only to the goalie
148
175
result.insert (result.begin () + 1 , shoot_or_chip_tactic);
149
176
177
+ // If we can't do anything else then patrol?
178
+ for (auto &patrol_tactic : patrol_tactics)
179
+ {
180
+ result.emplace_back (patrol_tactic);
181
+ }
182
+
150
183
// yield the Tactics this Play wants to run, in order of priority
151
184
yield (result);
152
185
0 commit comments