Skip to content

Commit 13f04e4

Browse files
nimazareiansauravbannapre-commit-ci-lite[bot]
authored
New passing and receiving architecture and tuned offense strategy (UBC-Thunderbots#3200)
* added pass speed cost function * testing * testing * test * test * testing * testing * testing * test * fix * fixed cost function * formatting * fix * test * test * test * fix tests * formatting + docs * formatting + docs * test * test * added tests for backward passes * uncomment + formatting * docs * fix * added new field tets for passing * fix * fixed tests * fix * fix * fix tests * fix? * fix? * fix tests * [pre-commit.ci lite] apply automatic fixes * implemented new pass changes * fix * removed unecessary changes * [pre-commit.ci lite] apply automatic fixes * formatting * fix types * fix * testing changes * fix * [pre-commit.ci lite] apply automatic fixes * removed unecessary changes * WIP error with map brace initialization in play.cpp * Visualize shapes in debug layer * Visualize other shapes * todo * fix * Revert "fix" This reverts commit 7b127db. * [pre-commit.ci lite] apply automatic fixes * formatting * fix bug * Update to use map and visualize 3 shapes * clean up * formatting * cleanup * fix * bug * Cleanup parameter names * [pre-commit.ci lite] apply automatic fixes * fix tests * [pre-commit.ci lite] apply automatic fixes * merge * fix build * test * fix * fix * address comments * [pre-commit.ci lite] apply automatic fixes * new sampling pass generator * Initial jank working implementation * updated rateZoneSmart based on previous implementation. Should visualize and check * Not sure why there's no pass cost viz * fixing stuff * fix bug * Fix bug * tune some constants, update viz, and formatting * updated recv rating and added some code. * spread out receivers * freeze layers if sim paused * Update debug shapes to include unique ID * wip * fix heatmap visualization * cleanup and additional fixed * Update some parameter constants + fix calculateInterceptRisk * Merge prev changes * Update calculateInterceptRisk and ratePassShootScore * fix typo * changes * Keepaway doesn't look away unless in risk, receiver positions are spread out better, * add simulation speed control * Fix abort pass constants which improves one touch kick chance. Update pass visualization colors if comitted * Update variable sim speed to use qmenu * add ReceiverTacticConfig * Receivers position themselves based on pass destination for passes in flight * Remove unnecessary check in AttackerFSM::shouldKick * Update freekick play * Use Pass::fromDestReceiveSpeed * refactor keepaway cost functions and visualize them * Don't refresh layers if sim is paused * Added createAttackerVisualization proto. Need to update tscope to visualize it * Add gl_attacker_layer.py * Formatting * Add shortcut for changing sim speed * Add attacker tactic visualizations, thunderscope sim speed control, update debug shapes layer * Add function docs * update calculateInterceptRisk and add constants to parameters.proto * Reorder parameters for passing for visualization and add new params for sampling_pass_generator.cpp * address comments + fix tests * fix * fix * Build with optimization flags by default and don't run under GDB by default * Remove -o comment * Support ignoring robots to pass to and Remove BasePassGenerator * Add score for open angle for ratePassShootScore * clean up ratePassShootScore and add constants to parameters.proto * Add passing config to most cost functions and cleanup. KeepAwayTest is failing * Fix calculateProximityRisk * Fix merge * Move more constants to parameters.proto Add documentation to receiver_position_generator.hpp * Fix tests in cost_function_test.cpp and remove TODOs. Visualize additional cost functions * Add tests for newly added cost functions * fix shoot_or_pass_play_fsm_test.cpp * add size check to shoot_or_pass_play_fsm.cpp * update attacker_tactic_keep_away_test.cpp to ignore checks * remove extra passing_sim_test.py due to bad merge * Fix formatting * Move debug pass visualizations to parameters.proto * WIP receiver_position_generator_test.cpp * Replace sampling_pass_generator with gradient_descent_pass_generator * Added ratePassNotTooClose and formatting * Update gradient_descent_pass_generator to store prev best passes per robot * some cleanup * todo * Make sampling circle dynamic * some cleanup * formatting * cleanup receiver_position_generator * address some of the comments * Remove old pass gen code * Add tests for new pass gen * remove extra cost functions * update ShootOrPassPlayFSM::passFound to stop the passes from being aborted early * Remove old TODOs * Revert Thunderscope changes * Some more cleanup * Add enemy_interception_time_multiplier * wip fixes * formatting * fix shoot or pass fsm test * Addressing PR comments * Add tests for receiver_position_generator * Fix tests * cleanup * Re-enable old tests * Use normalizeValueToRange * address some comments * add TODO for ball model * Remove dup comment * fix bug in pytest sequenced eventual validations * Cleanup passing_sim_test.py and few small bug fixes * [pre-commit.ci lite] apply automatic fixes * disable shoot_or_pass_play_test.cpp again * Address comments * fix * rename disable_one_touch_kick to enable_one_touch_kick to match qleaning gameplay branch * remove test --------- Co-authored-by: sauravbanna <sauravbanna@gmail.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent be71076 commit 13f04e4

57 files changed

Lines changed: 1923 additions & 1819 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/proto/parameters.proto

Lines changed: 191 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ message AiConfig
4141
required DefensePlayConfig defense_play_config = 11;
4242
required RobotNavigationObstacleConfig robot_navigation_obstacle_config = 12;
4343
required AiParameterConfig ai_parameter_config = 13;
44+
required ReceiverTacticConfig receiver_tactic_config = 14;
4445
}
4546

4647
message AiControlConfig
@@ -64,12 +65,34 @@ message AttackerTacticConfig
6465
// The radius of the circle around a friendly robot around which
6566
// we think an enemy is about to steal the ball
6667
required double enemy_about_to_steal_ball_radius = 1
67-
[default = 0.1, (bounds).min_double_value = 0.0, (bounds).max_double_value = 4.0];
68+
[default = 0.4, (bounds).min_double_value = 0.0, (bounds).max_double_value = 4.0];
6869

6970
// The minimum open angle to the goal that we require before taking a shot
7071
required double min_open_angle_for_shot_deg = 2 [
7172
default = 6.0,
72-
(bounds).min_double_value = 0.0,
73+
(bounds).min_double_value = 0.1,
74+
(bounds).max_double_value = 90.0
75+
];
76+
}
77+
78+
message ReceiverTacticConfig
79+
{
80+
// Whether one touch kicks should be enabled or not
81+
required bool enable_one_touch_kick = 1 [default = true];
82+
83+
// The minimum open angle to the goal that we require before taking a one touch kick
84+
required double min_open_angle_for_one_touch_deg = 2 [
85+
default = 6.0,
86+
(bounds).min_double_value = 0.1,
87+
(bounds).max_double_value = 90.0
88+
];
89+
90+
// TODO (#2570): try to make it as big as possible when tuning
91+
// The maximum deflection angle that we will attempt a one-touch kick towards the
92+
// enemy goal
93+
required double max_deflection_for_one_touch_deg = 3 [
94+
default = 60.0,
95+
(bounds).min_double_value = 10.0,
7396
(bounds).max_double_value = 90.0
7497
];
7598
}
@@ -84,6 +107,52 @@ message CornerKickPlayConfig
84107

85108
message PassingConfig
86109
{
110+
// Note that the order the fields are defined here is the order that
111+
// they are displayed in Thunderscope's Parameters widget, and the order
112+
// is independent of the field's numbering.
113+
114+
reserved 8, 5;
115+
116+
/***** Pass generation parameters *****/
117+
// The number of passes to sample per robot.
118+
required uint32 pass_gen_num_samples_per_robot = 21
119+
[default = 5, (bounds).min_int_value = 1, (bounds).max_int_value = 100];
120+
// The minimum standard deviation (in meters) of the normal sampling distribution
121+
// used to generate passes around robots. This STD is used when the robot is
122+
// stationary.
123+
required double pass_gen_min_rand_sample_std_dev_meters = 22 [
124+
default = 0.4,
125+
(bounds).min_double_value = 0.01,
126+
(bounds).max_double_value = 3.0
127+
];
128+
// The rate of growth of the STD as the robot velocity increases.
129+
required double pass_gen_rand_sample_std_dev_robot_vel_multiplier = 23 [
130+
default = 0.15,
131+
(bounds).min_double_value = 0.0,
132+
(bounds).max_double_value = 0.5
133+
];
134+
// The rate of growth of the distance offset of the center of the normal
135+
// distribution as the robot velocity increases. If set to 0, the center
136+
// of the sampled receiving positions will be the same as the robot's position.
137+
required double pass_gen_rand_sample_center_robot_vel_multiplier = 24
138+
[default = 0.3, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
139+
// The minimum pass speed (in m/s)
140+
required double min_pass_speed_m_per_s = 6
141+
[default = 2.0, (bounds).min_double_value = 0.0, (bounds).max_double_value = 5.0];
142+
// The maximum pass speed (in m/s)
143+
required double max_pass_speed_m_per_s = 7 [
144+
default = 6.0,
145+
(bounds).min_double_value = 0.0,
146+
(bounds).max_double_value = 10.0
147+
];
148+
// The max speed at which a pass should be received
149+
required double max_receive_speed_m_per_s = 11
150+
[default = 2.0, (bounds).min_double_value = 1.0, (bounds).max_double_value = 4.0];
151+
// The number of steps of gradient descent to perform in each iteration
152+
required int32 number_of_gradient_descent_steps_per_iter = 9
153+
[default = 2, (bounds).min_int_value = 0, (bounds).max_int_value = 100];
154+
155+
/***** Cost function parameters *****/
87156
// The offset from the sides of the field to place the rectangular
88157
// sigmoid we use to determine what areas to pass to
89158
required double static_field_position_quality_x_offset = 1
@@ -97,45 +166,108 @@ message PassingConfig
97166
// to the goal having less of an effect.
98167
required double static_field_position_quality_friendly_goal_distance_weight = 3
99168
[default = 0.3, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
169+
// The estimated delay in seconds between the time we commit to a pass and the time
170+
// the pass is taken.
171+
required double pass_delay_sec = 12
172+
[default = 0.3, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
173+
// The extra time added to the minimum time that it will take a friendly
174+
// robot to reach the receiving position and orientation.
175+
required double friendly_time_to_receive_slack_sec = 13
176+
[default = 0.1, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
100177
// This controls how heavily we weigh an enemy robot being near the pass
101178
// receiver when calculating enemy risk to a pass
102179
required double enemy_proximity_importance = 4 [
103180
default = 0.5,
104-
(bounds).min_double_value = 0.0,
181+
(bounds).min_double_value = 0.01,
105182
(bounds).max_double_value = 10.0
106183
];
107-
// The maximum angle that we have to rotate after receiving a pass to
108-
// shoot that we think would likely result in a goal. Note that we may
109-
// try to take shots that require us to rotate more then this, it's more
110-
// of a soft limit.
111-
required double ideal_max_rotation_to_shoot_degrees = 5 [
112-
default = 60.0,
184+
// A value multiplied by the duration that our enemy robot model predicts will
185+
// take an enemy robot to intercept a pass. 1 implies that our enemy robot model
186+
// is exactly correct, with higher values meaning that the enemy will take longer
187+
// to intercept the pass, and lower values meaning that the enemy will intercept
188+
// the pass earlier than we anticipate.
189+
required double enemy_interception_time_multiplier = 14 [
190+
default = 1.0,
113191
(bounds).min_double_value = 0.0,
114-
(bounds).max_double_value = 180.0
192+
(bounds).max_double_value = 10.0
115193
];
116-
// The minimum pass speed (in m/s)
117-
required double min_pass_speed_m_per_s = 6
118-
[default = 1, (bounds).min_double_value = 0.0, (bounds).max_double_value = 5.0];
119-
// The maximum pass speed (in m/s)
120-
required double max_pass_speed_m_per_s = 7 [
121-
default = 6.0,
194+
// This controls how heavily we weigh the time the enemy team has to intercept a pass.
195+
// Increasing this value increases the risk (decreasing the score) associated with a
196+
// pass that the enemy could intercept.
197+
required double enemy_interception_risk_importance = 15 [
198+
default = 4.0,
122199
(bounds).min_double_value = 0.0,
123-
(bounds).max_double_value = 10.0
200+
(bounds).max_double_value = 20.0
124201
];
125-
// How long we think the enemy will take to recognize we're passing and start
126-
// moving to intercept
127-
required double enemy_reaction_time = 8
128-
[default = 0.4, (bounds).min_double_value = 0.0, (bounds).max_double_value = 3.0];
129-
// The number of steps of gradient descent to perform in each iteration
130-
required int32 number_of_gradient_descent_steps_per_iter = 9
131-
[default = 2, (bounds).min_int_value = 0, (bounds).max_int_value = 100];
132-
// Cost visualization parameters
202+
// The distance in meters along the x-axis from the passer that we prefer the receiver
203+
// to be when receiving a pass on the friendly half. Note that this is a soft limit
204+
// and the receiver may be further back.
205+
required double backwards_pass_distance_meters = 16 [
206+
default = -1.0,
207+
(bounds).min_double_value = -10.0,
208+
(bounds).max_double_value = 5.0
209+
];
210+
// The max distance in meters that the receiver can be from the passer when receiving
211+
// a pass.
212+
required double receiver_ideal_max_distance_meters = 17 [
213+
default = 10.0,
214+
(bounds).min_double_value = 0.1,
215+
(bounds).max_double_value = 20.0
216+
];
217+
// The min distance in meters that the receiver can be from the passer when receiving
218+
// a pass.
219+
required double receiver_ideal_min_distance_meters = 18 [
220+
default = 1.5,
221+
(bounds).min_double_value = 0.1,
222+
(bounds).max_double_value = 20.0
223+
];
224+
// The minimum open angle (in degrees) for an ideal shot on enemy goal from the
225+
// receiver's position. Any angle greater than this is also considered ideal, where as
226+
// angles below this are considered less ideal and are given a lower score.
227+
required double min_ideal_pass_shoot_goal_open_angle_deg = 19 [
228+
default = 10.0,
229+
(bounds).min_double_value = 1.0,
230+
(bounds).max_double_value = 45.0
231+
];
232+
// The min score that ratePassShootScore return. Used to limit the cost function
233+
// from returning a very low score, causing the rest of the cost functions to be
234+
// ignored.
235+
required double min_pass_shoot_score = 20
236+
[default = 0.5, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
237+
238+
/***** Visualization parameters *****/
239+
// Cost function visualization parameters
133240
required CostVisualizationConfig cost_vis_config = 10;
134-
// The max speed at which a pass should be received
135-
required double max_receive_speed = 11
136-
[default = 2.0, (bounds).min_double_value = 1.0, (bounds).max_double_value = 4.0];
137-
required double backwards_pass_distance = 13
138-
[default = 0.5, (bounds).min_double_value = 0.0, (bounds).max_double_value = 2.0];
241+
// Pass generator visualization parameters
242+
required PassGeneratorVisualizationConfig pass_gen_vis_config = 25;
243+
244+
/***** Receiver position generation parameters *****/
245+
required ReceiverPositionGeneratorConfig receiver_position_generator_config = 26;
246+
}
247+
248+
message ReceiverPositionGeneratorConfig
249+
{
250+
// A multiplier to incentivize using the same receiver position as the previous
251+
// iteration
252+
required double previous_best_receiver_position_score_multiplier = 1
253+
[default = 1.5, (bounds).min_double_value = 1.0, (bounds).max_double_value = 3.0];
254+
// The number of samples to generate initially for each zone to get a sense of the
255+
// best zones.
256+
required uint32 num_initial_samples_per_zone = 2
257+
[default = 5, (bounds).min_int_value = 1, (bounds).max_int_value = 100];
258+
// The number of additional samples to generate for the top zones after the initial
259+
// samples. Used to get a more accurate max score.
260+
required uint32 num_additional_samples_per_top_zone = 3
261+
[default = 20, (bounds).min_int_value = 1, (bounds).max_int_value = 100];
262+
// The minimum angle (in degrees) between a receiver, the ball, and a previously
263+
// selected receiver.
264+
required double min_angle_between_receivers_deg = 4 [
265+
default = 20.0,
266+
(bounds).min_double_value = 0.0,
267+
(bounds).max_double_value = 45.0
268+
];
269+
270+
required ReceiverPositionGeneratorVisualizationConfig receiver_vis_config = 5;
139271
}
140272

141273
message GoalieTacticConfig
@@ -246,6 +378,14 @@ message ShootOrPassPlayConfig
246378
(bounds).max_double_value = 1.0
247379
];
248380

381+
// The minimum pass quality we're willing to attempt before ramping
382+
// down the score to abs_min_pass_score
383+
required double min_perfect_pass_score = 6 [
384+
default = 0.85,
385+
(bounds).min_double_value = 0.0,
386+
(bounds).max_double_value = 1.0
387+
];
388+
249389
// When we're choosing a pass, we start by looking for a pass with a perfect score
250390
// of 1, and then over time lower the score we're will to accept. This parameter
251391
// how fast we ramp down to abs_min_pass_score. This is in seconds.
@@ -254,11 +394,11 @@ message ShootOrPassPlayConfig
254394

255395
// threshold to decide if the ball has been kicked by a robot
256396
required double ball_shot_threshold = 3
257-
[default = 4.0, (bounds).min_double_value = 0.0, (bounds).max_double_value = 5.0];
397+
[default = 1.0, (bounds).min_double_value = 0.0, (bounds).max_double_value = 5.0];
258398

259399
// threshold to decide if the ball has been kicked by a robot
260400
required double min_distance_to_pass = 4
261-
[default = 0.1, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
401+
[default = 0.2, (bounds).min_double_value = 0.0, (bounds).max_double_value = 1.0];
262402

263403
// threshold for the distance between passer and receiver
264404
required double short_pass_threshold = 5
@@ -423,10 +563,28 @@ message CostVisualizationConfig
423563
required int32 num_cols = 2
424564
[default = 45, (bounds).min_int_value = 1, (bounds).max_int_value = 100];
425565
// cost functions
426-
required bool static_position_quality = 3 [default = false];
566+
required bool static_position_quality = 3 [default = false];
567+
required bool pass_forward_quality = 7 [default = false];
568+
required bool pass_not_too_close_quality = 8 [default = false];
569+
427570
required bool pass_friendly_capability = 4 [default = false];
428571
required bool pass_enemy_risk = 5 [default = false];
429572
required bool pass_shoot_score = 6 [default = false];
573+
required bool enemy_proximity_risk = 9 [default = false];
574+
required bool enemy_interception_risk = 10 [default = false];
575+
576+
required bool passer_position_score = 11 [default = false];
577+
required bool receiver_position_score = 12 [default = false];
578+
}
579+
580+
message PassGeneratorVisualizationConfig
581+
{
582+
required bool visualize_sampled_passes = 1 [default = false];
583+
}
584+
585+
message ReceiverPositionGeneratorVisualizationConfig
586+
{
587+
required bool visualize_best_receiving_positions_and_zones = 1 [default = false];
430588
}
431589

432590
message PossessionTrackerConfig

src/shared/constants.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ static const char PROTO_MSG_TYPE_DELIMITER[4] = "!!!";
5353

5454
/* Game Rules */
5555
// The max allowed speed of the ball, in metres per second
56+
// https://robocup-ssl.github.io/ssl-rules/sslrules.html#_ball_speed
5657
static const double BALL_MAX_SPEED_METERS_PER_SECOND = 6.5;
58+
// The safe max speed of the ball that we should shoot at, in metres per second
59+
static const double BALL_SAFE_MAX_SPEED_METERS_PER_SECOND =
60+
BALL_MAX_SPEED_METERS_PER_SECOND - 0.5;
5761
// The max allowed height of the robots, in metres
5862
static const double ROBOT_MAX_HEIGHT_METERS = 0.15;
5963
// The max allowed radius of the robots, in metres

src/software/BUILD

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,8 @@ pybind_library(
8585
"//shared:robot_constants",
8686
"//software:constants",
8787
"//software/ai/passing:eighteen_zone_pitch_division",
88-
"//software/ai/passing:pass",
89-
"//software/ai/passing:pass_evaluation",
9088
"//software/ai/passing:pass_generator",
89+
"//software/ai/passing:receiver_position_generator",
9190
"//software/estop:threaded_estop_reader",
9291
"//software/geom:angle",
9392
"//software/geom:point",

src/software/ai/evaluation/calc_best_shot.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ std::optional<Shot> calcBestShotOnGoal(const Segment &goal_post, const Point &sh
44
const std::vector<Robot> &robot_obstacles,
55
TeamType goal, double radius)
66
{
7+
// Don't return a shot if the ball is behind the net
8+
if ((goal == TeamType::FRIENDLY && shot_origin.x() < goal_post.getStart().x()) ||
9+
(goal == TeamType::ENEMY && shot_origin.x() > goal_post.getStart().x()))
10+
{
11+
return std::nullopt;
12+
}
13+
714
size_t max_num_obstacles = robot_obstacles.size();
815

916
Angle pos_post_angle = (goal_post.getStart() - shot_origin).orientation();

src/software/ai/evaluation/keep_away.cpp

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,11 @@
33
#include "software/ai/passing/cost_function.h"
44
#include "software/geom/algorithms/closest_point.h"
55
#include "software/geom/algorithms/contains.h"
6-
#include "software/math/math_functions.h"
76
#include "software/optimization/gradient_descent_optimizer.hpp"
87

9-
double ratePasserPointForKeepAway(const Pass& pass, const Team& enemy_team)
8+
Point findKeepAwayTargetPoint(const World& world, const Pass& best_pass_so_far,
9+
const TbotsProto::PassingConfig& passing_config)
1010
{
11-
// the default values for these passing parameters
12-
// TODO: cleanup passing parameters as part of #1987
13-
static constexpr double PASSER_ENEMY_PROXIMITY_IMPORTANCE = 1.5;
14-
static constexpr double RECEIVER_ENEMY_PROXIMITY_IMPORTANCE = 0.;
15-
static const auto ENEMY_REACTION_TIME = Duration::fromSeconds(0);
16-
17-
18-
return ratePassEnemyRisk(enemy_team, pass, ENEMY_REACTION_TIME,
19-
RECEIVER_ENEMY_PROXIMITY_IMPORTANCE) *
20-
(1 - std::max(0., calculateProximityRisk(pass.passerPoint(), enemy_team,
21-
PASSER_ENEMY_PROXIMITY_IMPORTANCE)));
22-
}
23-
24-
25-
Point findKeepAwayTargetPoint(const World& world, const Pass& best_pass_so_far)
26-
{
27-
static constexpr auto KEEPAWAY_SEARCH_CIRCLE_RADIUS = 0.5;
28-
29-
// the width of both the field boundary sigmoid and the circular search region sigmoid
30-
static constexpr auto SIGMOID_WIDTH = 0.1;
3111
// the inward offset of the field boundaries to use for the field lines sigmoid
3212
static constexpr auto FIELD_SIZE_REDUCTION_M = 0.25;
3313

@@ -38,10 +18,6 @@ Point findKeepAwayTargetPoint(const World& world, const Pass& best_pass_so_far)
3818
// we need to scale the gradient appropriately. Value empirically determined.
3919
static constexpr GradientDescentOptimizer<2>::ParamArray PARAM_WEIGHTS = {0.1, 0.1};
4020

41-
42-
// the region to which the optimization is (effectively) constrained to
43-
Circle keepaway_search_region(world.ball().position(), KEEPAWAY_SEARCH_CIRCLE_RADIUS);
44-
4521
// a reduced field rectangle to effectively constrain the optimization to field
4622
// boundaries
4723
const auto& field_bounds = world.field().fieldLines();
@@ -54,12 +30,8 @@ Point findKeepAwayTargetPoint(const World& world, const Pass& best_pass_so_far)
5430
// the position rating function we want to maximize
5531
const auto keepaway_point_cost = [&](const std::array<double, 2>& passer_pt_array) {
5632
Point passer_pt(std::get<0>(passer_pt_array), std::get<1>(passer_pt_array));
57-
Pass pass(passer_pt, best_pass_so_far.receiverPoint(), best_pass_so_far.speed());
58-
return ratePasserPointForKeepAway(pass, world.enemyTeam()) *
59-
// constrain the optimization to a circular area around the ball
60-
circleSigmoid(keepaway_search_region, passer_pt, SIGMOID_WIDTH) *
61-
// don't try to dribble the ball off the field
62-
rectangleSigmoid(reduced_field_bounds, passer_pt, SIGMOID_WIDTH);
33+
return rateKeepAwayPosition(passer_pt, world, best_pass_so_far,
34+
reduced_field_bounds, passing_config);
6335
};
6436
GradientDescentOptimizer<2> optimizer{PARAM_WEIGHTS};
6537
auto passer_pt_array = optimizer.maximize(

0 commit comments

Comments
 (0)