-
Notifications
You must be signed in to change notification settings - Fork 61
Searcher Standing Delay #1735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Searcher Standing Delay #1735
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3f66fc7
add timeout for defender to become searcher
paudar 6fbe745
only affect searchers that where defender
paudar bc06a60
add check for y-position of searcher
paudar 370c3e0
fmt file
paudar 20deaa0
stand only when in own half
paudar 0e6c103
make previous role the real previous role
paudar 596adeb
forever keeper
paudar 01c9449
more edge-cases in standing seracher bevi_test
paudar 5d01132
change bevihavior scenario
paudar e1fb18f
add aditional assertion at standing_searcher bevytest
paudar 7082a7e
add assertions to bevihavior standing_searcher
paudar 7af02ba
change parameter for later search motion
paudar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
crates/bevyhavior_simulator/src/bin/standing_searcher.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| use std::time::Duration; | ||
|
|
||
| use bevy::prelude::*; | ||
|
|
||
| use linear_algebra::{point, vector}; | ||
| use scenario::scenario; | ||
| use spl_network_messages::{GameState, Penalty, PlayerNumber, Team}; | ||
|
|
||
| use bevyhavior_simulator::{ | ||
| ball::BallResource, | ||
| game_controller::GameControllerCommand, | ||
| robot::Robot, | ||
| time::{Ticks, TicksTime}, | ||
| }; | ||
| use types::{ball_position::SimulatorBallState, motion_command::MotionCommand}; | ||
|
|
||
| #[scenario] | ||
| fn standing_searcher(app: &mut App) { | ||
| app.add_systems(Startup, startup); | ||
| app.add_systems(Update, update); | ||
| } | ||
|
|
||
| fn startup( | ||
| mut commands: Commands, | ||
| mut game_controller_commands: EventWriter<GameControllerCommand>, | ||
| ) { | ||
| for number in [ | ||
| PlayerNumber::One, | ||
| PlayerNumber::Two, | ||
| PlayerNumber::Three, | ||
| PlayerNumber::Four, | ||
| PlayerNumber::Five, | ||
| PlayerNumber::Seven, | ||
| ] { | ||
| commands.spawn(Robot::new(number)); | ||
| } | ||
| game_controller_commands.send(GameControllerCommand::SetGameState(GameState::Ready)); | ||
| } | ||
|
|
||
| fn update( | ||
| time: Res<Time<Ticks>>, | ||
| mut ball: ResMut<BallResource>, | ||
| mut exit: EventWriter<AppExit>, | ||
| mut robots: Query<&mut Robot>, | ||
| mut game_controller_commands: EventWriter<GameControllerCommand>, | ||
| ) { | ||
| if time.ticks() == 4150 { | ||
| game_controller_commands.send(GameControllerCommand::Penalize( | ||
| PlayerNumber::Two, | ||
| Penalty::Manual { | ||
| remaining: Duration::from_secs(1), | ||
| }, | ||
| Team::Hulks, | ||
| )); | ||
| } | ||
|
|
||
| if time.ticks() == 4155 { | ||
| game_controller_commands.send(GameControllerCommand::Unpenalize( | ||
| PlayerNumber::Two, | ||
| Team::Hulks, | ||
| )); | ||
| } | ||
|
|
||
| if time.ticks() == 4200 { | ||
| ball.state = None; | ||
| } | ||
|
|
||
| if time.ticks() == 4660 { | ||
| if let MotionCommand::Stand { .. } = robots | ||
| .iter_mut() | ||
| .find(|robot| robot.parameters.player_number == PlayerNumber::Two) | ||
| .unwrap() | ||
| .database | ||
| .main_outputs | ||
| .motion_command | ||
| { | ||
| println!("Standing searcher at penalty walk-in"); | ||
| exit.send(AppExit::from_code(1)); | ||
| } | ||
| if let MotionCommand::Walk { .. } = robots | ||
| .iter_mut() | ||
| .find(|robot| robot.parameters.player_number == PlayerNumber::Three) | ||
| .unwrap() | ||
| .database | ||
| .main_outputs | ||
| .motion_command | ||
| { | ||
| println!("Moving searcher after ball loss"); | ||
| exit.send(AppExit::from_code(1)); | ||
| } | ||
| } | ||
|
|
||
| if time.ticks() == 5500 { | ||
| ball.state = Some(SimulatorBallState { | ||
| position: point![-2.7, -0.2], | ||
| velocity: vector![0.0, 0.0], | ||
| }); | ||
| } | ||
| if time.ticks() == 6000 { | ||
| ball.state = None; | ||
| } | ||
| if time.ticks() == 6750 { | ||
| ball.state = Some(SimulatorBallState { | ||
| position: point![4.0, -0.2], | ||
| velocity: vector![0.0, 0.0], | ||
| }); | ||
| } | ||
| if time.ticks() == 7200 { | ||
| ball.state = None; | ||
| } | ||
| if time.ticks() >= 10_000 { | ||
| println!("Done"); | ||
| exit.send(AppExit::Success); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.