Skip to content

Commit

Permalink
Penalty kick behavioral fixes (#1321)
Browse files Browse the repository at this point in the history
* dissallow striker moving towards ball

* prevent midfielders from running across field in penalty kick

* ignore striker message timeout and dont become searcher in penalty kick

* as ref
  • Loading branch information
MaikRe authored Jul 21, 2024
1 parent eb3fa2d commit e1a847d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
3 changes: 2 additions & 1 deletion crates/control/src/behavior/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ impl Behavior {
},
_ => match world_state.filtered_game_controller_state {
Some(FilteredGameControllerState {
game_state: FilteredGameState::Ready { .. },
game_state:
FilteredGameState::Ready { .. } | FilteredGameState::Playing { .. },
sub_state: Some(SubState::PenaltyKick),
kicking_team: Team::Opponent,
..
Expand Down
24 changes: 17 additions & 7 deletions crates/control/src/behavior/support.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,23 @@ fn support_pose(
.filtered_game_controller_state
.as_ref()
.map(|filtered_game_controller_state| filtered_game_controller_state.game_state);
let mut clamped_x = match filtered_game_state {
Some(FilteredGameState::Ready { .. })
| Some(FilteredGameState::Playing {
ball_is_free: false,
kick_off: true,
..
}) => supporting_position
let sub_state = world_state
.filtered_game_controller_state
.as_ref()
.map(|filtered_game_controller_state| filtered_game_controller_state.sub_state);
let mut clamped_x = match (filtered_game_state, sub_state) {
(Some(FilteredGameState::Ready { .. }), Some(Some(SubState::PenaltyKick))) => {
supporting_position.x().max(field_dimensions.length / 4.0)
}
(Some(FilteredGameState::Ready { .. }), _)
| (
Some(FilteredGameState::Playing {
ball_is_free: false,
kick_off: true,
..
}),
_,
) => supporting_position
.x()
.min(maximum_x_in_ready_and_when_ball_is_not_free),
_ => supporting_position.x().clamp(minimum_x, maximum_x),
Expand Down
9 changes: 8 additions & 1 deletion crates/control/src/role_assignment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,14 @@ impl RoleAssignment {

let mut team_ball = self.team_ball;

if spl_striker_message_timeout {
let is_in_penalty_kick = matches!(
context.filtered_game_controller_state,
Some(FilteredGameControllerState {
sub_state: Some(SubState::PenaltyKick),
..
})
);
if spl_striker_message_timeout && !is_in_penalty_kick {
match new_role {
Role::Keeper => {
team_ball = None;
Expand Down

0 comments on commit e1a847d

Please sign in to comment.