diff --git a/battlecode25/engine/game/constants.py b/battlecode25/engine/game/constants.py index d181a25..665842f 100644 --- a/battlecode25/engine/game/constants.py +++ b/battlecode25/engine/game/constants.py @@ -79,6 +79,9 @@ class GameConstants: # The maximum turns a robot can have 0 paint before it dies. MAX_TURNS_WITHOUT_PAINT = 10 + # Moppers face greater enemy territory paint penalties than other robots by this factor + MOPPER_PAINT_PENALTY_MULTIPLIER = 2 + # ***************************** # ****** GAME MECHANICS ******* # ***************************** diff --git a/battlecode25/engine/game/game_fb.py b/battlecode25/engine/game/game_fb.py index 4584f1f..fab57c7 100644 --- a/battlecode25/engine/game/game_fb.py +++ b/battlecode25/engine/game/game_fb.py @@ -305,6 +305,16 @@ def add_die_action(self, id, was_exception): self.current_actions.append(action_offset) self.current_action_types.append(Action.Action().DieAction) + def add_remove_paint_action(self, affected_robot_id, paint): + action_offset = DamageAction.CreateDamageAction(self.builder, affected_robot_id, paint) + self.current_actions.append(action_offset) + self.current_actions.append(Action.Action().DamageAction) + + def add_complete_resource_pattern_action(self, loc): + action_offset = TransferAction.CreateTransferAction(self.builder, self.initial_map.loc_to_index(loc), 0) + self.current_actions.append(action_offset) + self.current_actions.append(Action.Action().TransferAction) + def add_team_info(self, team, money_amount, coverage_amount, resource_patterns): self.team_ids.append(fb_from_team(team)) self.team_money.append(money_amount) diff --git a/battlecode25/engine/game/robot.py b/battlecode25/engine/game/robot.py index 59c3322..3feb01f 100644 --- a/battlecode25/engine/game/robot.py +++ b/battlecode25/engine/game/robot.py @@ -108,12 +108,13 @@ def process_end_of_turn(self): paint_status = self.game.paint[loc_idx] if self.type.is_robot_type(): + multiplier = GameConstants.MOPPER_PAINT_PENALTY_MULTIPLIER if self.type == UnitType.MOPPER else 1 if self.game.team_from_paint(paint_status) == self.team: paint_penalty = 0 elif self.game.team_from_paint(paint_status) == Team.NEUTRAL: - paint_penalty = GameConstants.PENALTY_NEUTRAL_TERRITORY + paint_penalty = GameConstants.PENALTY_NEUTRAL_TERRITORY * multiplier else: - paint_penalty = GameConstants.PENALTY_ENEMY_TERRITORY + paint_penalty = GameConstants.PENALTY_ENEMY_TERRITORY * multiplier count = 0 for adj_loc in self.game.get_all_locations_within_radius_squared(self.loc, 2): adj_robot = self.game.get_robot(adj_loc) diff --git a/battlecode25/engine/game/robot_controller.py b/battlecode25/engine/game/robot_controller.py index cbd534c..ee6dc3e 100644 --- a/battlecode25/engine/game/robot_controller.py +++ b/battlecode25/engine/game/robot_controller.py @@ -349,6 +349,7 @@ def attack(self, loc: MapLocation, use_secondary_color: bool=False) -> None: target_robot = self.game.get_robot(loc) if target_robot and target_robot.type.is_robot_type() and target_robot.team != self.robot.team: target_robot.add_paint(-GameConstants.MOPPER_ATTACK_PAINT_DEPLETION) + self.game.game_fb.add_remove_paint_action(target_robot.id, GameConstants.MOPPER_ATTACK_PAINT_DEPLETION) self.robot.add_paint(GameConstants.MOPPER_ATTACK_PAINT_ADDITION) self.game.game_fb.add_attack_action(target_robot.id) @@ -415,6 +416,7 @@ def mop_swing(self, dir: Direction) -> None: target_robot = self.game.get_robot(new_loc) if target_robot and target_robot.team != self.robot.team: target_robot.add_paint(-GameConstants.MOPPER_SWING_PAINT_DEPLETION) + self.game.game_fb.add_remove_paint_action(target_robot.id, GameConstants.MOPPER_SWING_PAINT_DEPLETION) target_ids.append(target_robot.id) else: target_ids.append(0) @@ -486,6 +488,8 @@ def mark_resource_pattern(self, loc: MapLocation) -> None: def assert_can_mark(self, loc: MapLocation) -> None: self.assert_is_robot_type(self.robot.type) self.assert_can_act_location(loc, GameConstants.MARK_RADIUS_SQUARED) + if not self.game.is_passable(loc): + raise RobotError("Cannot mark a square that is not paintable.") def can_mark(self, loc: MapLocation) -> bool: try: @@ -572,6 +576,7 @@ def can_complete_resource_pattern(self, loc: MapLocation) -> bool: def complete_resource_pattern(self, loc: MapLocation) -> None: self.assert_can_complete_resource_pattern(loc) self.game.complete_resource_pattern(self.robot.team, loc) + self.game.game_fb.add_complete_resource_pattern_action(loc) # BUILDING FUNCTIONS