From 6ba011ea5aacaec17ff143903679e04f3a56cfa6 Mon Sep 17 00:00:00 2001 From: energyinjoles Date: Wed, 8 Apr 2026 19:22:30 +0800 Subject: [PATCH] flip get_formation to return right, left instead of left, right for standardisation --- utama_core/config/formations.py | 8 ++++---- utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py | 4 ++-- utama_core/run/strategy_runner.py | 4 ++-- utama_core/strategy/examples/startup_strategy.py | 2 +- utama_core/tests/strategy_runner/test_grsim_sim_setup.py | 4 ++-- utama_core/tests/strategy_runner/test_rsim_formations.py | 4 ++-- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/utama_core/config/formations.py b/utama_core/config/formations.py index 0a03fc63..5f2873ee 100644 --- a/utama_core/config/formations.py +++ b/utama_core/config/formations.py @@ -136,8 +136,8 @@ def _validate_team_separation(left, right): def get_formations( bounds: FieldBounds, - n_left: int, n_right: int, + n_left: int, formation_type: FormationType, ) -> tuple[list[FormationEntry], list[FormationEntry]]: """ @@ -146,13 +146,13 @@ def get_formations( Args: bounds: FieldBounds object defining the top-left and bottom-right corners of the field. - n_left: Number of robots on the left team. n_right: Number of robots on the right team. + n_left: Number of robots on the left team. formation_type: The type of formation to generate (e.g., START_ONE). Returns: tuple[list[FormationEntry], list[FormationEntry]]: A tuple containing two lists of FormationEntry objects. - left and right team formations respectively. + (right, left) team formations respectively. """ if n_left > MAX_ROBOTS or n_right > MAX_ROBOTS: raise ValueError( @@ -174,4 +174,4 @@ def get_formations( _validate_bounds_and_intra_team_collision(right, bounds) _validate_team_separation(left, right) - return left, right + return right, left diff --git a/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py b/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py index f3e81723..26d1cd6b 100644 --- a/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py +++ b/utama_core/rsoccer_simulator/src/ssl/envs/standard_ssl.py @@ -117,10 +117,10 @@ def __init__( # Makes the implicit assumption of blue on left and yellow on right if formation not given # This assumption is faulty for normal strats, but it is necessary if rsim is spawned in isolation with no strat context if blue_starting_formation is None or yellow_starting_formation is None: - self.blue_formation, self.yellow_formation = get_formations( + self.yellow_formation, self.blue_formation = get_formations( STANDARD_FIELD_DIMS.full_field_bounds, - n_left=n_robots_blue, n_right=n_robots_yellow, + n_left=n_robots_blue, formation_type=FormationType.START_ONE, ) diff --git a/utama_core/run/strategy_runner.py b/utama_core/run/strategy_runner.py index 2d1a8838..450a8d56 100644 --- a/utama_core/run/strategy_runner.py +++ b/utama_core/run/strategy_runner.py @@ -347,10 +347,10 @@ def _load_sim( if self.mode == Mode.REAL: return None, None - left_start, right_start = get_formations( + right_start, left_start = get_formations( bounds=self.field_bounds, - n_left=self.exp_enemy if self.my_team_is_right else self.exp_friendly, n_right=self.exp_friendly if self.my_team_is_right else self.exp_enemy, + n_left=self.exp_enemy if self.my_team_is_right else self.exp_friendly, formation_type=FormationType.START_ONE, ) diff --git a/utama_core/strategy/examples/startup_strategy.py b/utama_core/strategy/examples/startup_strategy.py index e27d3d67..ffcb9607 100644 --- a/utama_core/strategy/examples/startup_strategy.py +++ b/utama_core/strategy/examples/startup_strategy.py @@ -14,7 +14,7 @@ def generate_starting_positions(is_right_team: bool): """ Generate starting and target formations based on team side. """ - left_formation, right_formation = get_formations( + right_formation, left_formation = get_formations( STANDARD_FIELD_DIMS.full_field_bounds, MAX_ROBOTS, MAX_ROBOTS, diff --git a/utama_core/tests/strategy_runner/test_grsim_sim_setup.py b/utama_core/tests/strategy_runner/test_grsim_sim_setup.py index 0c64dc32..040d4ac1 100644 --- a/utama_core/tests/strategy_runner/test_grsim_sim_setup.py +++ b/utama_core/tests/strategy_runner/test_grsim_sim_setup.py @@ -83,10 +83,10 @@ def test_grsim_spawn_positions_and_ball_use_field_bounds_center(): assert isinstance(runner.sim_controller, _FakeGRSimController) - left_start, right_start = get_formations( + right_start, left_start = get_formations( bounds=bounds, - n_left=exp_friendly, n_right=exp_enemy, + n_left=exp_friendly, formation_type=FormationType.START_ONE, ) expected_yellow, expected_blue = map_left_right_to_colors( diff --git a/utama_core/tests/strategy_runner/test_rsim_formations.py b/utama_core/tests/strategy_runner/test_rsim_formations.py index 618513c4..0f90151d 100644 --- a/utama_core/tests/strategy_runner/test_rsim_formations.py +++ b/utama_core/tests/strategy_runner/test_rsim_formations.py @@ -81,10 +81,10 @@ def test_rsim_formation_allocation_and_spawn_positions( exp_enemy=n_enemy, ) - left_start, right_start = get_formations( + right_start, left_start = get_formations( bounds=runner.field_bounds, - n_left=n_enemy if team_on_right else n_friendly, n_right=n_friendly if team_on_right else n_enemy, + n_left=n_enemy if team_on_right else n_friendly, formation_type=FormationType.START_ONE, ) expected_yellow, expected_blue = map_left_right_to_colors(