Skip to content

Commit

Permalink
Merge branch 'main' into public-release
Browse files Browse the repository at this point in the history
  • Loading branch information
TheApplePieGod committed Jan 10, 2025
2 parents 522976f + 337ee0c commit 16af00f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
3 changes: 3 additions & 0 deletions battlecode25/engine/game/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *******
# *****************************
Expand Down
10 changes: 10 additions & 0 deletions battlecode25/engine/game/game_fb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions battlecode25/engine/game/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions battlecode25/engine/game/robot_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 16af00f

Please sign in to comment.