Thunderbots Project
Loading...
Searching...
No Matches
enemy_threat.h
1#pragma once
2
3#include <optional>
4#include <vector>
5
6#include "software/world/world.h"
7
8// This struct stores the concept of an Enemy Threat. It contains all the necessary
9// information about an enemy robot and why it's threatening to the friendly team.
11{
12 // The enemy robot
13 Robot robot;
14
15 // Whether or not this robot has possession of the ball
16 bool has_ball;
17
18 // How much of the goal the enemy robot can see
19 // This does not account for obstacles
20 // For example, robots in the corner would have a very small angle
21 // while robots directly in front of the net would have a large angle
22 Angle goal_angle;
23
24 // The largest angle the robot has to shoot on the friendly net, taking obstacles
25 // into account
26 std::optional<Angle> best_shot_angle;
27
28 // The target the robot would shoot at
29 std::optional<Point> best_shot_target;
30
31 // How many passes it would take for this robot to get the ball
32 // 0 - The robot already has the ball
33 // 1 - The robot needs 1 pass to get the ball
34 // 2 - ...etc
35 int num_passes_to_get_possession;
36
37 // The robot that would pass to this robot if necessary
38 std::optional<Robot> passer;
39
40 // Define the equality operator for this struct since one is not generated by
41 // default. This is especially useful for the unit tests.
42 bool operator==(const EnemyThreat &other) const
43 {
44 return this->robot == other.robot && this->has_ball == other.has_ball &&
45 this->goal_angle == other.goal_angle &&
46 this->best_shot_angle == other.best_shot_angle &&
47 this->best_shot_target == other.best_shot_target &&
48 this->num_passes_to_get_possession == other.num_passes_to_get_possession &&
49 this->passer == other.passer;
50 }
51};
52
64std::map<Robot, std::vector<Robot>, Robot::cmpRobotByID> findAllReceiverPasserPairs(
65 const std::vector<Robot> &possible_passers,
66 const std::vector<Robot> &possible_receivers, const std::vector<Robot> &all_robots);
67
86std::optional<std::pair<int, std::optional<Robot>>> getNumPassesToRobot(
87 const Robot &initial_passer, const Robot &final_receiver, const Team &passing_team,
88 const Team &other_team);
89
98void sortThreatsInDecreasingOrder(std::vector<EnemyThreat> &threats);
99
117std::vector<EnemyThreat> getAllEnemyThreats(const Field &field, const Team &friendly_team,
118 Team enemy_team, const Ball &ball,
119 bool include_goalie);
Definition angle.h:15
Definition ball.h:11
Definition field.h:36
Definition robot.h:16
Definition team.h:15
Definition enemy_threat.h:11
Definition robot.h:228